JcrRepository implements org.modeshape.jcr.api.Repository { @Override public String getName() { return repositoryName.get(); } protected  JcrRepository( RepositoryConfiguration configuration ); State getState(); @Override String getName(); @Override int getActiveSessionsCount(); RepositoryStatistics getRepositoryStatistics(); Problems getStartupProblems(); Transactions transactions(); RepositoryConfiguration getConfiguration(); @Override String getDescriptor( String key ); @Override JcrValue getDescriptorValue( String key ); @Override JcrValue[] getDescriptorValues( String key ); @Override boolean isSingleValueDescriptor( String key ); @Override boolean isStandardDescriptor( String key ); @Override String[] getDescriptorKeys(); @Override synchronized JcrSession login(); @Override synchronized JcrSession login( Credentials credentials ); @Override synchronized JcrSession login( String workspaceName ); @Override synchronized JcrSession login( final Credentials credentials,
                                          String workspaceName );  }
@SuppressWarnings( "deprecation" ) @Test public void shouldHaveRootNode() throws Exception { session = createSession(); javax.jcr.Node root = session.getRootNode(); String uuid = root.getIdentifier(); assertThat(root.isNodeType("mix:referenceable"), is(true)); assertThat(root.getUUID(), is(uuid)); assertThat(root.getIdentifier(), is(uuid)); javax.jcr.NodeIterator iter = root.getNodes(); javax.jcr.Node system = iter.nextNode(); assertThat(system.getName(), is("jcr:system")); javax.jcr.Node childA = root.addNode("childA", "nt:unstructured"); assertThat(childA, is(notNullValue())); iter = root.getNodes(); javax.jcr.Node system2 = iter.nextNode(); javax.jcr.Node childA2 = iter.nextNode(); assertThat(system2.getName(), is("jcr:system")); assertThat(childA2.getName(), is("childA")); }
@FixFor( "MODE-1525" ) @Test public void shouldDiscoverCorrectChildNodeType() throws Exception { session = createSession(); InputStream cndStream = getClass().getResourceAsStream("/cnd/medical.cnd"); assertThat(cndStream, is(notNullValue())); session.getWorkspace().getNodeTypeManager().registerNodeTypes(cndStream, true); Node root = session.getRootNode(); Node person = root.addNode("jsmith", "inf:person"); person.setProperty("inf:firstName", "John"); person.setProperty("inf:lastName", "Smith"); session.save(); Node doctor = root.addNode("drBarnes", "inf:doctor"); doctor.setProperty("inf:firstName", "Sally"); doctor.setProperty("inf:lastName", "Barnes"); doctor.setProperty("inf:doctorProviderNumber", "12345678-AB"); session.save(); Node referral = root.addNode("referral", "nt:unstructured"); referral.addMixin("er:eReferral"); assertThat(referral.getMixinNodeTypes()[0].getName(), is("er:eReferral")); Node group = referral.addNode("er:gp"); assertThat(group.getPrimaryNodeType().getName(), is("inf:doctor")); assertThat(group.hasProperty("inf:firstName"), is(false)); assertThat(group.hasProperty("inf:lastName"), is(false)); session.save(); assertThat(group.getProperty("inf:firstName").getString(), is("defaultFirstName")); assertThat(group.getProperty("inf:lastName").getString(), is("defaultLastName")); Node docGroup = root.addNode("documentGroup", "inf:documentGroup"); assertThat(docGroup.getPrimaryNodeType().getName(), is("inf:documentGroup")); docGroup.addMixin("er:eReferral"); Node ergp = docGroup.addNode("er:gp"); assertThat(ergp.getPrimaryNodeType().getName(), is("inf:doctor")); assertThat(ergp.hasProperty("inf:firstName"), is(false)); assertThat(ergp.hasProperty("inf:lastName"), is(false)); session.save(); assertThat(ergp.getProperty("inf:firstName").getString(), is("defaultFirstName")); assertThat(ergp.getProperty("inf:lastName").getString(), is("defaultLastName")); }
@FixFor( "MODE-1525" ) @Test public void shouldDiscoverCorrectChildNodeTypeButFailOnMandatoryPropertiesWithNoDefaultValues() throws Exception { session = createSession(); InputStream cndStream = getClass().getResourceAsStream("/cnd/medical-invalid-mandatories.cnd"); assertThat(cndStream, is(notNullValue())); session.getWorkspace().getNodeTypeManager().registerNodeTypes(cndStream, true); Node root = session.getRootNode(); Node person = root.addNode("jsmith", "inf:person"); person.setProperty("inf:firstName", "John"); person.setProperty("inf:lastName", "Smith"); session.save(); Node doctor = root.addNode("drBarnes", "inf:doctor"); doctor.setProperty("inf:firstName", "Sally"); doctor.setProperty("inf:lastName", "Barnes"); doctor.setProperty("inf:doctorProviderNumber", "12345678-AB"); session.save(); Node referral = root.addNode("referral", "nt:unstructured"); referral.addMixin("er:eReferral"); assertThat(referral.getMixinNodeTypes()[0].getName(), is("er:eReferral")); Node group = referral.addNode("er:gp"); assertThat(group.getPrimaryNodeType().getName(), is("inf:doctor")); try { session.save(); fail("Expected a constraint violation exception"); } catch (ConstraintViolationException e) { } group.setProperty("inf:firstName", "Sally"); group.setProperty("inf:lastName", "Barnes"); session.save(); }