/** * Tests if <code>VersionHistory.isSame()</code> returns the right * <code>boolean</code> value */ public void testIsSame() throws Exception { assertTrue("VersionHistory.isSame(Item) did not return true", vHistory.isSame(version.getParent())); }
/** * Checks if the specified version belongs to this <code>VersionHistory</code>. * This method throws <code>VersionException</code> if {@link Version#getContainingHistory()} * is not the same item than this <code>VersionHistory</code>. * * @param version * @throws javax.jcr.version.VersionException * @throws javax.jcr.RepositoryException */ private void checkValidVersion(Version version) throws VersionException, RepositoryException { if (!version.getContainingHistory().isSame(this)) { throw new VersionException("Specified version '" + version.getName() + "' is not part of this history."); } }
/** * Checks if the specified version belongs to this <code>VersionHistory</code>. * This method throws <code>VersionException</code> if {@link Version#getContainingHistory()} * is not the same item than this <code>VersionHistory</code>. * * @param version * @throws javax.jcr.version.VersionException * @throws javax.jcr.RepositoryException */ private void checkValidVersion(Version version) throws VersionException, RepositoryException { if (!version.getContainingHistory().isSame(this)) { throw new VersionException("Specified version '" + version.getName() + "' is not part of this history."); } }
/** * Tests if {@link javax.jcr.version.Version#getContainingHistory()} returns * the correct VersionHistory instance. */ public void testGetContainingHistory() throws RepositoryException { // create version versionableNode.checkout(); Version version = versionableNode.checkin(); assertTrue("Method getContainingHistory() must return the same VersionHistory " + "as getVersionHistory() of the corresponding Node.", versionableNode.getVersionHistory().isSame(version.getContainingHistory())); } }
/** * @since oak */ @Test public void testGetVersionHistoryNode() throws Exception { // accessing the version history must be allowed if the versionable node // is readable to the editing test session. Node testNode = testSession.getNode(versionablePath); String vhPath = vh.getPath(); String vhUUID = vh.getIdentifier(); assertTrue(vh.isSame(testNode.getSession().getNode(vhPath))); assertTrue(vh.isSame(testNode.getSession().getNodeByIdentifier(vhUUID))); assertTrue(vh.isSame(testNode.getSession().getNodeByUUID(vhUUID))); }
public void testCopy() throws RepositoryException { Workspace wsp = superuser.getWorkspace(); VersionManager vMgr = wsp.getVersionManager(); String srcPath = versionableNode.getPath(); String dstPath = getProperty("destination"); wsp.copy(srcPath, dstPath); // check versionable Node v = superuser.getNode(dstPath); assertTrue("Copied Node.isNodeType(mix:simpleVersionable) must return true.", v.isNodeType(mixSimpleVersionable)); assertFalse("Copied Node.isNodeType(mix:versionable) must return false.", v.isNodeType(mixVersionable)); // check different version history VersionHistory vh1 = vMgr.getVersionHistory(srcPath); VersionHistory vh2 = vMgr.getVersionHistory(dstPath); assertFalse("Copied node needs a new version history.", vh1.isSame(vh2)); // check if 1 version assertEquals("Copied node must have 1 version.", 1, getNumberOfVersions(vh2)); } }
/** * @since oak (DIFF: jr required jcr:versionManagement privilege on the version store) */ @Test public void testAccessVersionHistory() throws Exception { Node n = createVersionableNode(superuser.getNode(path)); allow(n.getPath(), versionPrivileges); Node testNode = testSession.getNode(n.getPath()); testNode.checkin(); testNode.checkout(); // accessing the version history must be allowed if the versionable node // is readable to the editing test session. VersionHistory vh = testNode.getVersionHistory(); String vhPath = vh.getPath(); String vhUUID = vh.getIdentifier(); assertTrue(vh.isSame(testNode.getSession().getNode(vhPath))); assertTrue(vh.isSame(testNode.getSession().getNodeByIdentifier(vhUUID))); assertTrue(vh.isSame(testNode.getSession().getNodeByUUID(vhUUID))); }
@Test public void testCopyVersionableNode() throws Exception { Session session = getAdminSession(); Node toCopy = session.getNode(TEST_PATH + "/source/node"); toCopy.addMixin(JcrConstants.MIX_VERSIONABLE); session.save(); session.getWorkspace().copy(TEST_PATH + "/source/node", TEST_PATH + "/target/copied"); assertTrue(testNode.hasNode("source/node")); assertTrue(testNode.hasNode("target/copied")); Node copy = testNode.getNode("target/copied"); assertTrue(copy.isNodeType(JcrConstants.MIX_VERSIONABLE)); assertFalse(copy.getVersionHistory().isSame(toCopy.getVersionHistory())); }
public void testCopy() throws RepositoryException { Workspace wsp = superuser.getWorkspace(); VersionManager vMgr = wsp.getVersionManager(); String srcPath = versionableNode.getPath(); String dstPath = getProperty("destination"); wsp.copy(srcPath, dstPath); // check versionable Node v = superuser.getNode(dstPath); assertTrue("Copied Node.isNodeType(mix:cersionable) must return true.", v.isNodeType(mixVersionable)); // check different version history VersionHistory vh1 = vMgr.getVersionHistory(srcPath); VersionHistory vh2 = vMgr.getVersionHistory(dstPath); assertFalse("Copied node needs a new version history.", vh1.isSame(vh2)); // check if 1 version assertEquals("Copied node must have 1 version.", 1, getNumberOfVersions(vh2)); // check if jcr:copiedFrom is set correctly assertTrue("Version history of desination must have a jcr:copiedFrom property", vh2.hasProperty(jcrCopiedFrom)); Node ref = vh2.getProperty(jcrCopiedFrom).getNode(); Version base = vMgr.getBaseVersion(srcPath); assertTrue("jcr:copiedFrom must point to the base version of the original.", ref.isSame(base)); } }
/** * @since oak */ @Test public void testGetVersion() throws Exception { // accessing the version history must be allowed if the versionable node // is readable to the editing test session. Node testNode = testSession.getNode(versionablePath); VersionHistory vh = testNode.getVersionHistory(); Version version = vh.getVersion(v.getName()); assertTrue(v.isSame(version)); assertTrue(vh.isSame(version.getContainingHistory())); version = vh.getVersion(v2.getName()); assertTrue(v2.isSame(version)); assertTrue(vh.isSame(version.getContainingHistory())); }
if (!vH.isSame(version.getContainingHistory())) { throw new VersionException("Version " + version + " does not correspond to the restore target.");
if (!vH.isSame(version.getContainingHistory())) { throw new VersionException("Version " + version + " does not correspond to the restore target.");