@Override public AbstractJcrNode addNode( String relPath, String primaryNodeTypeName ) throws ItemExistsException, PathNotFoundException, NoSuchNodeTypeException, LockException, VersionException, ConstraintViolationException, RepositoryException { checkSession(); return addNode(relPath, primaryNodeTypeName, null, false); }
protected AbstractJcrNode addAclNode( String relPath, String primaryNodeTypeName ) throws ItemExistsException, PathNotFoundException, NoSuchNodeTypeException, LockException, VersionException, ConstraintViolationException, RepositoryException { checkSession(); return addNode(relPath, primaryNodeTypeName, null, true); }
@Override public AbstractJcrNode addNode( String relPath ) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, RepositoryException { checkSession(); return addNode(relPath, null, null, false); }
@Override public AbstractJcrNode addNode( String relPath ) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, RepositoryException { checkSession(); return addNode(relPath, null, null, false); }
protected AbstractJcrNode addAclNode( String relPath, String primaryNodeTypeName ) throws ItemExistsException, PathNotFoundException, NoSuchNodeTypeException, LockException, VersionException, ConstraintViolationException, RepositoryException { checkSession(); return addNode(relPath, primaryNodeTypeName, null, true); }
@Override public AbstractJcrNode addNode( String relPath, String primaryNodeTypeName ) throws ItemExistsException, PathNotFoundException, NoSuchNodeTypeException, LockException, VersionException, ConstraintViolationException, RepositoryException { checkSession(); return addNode(relPath, primaryNodeTypeName, null, false); }
@Test public void shouldHaveNameThatExcludesSameNameSiblingIndex() throws Exception { assertThat(altima.getName(), is("Nissan Altima")); javax.jcr.Node altima2 = hybrid.addNode("Nissan Altima"); try { assertThat(altima2, is(notNullValue())); assertThat(altima2.getPath(), is("/Cars/Hybrid/Nissan Altima[2]")); assertThat(altima2.getName(), is("Nissan Altima")); } finally { altima2.remove(); // remove the node we added in this test to not interfere with other tests } }
@Test public void shouldHavePath() throws Exception { assertThat(altima.getPath(), is("/Cars/Hybrid/Nissan Altima")); javax.jcr.Node altima2 = hybrid.addNode("Nissan Altima"); try { assertThat(altima2, is(notNullValue())); assertThat(altima2.getPath(), is("/Cars/Hybrid/Nissan Altima[2]")); } finally { altima2.remove(); // remove the node we added in this test to not interfere with other tests } }
@Test public void shouldHaveSameNameSiblingIndex() throws Exception { assertThat(altima.getIndex(), is(1)); javax.jcr.Node altima2 = hybrid.addNode("Nissan Altima"); try { assertThat(altima2, is(notNullValue())); assertThat(altima2.getIndex(), is(2)); } finally { altima2.remove(); // remove the node we added in this test to not interfere with other tests } }
@Test( expected = ConstraintViolationException.class ) public void shouldNotAllowAdditionIfResidualChildNodeConflicts() throws Exception { session.getRootNode().addNode("a", "nt:unstructured").addNode(CHILD_NODE_B, "nt:base"); session.save(); Node rootNode = session.getRootNode(); Node nodeA = rootNode.getNode("a"); assertThat(nodeA.canAddMixin(MIXIN_TYPE_WITH_AUTO_CHILD), is(false)); nodeA.addMixin(MIXIN_TYPE_WITH_AUTO_CHILD); }
@Test @FixFor( "MODE-1940" ) public void shouldIndexMovedNodes() throws Exception { initializeData(); // create /w/q session.getNode("/").addNode("w").addNode("q"); session.save(); // move /a to /w/q session.getWorkspace().move("/a", "/w/x"); Thread.sleep(200); queryForAbsentLocalName("a"); queryForExistingLocaLName("x", "/w/x"); queryForExistingLocaLName("b", "/w/x/b"); queryForExistingLocaLName("c", "/w/x/b/c"); }
@Test public void shouldAllowAdditionIfResidualChildNodeDoesNotConflict() throws Exception { session.getRootNode().addNode("a", "nt:unstructured").addNode(CHILD_NODE_B, "nt:unstructured"); session.save(); Node rootNode = session.getRootNode(); Node nodeA = rootNode.getNode("a"); assertThat(nodeA.canAddMixin(MIXIN_TYPE_WITH_AUTO_CHILD), is(true)); nodeA.addMixin(MIXIN_TYPE_WITH_AUTO_CHILD); session.save(); Node newRootNode = session.getRootNode(); Node newNodeA = newRootNode.getNode("a"); Node newNodeB = newNodeA.getNode(CHILD_NODE_B); assertThat(newNodeA.isNodeType(MIXIN_TYPE_WITH_AUTO_CHILD), is(true)); assertThat(newNodeB.isNodeType("nt:unstructured"), is(true)); assertThat(newNodeB, is(notNullValue())); // Uncomment this to see the problem with the session cache not refreshing the immutable info for /a after a save // assertThat(newNodeB.getDefinition().getDeclaringNodeType().getName(), is(MIXIN_TYPE_B)); }
@Test @FixFor( "MODE-1807" ) public void shouldRegisterCNDFileWithResidualChildDefinition() throws Exception { session = createSession(); InputStream cndStream = getClass().getResourceAsStream("/cnd/orc.cnd"); assertThat(cndStream, is(notNullValue())); session.getWorkspace().getNodeTypeManager().registerNodeTypes(cndStream, true); session.getRootNode().addNode("patient", "orc:patient").addNode("patientcase", "orc:patientcase"); session.save(); assertNotNull(session.getNode("/patient/patientcase")); }
Node myCarrier = session.getNode("/NewArea").addNode("MyCarrier", CAR_CARRIER_TYPENAME);
@Test @FixFor( "MODE-1949") public void shouldNotAllowMixinRemovalIfPropertiesDefinedInParentMixinArePresent() throws Exception { Node folder = session.getNode("/").addNode("folder", "nt:folder"); //add the publishArea mixin which inherits from mix:title folder.addMixin("mode:publishArea"); folder.setProperty("jcr:title", "title"); folder.setProperty("jcr:description", "description"); session.save(); try { folder.removeMixin("mode:publishArea"); session.save(); fail("The mixin should not be removed because there are still properties defined from the parent mixin"); } catch (ConstraintViolationException e) { //expected } folder.setProperty("jcr:title", (Value)null); session.save(); try { folder.removeMixin("mode:publishArea"); session.save(); fail("The mixin should not be removed because there are still properties defined from the parent mixin"); } catch (ConstraintViolationException e) { //expected } folder.setProperty("jcr:description", (Value)null); session.save(); folder.removeMixin("mode:publishArea"); session.save(); }
@Test @FixFor( "MODE-2115" ) public void copiedNodesShouldReplaceReferenceableAutoCreatedChildren() throws Exception { tools.registerNodeTypes(session, "cnd/autocreated-child-nodes.cnd"); session.getRootNode().addNode("parent", "test:autocreatedReferenceableChildren"); session.save(); session.getNode("/parent/child1").addNode("child1_1"); session.save(); workspace.copy("/parent", "/new_parent"); AbstractJcrNode newParent = session.getNode("/new_parent"); assertEquals(2, newParent.getNodes().getSize()); // validate that the jcr:uuid is the same as the identifier of the node Node child1 = assertNode("/new_parent/child1", "test:subnodeReferenceable"); assertEquals(child1.getIdentifier(), child1.getProperty("jcr:uuid").getString()); Node child2 = assertNode("/new_parent/child2", "test:subnodeReferenceable"); assertEquals(child2.getIdentifier(), child2.getProperty("jcr:uuid").getString()); assertNode("/new_parent/child1/child1_1"); }
workspace.createWorkspace(wsName); JcrSession testWsSession = repository.login(wsName); testWsSession.getRootNode().addNode("testRoot").addNode("subNode"); assertNotNull(testWsSession.getNode("/jcr:system")); testWsSession.save();
public void importingMultipleTimeWithReplaceExistingShouldNotIncreaseReferencesCount() throws Exception { registerNodeTypes("cnd/ab-references.cnd"); session.getNode("/").addNode("testRoot"); session.save();