use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class CheckoutTest method setUp.
protected void setUp() throws Exception {
super.setUp();
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
if (!versionManager.isCheckedOut(path)) {
fail("A versionable node must be checked-out after persistent creation.");
}
if (!versionableNode.isCheckedOut()) {
fail("A versionable node must be checked-out after persistent creation.");
}
versionManager.checkin(path);
}
use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class CopyTest method testCopy.
public void testCopy() throws RepositoryException {
Workspace wsp = superuser.getWorkspace();
VersionManager vMgr = wsp.getVersionManager();
String srcPath = versionableNode.getPath();
String dstPath = getProperty("destination");
wsp.copy(srcPath, dstPath);
// check versionable
Node v = superuser.getNode(dstPath);
assertTrue("Copied Node.isNodeType(mix:cersionable) must return true.", v.isNodeType(mixVersionable));
// check different version history
VersionHistory vh1 = vMgr.getVersionHistory(srcPath);
VersionHistory vh2 = vMgr.getVersionHistory(dstPath);
assertFalse("Copied node needs a new version history.", vh1.isSame(vh2));
// check if 1 version
assertEquals("Copied node must have 1 version.", 1, getNumberOfVersions(vh2));
// check if jcr:copiedFrom is set correctly
assertTrue("Version history of desination must have a jcr:copiedFrom property", vh2.hasProperty(jcrCopiedFrom));
Node ref = vh2.getProperty(jcrCopiedFrom).getNode();
Version base = vMgr.getBaseVersion(srcPath);
assertTrue("jcr:copiedFrom must point to the base version of the original.", ref.isSame(base));
}
use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class FrozenNodeTest method testFrozenNodeNodeType.
/**
* @throws RepositoryException
*/
public void testFrozenNodeNodeType() throws RepositoryException {
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
Version v = versionManager.checkin(path);
Node n = v.getFrozenNode();
String puuid = n.getProperty(jcrPrimaryType).getValue().getString();
String nuuid = n.getPrimaryNodeType().getName();
assertEquals("jcr:primaryType needs to be equal to the getPrimaryNodeType() return value.", nuuid, puuid);
}
use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class FrozenNodeTest method testFrozenChildNodeType.
/**
* @throws RepositoryException
*/
public void testFrozenChildNodeType() throws RepositoryException {
Node n1 = versionableNode.addNode("child");
versionableNode.getSession().save();
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
Version v = versionManager.checkin(path);
Node n = v.getFrozenNode().getNode("child");
String fuuid = n.getProperty("jcr:frozenPrimaryType").getValue().getString();
String ruuid = n1.getPrimaryNodeType().getName();
assertEquals("jcr:frozenPrimaryType needs to be equal to the getPrimaryNodeType() return value.", ruuid, fuuid);
}
use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class VersionLabelTest method testMoveLabelJcr2.
/**
* Test if the 'moveLabel' flag moves an existing version label.
*
* @throws RepositoryException
* @see VersionHistory#addVersionLabel(String, String, boolean) with boolan flag equals true.
*/
public void testMoveLabelJcr2() throws RepositoryException {
vHistory.addVersionLabel(version.getName(), versionLabel, false);
try {
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
versionManager.checkout(path);
Version v = versionManager.checkin(path);
vHistory.addVersionLabel(v.getName(), versionLabel, true);
if (!vHistory.hasVersionLabel(v, versionLabel)) {
fail("If 'moveLabel' is true, an existing version label must be moved to the indicated version.");
}
} catch (VersionException e) {
fail("If 'moveLabel' is true, an existing version label must be moved to the indicated version.");
}
}
Aggregations