@Test /** * Name of a versioned node is available in the parent history. Translator takes care of this when * hippo:paths is present on the node, with the parent as one of its values. */ public void testVersionedNode() throws Exception { Node parent = session.getRootNode().addNode("test", "nt:unstructured"); parent.addMixin("mix:versionable"); Node child = parent.addNode("child", "nt:unstructured"); child.addMixin("mix:versionable"); child.setProperty("hippo:paths", new String[] {child.getUUID(), parent.getUUID()}); session.save(); child.checkin(); parent.checkin(); VersionHistory vh = child.getVersionHistory(); parent.checkout(); child.remove(); session.save(); parent.checkin(); VersionIterator versionIter = vh.getAllVersions(); versionIter.nextVersion(); // ignore root Version version = versionIter.nextVersion(); NodeTranslator nt = new NodeTranslator(new JcrNodeModel(version.getNode("jcr:frozenNode"))); assertEquals("child", nt.getNodeName().getObject()); assertTrue(version.getNode("jcr:frozenNode").isNodeType("mix:referenceable")); }
public void testVersionLabel() throws Exception { UserTransaction tx = new UserTransactionImpl(superuser); tx.begin(); Node n = testRootNode.addNode(nodeName1); n.addMixin(mixVersionable); testRootNode.save(); String v1 = n.checkin().getName(); n.checkout(); String v2 = n.checkin().getName(); n.getVersionHistory().addVersionLabel(v2, "label", false); tx.commit(); tx = new UserTransactionImpl(superuser); tx.begin(); n.restore(v1, false); n.getVersionHistory().removeVersion(v2); n.checkout(); v2 = n.checkin().getName(); n.getVersionHistory().addVersionLabel(v2, "label", false); tx.commit(); }
/** * Test for http://jira.exoplatform.org/browse/JCR-437 * * @throws Exception */ public void testRemoveNonMixVersionableParent() throws Exception { Node testroot = root.addNode("testRoot"); Node verionableChild = testroot.addNode("verionableChild"); verionableChild.addMixin("mix:versionable"); root.save(); assertFalse(testroot.isNodeType("mix:versionable")); assertTrue(verionableChild.isNodeType("mix:versionable")); VersionHistory vHistory = verionableChild.getVersionHistory(); assertNotNull(vHistory); String vhId = ((NodeImpl) vHistory).getUUID(); assertNotNull(session.getTransientNodesManager().getItemData(vhId)); testroot.remove(); root.save(); assertFalse(root.hasNode("testRoot")); ItemData vhdata = session.getTransientNodesManager().getItemData(vhId); // !!!! assertNull(vhdata); }