use of javax.jcr.version.VersionManager in project jackrabbit-oak by apache.
the class VersionTest method testFrozenUUID.
// OAK-1009 & OAK-1346
public void testFrozenUUID() throws RepositoryException {
Node n = testRootNode.addNode(nodeName1, testNodeType);
n.addMixin(mixVersionable);
Node child = n.addNode(nodeName2, "nt:folder");
superuser.save();
VersionManager vMgr = superuser.getWorkspace().getVersionManager();
Version v = vMgr.checkpoint(n.getPath());
vMgr.checkpoint(n.getPath());
Version baseVersion = vMgr.getBaseVersion(n.getPath());
Node frozenChild = baseVersion.getFrozenNode().getNode(child.getName());
assertEquals(child.getIdentifier(), frozenChild.getProperty(Property.JCR_FROZEN_UUID).getString());
vMgr.restore(v, true);
}
use of javax.jcr.version.VersionManager in project jackrabbit-oak by apache.
the class VersionTest method testGetNodeByUUID.
@SuppressWarnings("deprecation")
public void testGetNodeByUUID() throws RepositoryException {
Node n = testRootNode.addNode(nodeName1, testNodeType);
n.addMixin(mixVersionable);
superuser.save();
VersionManager vMgr = superuser.getWorkspace().getVersionManager();
String uuid = vMgr.getBaseVersion(n.getPath()).getUUID();
assertTrue("Session.getNodeByUUID() did not return Version object for a nt:version node.", superuser.getNodeByUUID(uuid) instanceof Version);
}
use of javax.jcr.version.VersionManager in project jackrabbit-oak by apache.
the class VersionTest method testRemoveVersion.
// OAK-3130
public void testRemoveVersion() throws RepositoryException {
Node n = testRootNode.addNode(nodeName1, testNodeType);
n.addMixin(mixVersionable);
superuser.save();
VersionManager vMgr = superuser.getWorkspace().getVersionManager();
vMgr.checkin(n.getPath());
Version v = vMgr.getBaseVersion(n.getPath());
try {
v.getContainingHistory().removeVersion(v.getName());
fail("removeVersion() must fail with ReferentialIntegrityException");
} catch (ReferentialIntegrityException e) {
// expected
}
vMgr.checkout(n.getPath());
v = vMgr.getBaseVersion(n.getPath());
try {
v.getContainingHistory().removeVersion(v.getName());
fail("removeVersion() must fail with ReferentialIntegrityException");
} catch (ReferentialIntegrityException e) {
// expected
}
}
use of javax.jcr.version.VersionManager in project jackrabbit-oak by apache.
the class OpvIgnoreTest method testWritePropertyWithIgnoreOPVAfterCheckIn.
//OAK-3328
public void testWritePropertyWithIgnoreOPVAfterCheckIn() throws RepositoryException {
Node ignoreTestNode = testRootNode.addNode("ignoreTestNode", JcrConstants.NT_UNSTRUCTURED);
String ignoredPropertyName = "ignoredProperty";
NodeTypeTemplate mixinWithIgnoreProperty = createNodeTypeWithIgnoreOPVProperty(ignoredPropertyName);
Node node = ignoreTestNode.addNode("testNode", testNodeType);
node.addMixin(mixinWithIgnoreProperty.getName());
node.setProperty(ignoredPropertyName, "initial value");
node.addMixin(mixVersionable);
superuser.save();
VersionManager vMgr = superuser.getWorkspace().getVersionManager();
if (!node.isCheckedOut()) {
vMgr.checkout(node.getPath());
}
vMgr.checkin(node.getPath());
node.setProperty(ignoredPropertyName, "next value");
superuser.save();
Property ignoreProperty = node.getProperty(ignoredPropertyName);
assertEquals("next value", ignoreProperty.getString());
}
use of javax.jcr.version.VersionManager in project jackrabbit-oak by apache.
the class OpvIgnoreTest method testRemovePropertyWithIgnoreOPVAfterCheckIn.
//OAK-3328
public void testRemovePropertyWithIgnoreOPVAfterCheckIn() throws RepositoryException {
Node ignoreTestNode = testRootNode.addNode("ignoreTestNode", JcrConstants.NT_UNSTRUCTURED);
String ignoredPropertyName = "test:ignoredProperty";
NodeTypeTemplate mixinWithIgnoreProperty = createNodeTypeWithIgnoreOPVProperty(ignoredPropertyName);
Node node = ignoreTestNode.addNode("testNode", testNodeType);
node.addMixin(mixinWithIgnoreProperty.getName());
node.setProperty(ignoredPropertyName, "initial value");
node.addMixin(mixVersionable);
superuser.save();
VersionManager vMgr = superuser.getWorkspace().getVersionManager();
if (!node.isCheckedOut()) {
vMgr.checkout(node.getPath());
}
vMgr.checkin(node.getPath());
node.getProperty(ignoredPropertyName).remove();
superuser.save();
assertFalse(node.hasProperty(ignoredPropertyName));
}
Aggregations