/** * Tests if <code>VersionHistory.getBaseVersion()</code> throws an {@link * javax.jcr.UnsupportedRepositoryOperationException} */ public void testGetBaseVersionJcr2() throws Exception { try { versionManager.getBaseVersion(vHistory.getPath()); fail("VersionHistory.getBaseVersion() did not throw an UnsupportedRepositoryOperationException"); } catch (UnsupportedRepositoryOperationException success) { } }
/** * Tests if <code>VersionHistory.getCorrespondingNodePath(String)</code> * returns the right path */ public void testGetCorrespondingNodePath() throws Exception { assertEquals("VersionHistory.getCorrespondingNodePath(String) did not return the right path", vHistory.getPath(), vHistory.getCorrespondingNodePath(workspaceName)); }
/** * Tests if <code>VersionHistory.checkin()</code> throws an {@link * javax.jcr.UnsupportedRepositoryOperationException} */ public void testCheckinJcr2() throws Exception { try { versionManager.checkin(vHistory.getPath()); fail("VersionHistory.checkin() did not throw an UnsupportedRepositoryOperationException"); } catch (UnsupportedRepositoryOperationException success) { } }
/** * Tests if <code>VersionHistory.getVersionHistory()</code> throws an {@link * javax.jcr.UnsupportedRepositoryOperationException} */ public void testGetVersionHistoryJcr2() throws Exception { try { versionManager.getVersionHistory(vHistory.getPath()); fail("VersionHistory.getVersionHistory() did not throw an UnsupportedRepositoryOperationException"); } catch (UnsupportedRepositoryOperationException success) { } }
/** * Tests if <code>VersionHistory.restoreByLabel(String, boolean)</code> * throws an {@link javax.jcr.UnsupportedRepositoryOperationException} */ public void testRestoreByLabelJcr2() throws Exception { try { versionManager.restoreByLabel(vHistory.getPath(), "abc", true); fail("VersionHistory.restoreByLabel(String,boolean) did not throw an UnsupportedRepositoryOperationException"); } catch (UnsupportedRepositoryOperationException success) { } }
/** * Tests if <code>VersionHistory.cancelMerge(Version)</code> throws an * {@link javax.jcr.UnsupportedRepositoryOperationException} */ public void testCancelMergeJcr2() throws Exception { try { versionManager.cancelMerge(vHistory.getPath(), version); fail("VersionHistory.cancelMerge(Version) did not throw an UnsupportedRepositoryOperationException"); } catch (UnsupportedRepositoryOperationException success) { } }
/** * Tests if <code>VersionHistory.doneMerge(Version)</code> throws an {@link * javax.jcr.UnsupportedRepositoryOperationException} */ public void testDoneMergeJcr2() throws Exception { try { versionManager.doneMerge(vHistory.getPath(), version); fail("VersionHistory should not be versionable: VersionHistory.doneMerge(Version) did not throw an UnsupportedRepositoryOperationException"); } catch (UnsupportedRepositoryOperationException success) { } }
/** * Tests if <code>VersionHistory.checkout()</code> throws an {@link * javax.jcr.UnsupportedRepositoryOperationException} */ public void testCheckoutJcr2() throws Exception { try { versionManager.checkout(vHistory.getPath()); fail("VersionHistory.checkout() did not throw an UnsupportedRepositoryOperationException"); } catch (UnsupportedRepositoryOperationException success) { } }
/** * Tests if <code>VersionHistory.isCheckedOut()</code> returns * <code>true</code> */ public void testIsCheckedOutJcr2() throws Exception { assertTrue("VersionHistory.isCheckedOut() did not return true", versionManager.isCheckedOut(vHistory.getPath())); }
/** * Tests if <code>VersionHistory.restore(String, boolean)</code> and * <code>VersionHistory.restore(Version, boolean)</code> throw an {@link * UnsupportedRepositoryOperationException} and <code>VersionHistory.restore(Version, * String, boolean)</code> throws a {@link ConstraintViolationException}. */ public void testRestoreJcr2() throws Exception { try { versionManager.restore(vHistory.getPath(), "abc", true); fail("VersionHistory.restore(String,boolean) did not throw an UnsupportedRepositoryOperationException"); } catch (UnsupportedRepositoryOperationException success) { } }
/** * Tests if <code>VersionHistory.getPath()</code> returns the right path */ public void testGetPath() throws Exception { assertTrue("VersionHistory.getPath() does not return the right path", vHistory.getPath().startsWith("/" + superuser.getNamespacePrefix(NS_JCR_URI) + ":system/" + superuser.getNamespacePrefix(NS_JCR_URI) + ":versionStorage/")); }
/** * Tests if <code>VersionHistory.getLock()</code> throws an {@link * javax.jcr.lock.LockException} */ public void testGetLockJcr2() throws Exception { ensureLockingSupported(); try { vHistory.getSession().getWorkspace().getLockManager().getLock(vHistory.getPath()); fail("VersionHistory should not be lockable: VersionHistory.getLock() did not throw a LockException"); } catch (LockException success) { } }
/** * Tests if <code>VersionHistory.unlock()</code> throws a {@link * javax.jcr.lock.LockException} */ public void testUnlockJcr2() throws Exception { ensureLockingSupported(); try { vHistory.getSession().getWorkspace().getLockManager().unlock(vHistory.getPath()); fail("VersionHistory should not be lockable: VersionHistory.unlock() did not throw a LockException"); } catch (LockException success) { } }
/** * Tests if <code>VersionHistory.holdsLock()</code> returns * <code>false</code> */ public void testHoldsLockJcr2() throws Exception { ensureLockingSupported(); assertFalse("VersionHistory.holdsLock() did not return false", vHistory.getSession().getWorkspace().getLockManager().holdsLock(vHistory.getPath())); }
/** * Tests if <code>VersionHistory.isLocked()</code> returns * <code>false</code> */ public void testIsLockedJcr2() throws Exception { ensureLockingSupported(); assertFalse("VersionHistory.isLocked() did not return false", vHistory.getSession().getWorkspace().getLockManager().isLocked(vHistory.getPath())); }
public Object doInJcr( final Session session ) throws RepositoryException { Item item = session.getItem( absPath ); Assert.isTrue( item.isNode() ); Node node = ( (Node) item ); return node.getVersionHistory().getPath(); } } );
/** * @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))); }
/** * @since oak */ @Test public void testGetVersionHistoryParentNode() throws Exception { String vhParentPath = Text.getRelativeParent(vh.getPath(), 1); assertFalse(testSession.nodeExists(vhParentPath)); try { testSession.getNode(vhParentPath); fail("version storage intermediate node must not be accessible"); } catch (PathNotFoundException e) { // success } }
/** * @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))); }
/** * @since oak */ @Test public void testHasVersionContentNodes() throws Exception { // version information must still be accessible assertTrue(testSession.nodeExists(v.getPath())); assertTrue(testSession.nodeExists(v2.getPath())); assertTrue(testSession.nodeExists(vh.getPath())); }