use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class CheckinTest method testMultipleCheckinHasNoEffectJcr2.
/**
* Test if VersionManager.checkin(P) has no effect if the path P resolves
* to a checked-in node.
*
* @throws RepositoryException
*/
public void testMultipleCheckinHasNoEffectJcr2() throws RepositoryException {
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
Version v = versionManager.checkin(path);
try {
Version v2 = versionManager.checkin(path);
assertTrue("Calling VersionManager.checkin(P) must not have an if the path P resolves to a node that is already checked-in.", v.isSame(v2));
} catch (RepositoryException e) {
fail("Calling VersionManager.checkin(P) must not throw an exception if the path P resolves to a node that is already checked-in.");
}
}
use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class CheckinTest method testIsNotCheckedOutJcr2.
/**
* Test if VersionManager.isCheckedOut(P) returns false after calling VersionManager.checkin(P).
*
* @throws RepositoryException
*/
public void testIsNotCheckedOutJcr2() throws RepositoryException {
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
versionManager.checkin(path);
boolean isCheckedOut = versionManager.isCheckedOut(path);
assertFalse("VersionManager.isCheckedOut(P) must return false after VersionManager.checkin(P).", isCheckedOut);
}
use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class CheckinTest method testBaseVersionAfterCheckinJcr2.
/**
* Test if versionable node N's jcr:baseVersion property is set to refer to
* the new version after checkin.
*
* @throws RepositoryException
*/
public void testBaseVersionAfterCheckinJcr2() throws RepositoryException {
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
Version v = versionManager.checkin(path);
Value baseVersionRef = versionableNode.getProperty(jcrBaseVersion).getValue();
assertEquals("Checked-in node's jcr:baseVersion property is set to refer to the version created on checkin.", superuser.getValueFactory().createValue(v), baseVersionRef);
}
use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class CheckoutTest method testCheckoutTwiceDoesNotThrowJcr2.
/**
* Test if VersionManager.checkout(P) doesn't throw any exception if P
* denotes the absolute path of a versionable node that has been checked
* out before.
*/
public void testCheckoutTwiceDoesNotThrowJcr2() throws RepositoryException {
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
versionManager.checkout(path);
versionManager.checkout(path);
}
use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class CheckoutTest method testCheckoutCopiesBaseValueToPredecessorPropertyJcr2.
/**
* Test if VersionManager.checkout(P), with P denoting the absolute path
* of a versionable node, copies the node's jcr:baseVersion to the node's
* jcr:predecessors property (no save required).
*/
public void testCheckoutCopiesBaseValueToPredecessorPropertyJcr2() throws RepositoryException {
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
Value baseVersionValue = versionableNode.getProperty(jcrBaseVersion).getValue();
versionManager.checkout(path);
Value[] predecessorsValues = versionableNode.getProperty(jcrPredecessors).getValues();
// loop over all values of jcr:predecessors property as it's not sure
// on which position jcr:baseVersion is copied.
boolean foundBaseVersionProp = false;
int i = 0;
while (i < predecessorsValues.length && !foundBaseVersionProp) {
if (predecessorsValues[i].equals(baseVersionValue)) {
foundBaseVersionProp = true;
}
i++;
}
if (!foundBaseVersionProp) {
fail("After calling Node.checkout() the current value of node's jcr:baseVersion must be copied to node's jcr:predecessors property");
}
}
Aggregations