use of javax.jcr.version.Version in project jackrabbit by apache.
the class FrozenNodeTest method testFrozenUUUID.
/**
* @throws RepositoryException
*/
public void testFrozenUUUID() throws RepositoryException, NotExecutableException {
// make versionable node referenceable
ensureMixinType(versionableNode, mixReferenceable);
versionableNode.getSession().save();
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
Version v = versionManager.checkin(path);
Node n = v.getFrozenNode();
String fuuid = n.getProperty(jcrFrozenUuid).getValue().getString();
String ruuid = versionableNode.getIdentifier();
assertEquals("jcr:frozenUuid needs to be equal to the getIdentifier() return value.", ruuid, fuuid);
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class FrozenNodeTest method testFrozenNodeType.
/**
* @throws RepositoryException
*/
public void testFrozenNodeType() throws RepositoryException {
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
Version v = versionManager.checkin(path);
Node n = v.getFrozenNode();
String fuuid = n.getProperty("jcr:frozenPrimaryType").getValue().getString();
String ruuid = versionableNode.getPrimaryNodeType().getName();
assertEquals("jcr:frozenPrimaryType needs to be equal to the getPrimaryNodeType() return value.", ruuid, fuuid);
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class RestoreTest method testRestoreChild1Jcr2_2.
public void testRestoreChild1Jcr2_2() throws RepositoryException {
versionableNode.addNode("child1");
versionableNode.getSession().save();
Version v1 = versionManager.checkin(versionableNode.getPath());
versionManager.checkout(versionableNode.getPath());
Version v2 = versionManager.checkin(versionableNode.getPath());
versionManager.restore(v1, true);
assertTrue("Node.restore('1.2') must not remove child node.", versionableNode.hasNode("child1"));
versionManager.restore(version, true);
assertFalse("Node.restore('1.0') must remove child node.", versionableNode.hasNode("child1"));
try {
versionManager.restore(v2, true);
} catch (RepositoryException e) {
fail("Node.restore('1.3') must fail.");
}
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class RestoreTest method testRestoreChild1Jcr2_3.
public void testRestoreChild1Jcr2_3() throws RepositoryException {
versionableNode.addNode("child1");
versionableNode.getSession().save();
Version v1 = versionManager.checkin(versionableNode.getPath());
versionManager.checkout(versionableNode.getPath());
Version v2 = versionManager.checkin(versionableNode.getPath());
versionManager.restore(versionableNode.getPath(), v1.getName(), true);
assertTrue("Node.restore('1.2') must not remove child node.", versionableNode.hasNode("child1"));
versionManager.restore(versionableNode.getPath(), version.getName(), true);
assertFalse("Node.restore('1.0') must remove child node.", versionableNode.hasNode("child1"));
try {
versionManager.restore(versionableNode.getPath(), v2.getName(), true);
} catch (RepositoryException e) {
fail("Node.restore('1.3') must fail.");
}
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class RestoreTest method testRestoreWithInvalidVersion.
/**
* Test if restoring a node with an invalid Version throws a VersionException
*
* @throws RepositoryException
*/
@SuppressWarnings("deprecation")
public void testRestoreWithInvalidVersion() throws RepositoryException {
Version invalidVersion = versionableNode2.checkin();
try {
versionableNode.restore(invalidVersion, true);
fail("Node.restore(Version, boolean): A VersionException must be thrown if the specified version does not exists in this node's version history.");
} catch (VersionException e) {
// success
}
}
Aggregations