### Question:
RepositoryService implements AdministeredService, Observer { public final ServiceAdministrator getAdministrator() { return this.administrator; } RepositoryService( RepositorySource configurationSource,
                              String configurationWorkspaceName,
                              Path pathToConfigurationRoot,
                              ExecutionContext context,
                              ObservationBus observationBus,
                              Problems problems ); final ServiceAdministrator getAdministrator(); final String getConfigurationSourceName(); final String getConfigurationWorkspaceName(); final RepositoryLibrary getRepositoryLibrary(); final ExecutionContext getExecutionEnvironment(); String getJndiName(); @Override boolean equals( Object obj ); void notify( Changes changes ); boolean requiresGarbageCollection(); void runGarbageCollection( Problems problems ); static final int MAXIMUM_NUMBER_OF_PASSES_PER_GC_RUN; }### Answer:
@Test public void shouldHaveServiceAdministratorAfterInstantiation() { assertThat(service.getAdministrator(), is(notNullValue())); }
@Test public void shouldAllowShuttingDownBeforeStartingUp() throws Exception { assertThat(service.getAdministrator().getState(), is(ServiceAdministrator.State.PAUSED)); service.getAdministrator().shutdown(); service.getAdministrator().awaitTermination(1, TimeUnit.SECONDS); assertThat(service.getAdministrator().getState(), is(ServiceAdministrator.State.TERMINATED)); }
@Test public void shouldStartUpUsingConfigurationRepositoryThatContainsNoSources() throws Exception { configRepository.create("/mode:sources").and(); service.getAdministrator().start(); verifyNoMoreInteractions(sources); }
@Test public void shouldStartUpAndCreateRepositoryUsingConfigurationRepositoryThatContainsNoSources() { configRepository.useWorkspace("default"); configRepository.create("/mode:sources").and(); configRepository.create("/mode:sources/source A").and(); final String className = InMemoryRepositorySource.class.getName(); configRepository.set(ModeShapeLexicon.CLASSNAME).on("/mode:sources/source A").to(className); configRepository.set(ModeShapeLexicon.CLASSPATH).on("/mode:sources/source A").to(""); configRepository.set("retryLimit").on("/mode:sources/source A").to(3); String fedReposPath = "/mode:repositories/fed repos/"; configRepository.create("/mode:repositories").and(); configRepository.create("/mode:repositories/fed repos").and(); configRepository.create("/mode:repositories/fed repos/mode:regions").and(); configRepository.create("/mode:repositories/fed repos/mode:regions/source A").and(); configRepository.create("/mode:repositories/fed repos/mode:regions/source B").and(); configRepository.create("/mode:repositories/fed repos/mode:regions/source C").and(); configRepository.create("/mode:repositories/fed repos/mode:regions/source D").and(); configRepository.set(ModeShapeLexicon.TIME_TO_EXPIRE).on(fedReposPath).to(20000); configRepository.set(ModeShapeLexicon.PROJECTION_RULES).on(fedReposPath + "mode:regions/source A").to("/a/b/c => /sx/sy"); configRepository.set(ModeShapeLexicon.PROJECTION_RULES).on(fedReposPath + "mode:regions/source B").to("/ => /"); configRepository.set(ModeShapeLexicon.PROJECTION_RULES).on(fedReposPath + "mode:regions/source C").to("/d/e/f => /"); configRepository.set(ModeShapeLexicon.PROJECTION_RULES).on(fedReposPath + "mode:regions/source D").to("/ => /x/y/z"); service.getAdministrator().start(); }