use of javax.jcr.version.Version in project jackrabbit by apache.
the class RestoreTest method testRestoreChild1Jcr2.
public void testRestoreChild1Jcr2() 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 LabelTest method testMoveLabel2.
public void testMoveLabel2() throws RepositoryException {
vHistory.addVersionLabel(version.getName(), versionLabel, false);
versionableNode.checkout();
Version v = versionableNode.checkin();
vHistory.addVersionLabel(v.getName(), versionLabel, true);
List<String> labels = Arrays.asList(vHistory.getVersionLabels(v));
assertTrue(labels.contains(versionLabel));
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class LabelTest method testMoveLabel3.
public void testMoveLabel3() throws RepositoryException {
versionableNode.checkout();
Version v = versionableNode.checkin();
vHistory.addVersionLabel(version.getName(), versionLabel, false);
vHistory.addVersionLabel(v.getName(), versionLabel, true);
List<String> labels = Arrays.asList(vHistory.getVersionLabels(version));
assertFalse(labels.contains(versionLabel));
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class LabelTest method testMoveLabel4.
public void testMoveLabel4() throws RepositoryException {
versionableNode.checkout();
Version v = versionableNode.checkin();
vHistory.addVersionLabel(version.getName(), versionLabel, false);
vHistory.addVersionLabel(v.getName(), versionLabel, true);
Version v2 = vHistory.getVersionByLabel(versionLabel);
assertTrue(v2.isSame(v));
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class BackwardsCompatibilityIT method assertVersionable.
@SuppressWarnings("deprecation")
private Node assertVersionable(Node test) throws RepositoryException {
assertTrue(test.hasNode("versionable"));
Node versionable = test.getNode("versionable");
assertTrue(versionable.isNodeType("nt:myversionable"));
assertTrue(versionable.isNodeType("nt:unstructured"));
assertTrue(versionable.isNodeType("mix:versionable"));
assertFalse(versionable.isCheckedOut());
VersionHistory history = versionable.getVersionHistory();
Version versionB = versionable.getBaseVersion();
String[] labels = history.getVersionLabels(versionB);
assertEquals(1, labels.length);
assertEquals("labelB", labels[0]);
Version versionA = history.getVersionByLabel("labelA");
versionable.restore(versionA, true);
assertEquals("A", versionable.getProperty("foo").getString());
versionable.restore(versionB, true);
assertEquals("B", versionable.getProperty("foo").getString());
return versionable;
}
Aggregations