/** * Asynchronously shutdown the deployed {@link Repository} instance with the given the name, and return a future that will * return whether the Repository instance is shutdown. If the Repository is not running, the resulting future will return * immediately. * <p> * Note that the caller does not have to wait for the shutdown to completed. However, to do so the caller merely calls * {@link Future#get() get()} or {@link Future#get(long, TimeUnit) get(long,TimeUnit)} on the future to return a boolean flag * specifying whether the Repository instance is shutdown (not running). Note that any exceptions thrown during the shutdown * will be wrapped in an {@link ExecutionException} thrown by the Future's <code>get</code> methods. * </p> * * @param repositoryName the name of the deployed repository * @return a future wrapping the asynchronous shutdown process; never null, and {@link Future#get()} will return whether the * @throws IllegalArgumentException if the repository name is null, blank or invalid * @throws NoSuchRepositoryException if there is no repository with the specified name * @throws IllegalStateException if this engine is not {@link #getState() running} * @see #deploy(RepositoryConfiguration) * @see #undeploy(String) */ public final Future<Boolean> shutdownRepository( String repositoryName ) throws NoSuchRepositoryException { return getRepository(repositoryName).shutdown(); }
/** * Asynchronously shutdown the deployed {@link Repository} instance with the given the name, and return a future that will * return whether the Repository instance is shutdown. If the Repository is not running, the resulting future will return * immediately. * <p> * Note that the caller does not have to wait for the shutdown to completed. However, to do so the caller merely calls * {@link Future#get() get()} or {@link Future#get(long, TimeUnit) get(long,TimeUnit)} on the future to return a boolean flag * specifying whether the Repository instance is shutdown (not running). Note that any exceptions thrown during the shutdown * will be wrapped in an {@link ExecutionException} thrown by the Future's <code>get</code> methods. * </p> * * @param repositoryName the name of the deployed repository * @return a future wrapping the asynchronous shutdown process; never null, and {@link Future#get()} will return whether the * @throws IllegalArgumentException if the repository name is null, blank or invalid * @throws NoSuchRepositoryException if there is no repository with the specified name * @throws IllegalStateException if this engine is not {@link #getState() running} * @see #deploy(RepositoryConfiguration) * @see #undeploy(String) */ public final Future<Boolean> shutdownRepository( String repositoryName ) throws NoSuchRepositoryException { return getRepository(repositoryName).shutdown(); }
@After public void afterEach() throws Exception { try { repository.shutdown().get(3L, TimeUnit.SECONDS); } finally { repository = null; config = null; } }
@After public void afterEach() throws Exception { try { repository.shutdown().get(3L, TimeUnit.SECONDS); } finally { repository = null; config = null; } }
if (repository != null) { repoNames.add(repository.getName()); repoFutures.add(repository.shutdown());
if (repository != null) { repoNames.add(repository.getName()); repoFutures.add(repository.shutdown());
return repository.shutdown(); } finally { lock.unlock();
return repository.shutdown(); } finally { lock.unlock();
@Test public void shouldFindConfigFileInFileSystem() throws Exception { URL configFileUrl = getClass().getResource("/tck/default/repo-config.json"); assertThat(configFileUrl, is(notNullValue())); File file = new File(configFileUrl.toURI()); configFile = new StringRefAddr("configFile", file.getAbsolutePath()); reference.add(configFile); reference.add(repositoryName); JcrRepository repo = (JcrRepository)factory.getObjectInstance(reference, null, null, null); try { assertThat(repo, is(notNullValue())); assertThat(repo.getName(), is(JCR_REPOSITORY_NAME)); } finally { if (repo != null) repo.shutdown(); } }
@Test public void shouldFindConfigFileOnClasspath() throws Exception { configFile = new StringRefAddr("configFile", "tck/default/repo-config.json"); reference.add(configFile); reference.add(repositoryName); JcrRepository repo = (JcrRepository)factory.getObjectInstance(reference, null, null, null); try { assertThat(repo, is(notNullValue())); assertThat(repo.getName(), is(JCR_REPOSITORY_NAME)); } finally { repo.shutdown(); } }
@Test public void shouldReturnSameRepository() throws Exception { configFile = new StringRefAddr("configFile", "tck/default/repo-config.json"); reference.add(configFile); reference.add(repositoryName); JcrRepository repo1 = null; JcrRepository repo2 = null; try { repo1 = (JcrRepository)factory.getObjectInstance(reference, null, null, null); repo2 = (JcrRepository)factory.getObjectInstance(reference, null, null, null); assertThat(repo1 == repo2, is(true)); } finally { try { if (repo1 != null) repo1.shutdown(); } finally { if (repo2 != null) repo2.shutdown(); } } }
@FixFor( "MODE-2033" ) @Test public void shouldStartAndReturnStartupProblems() throws Exception { shutdownDefaultRepository(); repository = TestingUtil.startRepositoryWithConfig("config/repo-config-with-startup-problems.json"); Problems problems = repository.getStartupProblems(); assertEquals("Expected 2 startup errors: " + problems.toString(), 2, problems.errorCount()); repository.shutdown().get(); problems = repository.getStartupProblems(); assertEquals("Invalid startup problems:" + problems.toString(), 2, problems.size()); }
@Test @FixFor("MODE-2679") public void shouldStartRepositoryUpForTurkishLocale() throws Exception { Locale current = Locale.getDefault(); try { Locale.setDefault(Locale.forLanguageTag("tr")); shutdownDefaultRepository(); repository = TestingUtil.startRepositoryWithConfig("config/repo-config-query-placeholder.json"); session = repository.login(); session.getRootNode().addNode("Ii"); session.save(); assertNotNull(session.getNode("/Ii")); assertTrue(repository.shutdown().get()); } finally { Locale.setDefault(current); } }
/** * Subclasses can call this method at the beginning of each test to shutdown any currently-running repository and to start up * a new repository with the given repository configuration * * @param configuration the repository configuration object; may not be null can be used in place of double quote, making it * easier for to specify a JSON content as a Java string) * @throws Exception if there was a problem starting the repository * @see #startRepositoryWithConfiguration(String) * @see #startRepositoryWithConfiguration(Document) * @see #startRepositoryWithConfiguration(InputStream) * @see #startRepositoryAutomatically */ protected void startRepositoryWithConfiguration( RepositoryConfiguration configuration ) throws Exception { // always use the test environment to provide some persistence defaults... configuration = configuration.with(new TestingEnvironment()); assertThat(configuration, is(notNullValue())); if (repository != null) { try { repository.shutdown().get(10, TimeUnit.SECONDS); } finally { repository = null; } } repository = new JcrRepository(configuration); repository.start(); session = repository.login(); }
@Test public void shouldAllowShuttingDownAndRestarting() throws Exception { JcrSession session1 = repository.login(); JcrSession session2 = repository.login(); assertThat(session1.isLive(), is(true)); assertThat(session2.isLive(), is(true)); session2.logout(); assertThat(session1.isLive(), is(true)); assertThat(session2.isLive(), is(false)); repository.shutdown().get(3L, TimeUnit.SECONDS); assertThat(session1.isLive(), is(false)); assertThat(session2.isLive(), is(false)); repository.start(); JcrSession session3 = repository.login(); assertThat(session1.isLive(), is(false)); assertThat(session2.isLive(), is(false)); assertThat(session3.isLive(), is(true)); session3.logout(); }
assertEquals(expectedJournalKeys, new TreeSet<NodeKey>(lastRecord.changedNodes())); repository.shutdown();
repository2.shutdown().get(5, TimeUnit.SECONDS));
@Test @FixFor( "MODE-2440" ) public void shouldRestoreBinaryReferencesWhenExcludedFromBackup() throws Exception { loadBinaryContent(); verifyBinaryContent(); // Make the backup, and check that there are no problems ... BackupOptions backupOptions = new BackupOptions() { @Override public boolean includeBinaries() { return false; } }; Problems problems = session().getWorkspace().getRepositoryManager().backupRepository(backupDirectory, backupOptions); assertNoProblems(problems); // shutdown the repo and remove just the repo main store (not the binary store) assertTrue(repository().shutdown().get()); FileUtil.delete(backupRepoDir.getPath() + "/store"); // start a fresh empty repo and then restore just the data without binaries startRepositoryWithConfigurationFrom("config/backup-repo-config.json"); RestoreOptions restoreOptions = new RestoreOptions() { @Override public boolean includeBinaries() { return false; } }; problems = session().getWorkspace().getRepositoryManager().restoreRepository(backupDirectory, restoreOptions); assertNoProblems(problems); verifyBinaryContent(); }
@Test @FixFor( "MODE-2056" ) public void shouldReturnActiveSessions() throws Exception { shutdownDefaultRepository(); RepositoryConfiguration config = new RepositoryConfiguration("repoName", new TestingEnvironment()); repository = new JcrRepository(config); assertEquals(0, repository.getActiveSessionsCount()); repository.start(); JcrSession session1 = repository.login(); JcrSession session2 = repository.login(); assertEquals(2, repository.getActiveSessionsCount()); session2.logout(); assertEquals(1, repository.getActiveSessionsCount()); session1.logout(); assertEquals(0, repository.getActiveSessionsCount()); repository.login(); repository.shutdown().get(); assertEquals(0, repository.getActiveSessionsCount()); }
queryContentInWorkspace(newRepository, null); } finally { newRepository.shutdown().get(10, TimeUnit.SECONDS);