use of javax.jcr.version.VersionManager in project jackrabbit-oak by apache.
the class ReferencesTest method testVersionReferencesVH.
public void testVersionReferencesVH() throws RepositoryException {
Node n = testRootNode.addNode(nodeName1, testNodeType);
n.addMixin(mixVersionable);
superuser.save();
String p = n.getPath();
VersionManager vMgr = superuser.getWorkspace().getVersionManager();
VersionHistory vh = vMgr.getVersionHistory(p);
// check if versionable node has references to root version
assertEquals("Version History", vh.getIdentifier(), n.getProperty(Property.JCR_VERSION_HISTORY).getString());
checkReferences("Version History", vh.getReferences(), p + "/jcr:versionHistory");
}
use of javax.jcr.version.VersionManager in project jackrabbit-oak by apache.
the class ReferencesTest method testVersionedReferences.
// OAK-1196 - Node.getReferences() should not show references in frozen nodes
public void testVersionedReferences() throws RepositoryException {
Node ref = testRootNode.addNode(nodeName2, testNodeType);
ref.addMixin(mixReferenceable);
superuser.save();
Node n = testRootNode.addNode(nodeName1, testNodeType);
n.addMixin(mixVersionable);
n.setProperty("myref", ref);
superuser.save();
String p = n.getPath();
VersionManager vMgr = superuser.getWorkspace().getVersionManager();
Version v1 = vMgr.checkpoint(p);
Node frozen = v1.getFrozenNode();
assertEquals("ref", ref.getPath(), frozen.getProperty("myref").getNode().getPath());
checkReferences("ref in version store", ref.getReferences(), n.getPath() + "/myref");
// also test what happens if node is removed
n.remove();
ref.remove();
superuser.save();
try {
frozen.getProperty("myref").getNode();
fail("removed reference should not be accessible");
} catch (ItemNotFoundException e) {
// ok
}
}
use of javax.jcr.version.VersionManager in project jackrabbit-oak by apache.
the class ReferencesTest method testVersionReferencesV0.
public void testVersionReferencesV0() throws RepositoryException {
Node n = testRootNode.addNode(nodeName1, testNodeType);
n.addMixin(mixVersionable);
superuser.save();
String p = n.getPath();
VersionManager vMgr = superuser.getWorkspace().getVersionManager();
Version v0 = vMgr.getVersionHistory(p).getRootVersion();
// check if versionable node has references to root version
assertEquals("Root Version", v0.getIdentifier(), n.getProperty(Property.JCR_BASE_VERSION).getString());
assertEquals("Root Version", v0.getIdentifier(), n.getProperty(Property.JCR_PREDECESSORS).getValues()[0].getString());
checkReferences("Root Version", v0.getReferences(), p + "/jcr:baseVersion", p + "/jcr:predecessors");
}
use of javax.jcr.version.VersionManager in project jackrabbit-oak by apache.
the class VersionTest method testFrozenNode.
public void testFrozenNode() throws RepositoryException {
Node n = testRootNode.addNode(nodeName1, testNodeType);
n.addMixin(mixVersionable);
Node child = n.addNode(nodeName2, ntUnstructured);
superuser.save();
VersionManager vMgr = superuser.getWorkspace().getVersionManager();
vMgr.checkpoint(n.getPath());
Version v = vMgr.getBaseVersion(n.getPath());
Node frozenChild = v.getFrozenNode().getNode(child.getName());
assertEquals(ntFrozenNode, frozenChild.getPrimaryNodeType().getName());
}
use of javax.jcr.version.VersionManager in project jackrabbit-oak by apache.
the class VersionTest method testVersionReferences.
// OAK-3130
public void testVersionReferences() throws RepositoryException {
Node n = testRootNode.addNode(nodeName1, testNodeType);
n.addMixin(mixVersionable);
superuser.save();
VersionManager vMgr = superuser.getWorkspace().getVersionManager();
Version v = vMgr.checkin(n.getPath());
Version rootVersion = v.getContainingHistory().getRootVersion();
Set<String> refs = getReferencingPaths(rootVersion);
// the rootVersion actually has referencing property
// from the version 'v' created by checkin() (jcr:predecessors
// points to the rootVersion), but for compatibility with
// Jackrabbit 2.x it is not returned by Node.getReferences()
assertEquals("references mismatch", emptySet(), refs);
refs = getReferencingPaths(v);
// Similar to above, the version is actually also referenced
// from the rootVersion's jcr:successors property, but for
// compatibility reasons it is not returned
Set<String> expected = ImmutableSet.of(concat(n.getPath(), jcrBaseVersion));
assertEquals("references mismatch", expected, refs);
}
Aggregations