JcrRepository implements org.modeshape.jcr.api.Repository { @Override public synchronized JcrSession login() throws RepositoryException { return login(null, null); } 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 );  }
@Test public void shouldAllowCreationOfSessionForDefaultWorkspaceWithoutUsingCredentials() throws Exception { JcrSession session1 = repository.login(); assertThat(session1.isLive(), is(true)); }
@Test( expected = NoSuchWorkspaceException.class ) public void shouldNotAllowCreatingSessionForNonExistantWorkspace() throws Exception { repository.login("non-existant-workspace"); }
@Test public void shouldAllowCreatingNewWorkspacesByDefault() throws Exception { try { repository.login("new-workspace"); } catch (NoSuchWorkspaceException e) { } JcrSession session1 = repository.login(); assertThat(session1.getRootNode(), is(notNullValue())); session1.getWorkspace().createWorkspace("new-workspace"); JcrSession session2 = repository.login("new-workspace"); assertThat(session2.getRootNode(), is(notNullValue())); }
@Test public void shouldAllowDestroyingWorkspacesByDefault() throws Exception { try { repository.login("new-workspace"); } catch (NoSuchWorkspaceException e) { } JcrSession session1 = repository.login(); assertThat(session1.getRootNode(), is(notNullValue())); session1.getWorkspace().createWorkspace("new-workspace"); JcrSession session2 = repository.login("new-workspace"); assertThat(session2.getRootNode(), is(notNullValue())); }