use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class CheckoutTest method testIsCheckedOutNonVersionableNodeJcr2.
/**
* Test calling VersionManager.isCheckedOut(P) with P denoting the
* absolute path of a non-versionable node.
*/
public void testIsCheckedOutNonVersionableNodeJcr2() throws RepositoryException {
VersionManager versionManager = nonVersionableNode.getSession().getWorkspace().getVersionManager();
String path = nonVersionableNode.getPath();
boolean isCheckedOut = versionManager.isCheckedOut(path);
Node vParent = null;
try {
vParent = nonVersionableNode.getParent();
while (!vParent.isNodeType(mixVersionable)) {
vParent = vParent.getParent();
}
} catch (ItemNotFoundException e) {
// root reached.
}
if (vParent != null && vParent.isNodeType(mixVersionable)) {
String parentPath = vParent.getPath();
if (versionManager.isCheckedOut(parentPath)) {
assertTrue("VersionManager.isCheckedOut(P) must return true if P denotes the absolute path of a non-versionable node whose nearest versionable ancestor is checked-out.", isCheckedOut);
} else {
assertFalse("VersionManager.isCheckedOut(P) must return false if P denotes the absolute path of a non-versionable node whose nearest versionable ancestor is checked-in.", isCheckedOut);
}
} else {
assertTrue("VersionManager.isCheckedOut(P) must return true if P denotes the absolute path of a non-versionable node that has no versionable ancestor", isCheckedOut);
}
}
use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class CheckinTest method setUp.
protected void setUp() throws Exception {
super.setUp();
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
versionManager.checkout(path);
}
use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class CheckinTest method testCheckinWithPendingChangesJcr2.
/**
* Test if VersionManager.checkin(P) throws InvalidItemStateException if
* the path P resolves to a node that has unsaved changes pending.
*
* @throws RepositoryException
*/
public void testCheckinWithPendingChangesJcr2() throws RepositoryException {
try {
// modify node without calling save()
versionableNode.setProperty(propertyName1, propertyValue);
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
versionManager.checkin(path);
fail("InvalidItemStateException must be thrown on attempt to checkin a node having any unsaved changes pending.");
} catch (InvalidItemStateException e) {
// ok
}
}
use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class CheckinTest method testPredecessorIsCopiedToNewVersionJcr2.
/**
* Test if the nodes jcr:predecessors property is copied to the new version
* on checkin.
*
* @throws RepositoryException
*/
public void testPredecessorIsCopiedToNewVersionJcr2() throws RepositoryException {
Value[] nPredecessorsValue = versionableNode.getProperty(jcrPredecessors).getValues();
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
Version v = versionManager.checkin(path);
Value[] vPredecessorsValue = v.getProperty(jcrPredecessors).getValues();
assertEquals("The versionable checked-out node's jcr:predecessors property is copied to the new version on checkin.", Arrays.asList(nPredecessorsValue), Arrays.asList(vPredecessorsValue));
}
use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class CheckinTest method testCheckinRemovesPredecessorPropertyJcr2.
/**
* Test if the node's jcr:predecessors property contains an empty value array
* after checkin.
*
* @throws RepositoryException
*/
public void testCheckinRemovesPredecessorPropertyJcr2() throws RepositoryException {
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
versionManager.checkin(path);
Value[] predecessorsValue = versionableNode.getProperty(jcrPredecessors).getValues();
assertTrue("Checkin must set the node's jcr:predecessors property to the empty array", predecessorsValue.length == 0);
}
Aggregations