/** * Tests if <code>Version.getProperty(String)</code> returns the right * property */ public void testGetProperty() throws Exception { assertTrue("Version.getProperty(String) does not return property jcr:created", version.getProperty(jcrCreated).getName().equals(jcrCreated)); }
/** * Test if the nodes jcr:predecessors property is copied to the new version * on checkin. * * @throws RepositoryException */ public void testPredecessorIsCopiedToNewVersionJcr2() throws RepositoryException { Value[] nPredecessorsValue = versionableNode.getProperty(jcrPredecessors).getValues(); VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager(); String path = versionableNode.getPath(); Version v = versionManager.checkin(path); Value[] vPredecessorsValue = v.getProperty(jcrPredecessors).getValues(); assertEquals("The versionable checked-out node's jcr:predecessors property is copied to the new version on checkin.", Arrays.asList(nPredecessorsValue), Arrays.asList(vPredecessorsValue)); }
/** * Test if the nodes jcr:predecessors property is copied to the new version * on Node.checkin(). * * @throws RepositoryException */ @SuppressWarnings("deprecation") public void testPredecessorIsCopiedToNewVersion() throws RepositoryException { Value[] nPredecessorsValue = versionableNode.getProperty(jcrPredecessors).getValues(); Version v = versionableNode.checkin(); Value[] vPredecessorsValue = v.getProperty(jcrPredecessors).getValues(); assertEquals("The versionable checked-out node's jcr:predecessors property is copied to the new version on checkin.", Arrays.asList(nPredecessorsValue), Arrays.asList(vPredecessorsValue)); }
public JcrVersion(Version version) throws RepositoryException { // storing node's properties into variables to reduce 'throws' for // getters Node frozen = version.getNode(JcrNT.FROZEN_NODE); initVersion(frozen); lastModified = version.getProperty("jcr:created").getDate().getTime(); }
public JcrVersion(Version version) throws RepositoryException { // storing node's properties into variables to reduce 'throws' for // getters Node frozen = version.getNode(JcrNT.FROZEN_NODE); initVersion(frozen); lastModified = version.getProperty("jcr:created").getDate().getTime(); }
/** * Tests if <code>Version.getUUID()</code> returns the right UUID */ public void testGetUUID() throws Exception { List<Value> successorValues = Arrays.asList(versionableNode.getVersionHistory().getRootVersion().getProperty(jcrSuccessors).getValues()); assertTrue("Version.getUUID() did not return the right UUID", successorValues.contains(superuser.getValueFactory().createValue(version))); }
/** * 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); }
public void testShouldCreateProperHistoryForVersionableChildOfNodeWithVersionSemantics() throws Exception { session = getHelper().getReadWriteSession(); Node node = getTestRoot(session).addNode("checkInTest", "modetest:versionTest"); session.save(); /* * Create /checkinTest/versionNode/copyNode with versionNode and copyNode being versionable. This should * create a child of type nt:childVersionedNode under the frozen node. */ Node versionNode = node.addNode("versionNode", "modetest:versionTest"); versionNode.addMixin("mix:versionable"); Node copyNode = versionNode.addNode("copyNode", "modetest:versionTest"); copyNode.addMixin("mix:versionable"); copyNode.setProperty("ignoreProp", "ignorePropValue"); copyNode.setProperty("copyProp", "copyPropValue"); session.save(); Version version = checkin(versionNode); assertThat(version.getProperty("jcr:frozenNode/copyNode/jcr:primaryType").getString(), is("nt:frozenNode")); assertThat(version.getProperty("jcr:frozenNode/copyNode/jcr:frozenPrimaryType").getString(), is("modetest:versionTest")); try { version.getProperty("jcr:frozenNode/copyNode/copyProp"); } catch (PathNotFoundException pnfe) { fail("Property should be copied to versionable child of versioned node, because copyNode was copied (see Section 3.13.9 Item 5 of JSR-283)"); } try { version.getProperty("jcr:frozenNode/copyNode/ignoreProp"); } catch (PathNotFoundException pnfe) { fail("Ignored property should be copied to versionable child of versioned node when in a COPY subgraph"); } }
Version version2 = checkin(versionNode); assertThat(version.getProperty("jcr:frozenNode/versionNode/jcr:primaryType").getString(), is("nt:versionedChild")); assertThat(version.getProperty("jcr:frozenNode/copyNode/abortNode/copyProp").getString(), is("copyPropValue")); try { version.getProperty("jcr:frozenNode/abortNode/ignoreProp"); fail("Property with OnParentVersionAction of IGNORE should not have been copied"); } catch (PathNotFoundException pnfe) { assertThat(version2.getProperty("jcr:frozenNode/jcr:primaryType").getString(), is("nt:frozenNode")); assertThat(version2.getProperty("jcr:frozenNode/jcr:frozenPrimaryType").getString(), is("modetest:versionTest")); assertThat(version2.getProperty("jcr:frozenNode/jcr:frozenUuid").getString(), is(versionNode.getIdentifier()));
Calendar nodeCreated = version.getProperty("jcr:created").getDate(); if (!node.hasProperty(HippoNodeType.HIPPO_PATHS)) { throw new ItemNotFoundException("No hippo:paths property present");
@SuppressWarnings( "deprecation" ) @Test @FixFor( "MODE-1775" ) public void shouldFindVersionNodeByIdentifierAndByUuid() throws Exception { registerNodeTypes(session, "cnd/versioning.cnd"); // Set up parent node and check it in ... Node parent = session.getRootNode().addNode("versionableNode", "ver:versionable"); parent.setProperty("versionProp", "v"); parent.setProperty("copyProp", "c"); parent.setProperty("ignoreProp", "i"); session.save(); Version version = versionManager.checkin(parent.getPath()); // Now look for the version node by identifier, using the different ways to get an identifier ... assertThat(session.getNodeByIdentifier(version.getIdentifier()), is((Node)version)); assertThat(session.getNodeByIdentifier(version.getProperty("jcr:uuid").getString()), is((Node)version)); assertThat(session.getNodeByUUID(version.getProperty("jcr:uuid").getString()), is((Node)version)); }
assertThat(version.getProperty("jcr:frozenNode/copyProp").getString(), is("copyPropValue")); assertThat(version.getProperty("jcr:frozenNode/versionProp").getString(), is("versionPropValue")); version.getProperty("jcr:frozenNode/ignoreProp"); fail("Frozen version should not record a property that has an OnParentVersionAction of IGNORE"); } catch (PathNotFoundException pnfe) { assertThat(version.getProperty("jcr:frozenNode/copyProp").getString(), is("copyPropValue")); assertThat(version.getProperty("jcr:frozenNode/versionProp").getString(), is("versionPropValue")); version.getProperty("ignoreProp"); fail("Frozen version should not record a property that has an OnParentVersionAction of IGNORE"); } catch (PathNotFoundException pnfe) {
@Test public void checkVersionCreatedBeforeRestore() throws Exception { // GIVEN versionManager.addVersion(node); // change test node before restore node.setProperty("mgnl:template", "section"); node.getNode("areaSubNode").remove(); node.getSession().save(); assertEquals(2, versionManager.getAllVersions(node).getSize()); MockRestoreVersionAction restoreVersionAction = new MockRestoreVersionAction(definition, null, null, uiContext, formDialogPresenter, new JcrNodeAdapter(node), i18n, versionManager, eventBus, versionConfig, contentConnector); restoreVersionAction.execute(); // WHEN restoreVersionAction.getEditorCallback().onSuccess(""); // THEN assertEquals(3, versionManager.getAllVersions(node).getSize()); Version version = versionManager.getVersion(node, "1.1"); assertEquals(CREATED_VERSION_BEFORE_RESTORE, NodeTypes.Versionable.getComment(version)); assertEquals("section", version.getProperty("mgnl:template").getString()); assertFalse(version.hasNode("areaSubNode")); }