use of javax.jcr.version.Version in project jackrabbit by apache.
the class MergeDoneMergeTest method testMergeNodeDoneMergeJcr2.
/**
* VersionManager.doneMerge(V) throws VersionException if V is not among the Vs in the
* jcr:mergeFailed prop. <br> with adding it to jcr:predecessors.<br>
* Branches will be joined.<br>
*/
public void testMergeNodeDoneMergeJcr2() throws RepositoryException {
// create 2 independent versions for a node and its corresponding node
// so merge fails for this node
// default workspace
Node originalNode = testRootNode.getNode(nodeName1);
VersionManager vmWsp1 = originalNode.getSession().getWorkspace().getVersionManager();
String originalPath = originalNode.getPath();
vmWsp1.checkout(originalPath);
vmWsp1.checkin(originalPath);
// second workspace
VersionManager vmWsp2 = nodeToMerge.getSession().getWorkspace().getVersionManager();
String path = nodeToMerge.getPath();
vmWsp2.checkin(path);
// "merge" the clonedNode with the newNode from the default workspace
vmWsp2.checkout(path);
vmWsp2.merge(path, workspace.getName(), true);
// get predecessors
Version[] predecessors = nodeToMerge.getBaseVersion().getPredecessors();
// get mergeFailed property
Property mergeFailedProperty = nodeToMerge.getProperty(jcrMergeFailed);
Value[] mergeFailedReferences = mergeFailedProperty.getValues();
for (int i = 0; i < mergeFailedReferences.length; i++) {
String id = mergeFailedReferences[i].getString();
vmWsp2.doneMerge(path, (Version) superuser.getNodeByIdentifier(id));
}
// check mergeFailed property - reference moved to predecessor
if (nodeToMerge.hasProperty(jcrMergeFailed)) {
Property mergeFailedPropertyAfterCancelMerge = nodeToMerge.getProperty(jcrMergeFailed);
Value[] mergeFailedReferencesAfterCancelMerge = mergeFailedPropertyAfterCancelMerge.getValues();
assertTrue(mergeFailedReferences.length > mergeFailedReferencesAfterCancelMerge.length);
}
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class GetContainingHistoryTest method testGetContainingHistory.
/**
* Tests if {@link javax.jcr.version.Version#getContainingHistory()} returns
* the correct VersionHistory instance.
*/
public void testGetContainingHistory() throws RepositoryException {
// create version
versionableNode.checkout();
Version version = versionableNode.checkin();
assertTrue("Method getContainingHistory() must return the same VersionHistory " + "as getVersionHistory() of the corresponding Node.", versionableNode.getVersionHistory().isSame(version.getContainingHistory()));
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class FrozenNodeTest method testFrozenChildNodeUUUID.
/**
* @throws RepositoryException
*/
public void testFrozenChildNodeUUUID() throws RepositoryException {
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 puuid = n.getProperty(jcrUUID).getValue().getString();
String nuuid = n.getIdentifier();
assertEquals("jcr:uuid needs to be equal to the getIdentifier() return value.", nuuid, puuid);
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class GetCreatedTest method testGetCreatedCheckAgainstProperty.
/**
* Returns the date this version was created. This corresponds to the value
* of the jcr:created property in the nt:version node that represents this
* version.
*/
public void testGetCreatedCheckAgainstProperty() throws RepositoryException {
// create version
versionableNode.checkout();
Version version = versionableNode.checkin();
Calendar calGetCreated = version.getCreated();
Calendar calCreatedProp = version.getProperty(jcrCreated).getValue().getDate();
assertEquals("Method getCreated() should return value of the jcr:created property.", calGetCreated, calCreatedProp);
}
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);
}
Aggregations