public static JcrRepository startClusteredRepositoryWithConfig(String configFile, String clusterNodeId) throws Exception { URL configUrl = TestingUtil.class.getClassLoader().getResource(configFile); Assert.assertNotNull(configFile + " not found", configFile); Properties properties = new Properties(); properties.put("clusterNode", clusterNodeId); Document configDoc = Json.read(configUrl).withVariablesReplaced(properties); JcrRepository repository = new JcrRepository(new RepositoryConfiguration(configDoc, configFile)); repository.start(); Thread.sleep(200); return repository; }
public static JcrRepository startRepositoryWithConfig( String configFile ) throws Exception { URL configUrl = TestingUtil.class.getClassLoader().getResource(configFile); RepositoryConfiguration config = RepositoryConfiguration.read(configUrl).with(new TestingEnvironment()); JcrRepository repository = null; repository = new JcrRepository(config); repository.start(); return repository; }
protected RepositoryConfiguration startRunStop(RepositoryOperation operation, RepositoryConfiguration config) { JcrRepository repository = null; try { repository = new JcrRepository(config); repository.start(); operation.execute(repository); return config; } catch (RuntimeException re) { throw re; } catch (Exception e) { throw new RuntimeException(e); } finally { if (repository != null) { TestingUtil.killRepository(repository); } } }
@Test(expected = RuntimeException.class) @FixFor( "MODE-2528" ) public void shouldNotStartRepositoryWithInvalidPersistence() throws Exception { shutdownDefaultRepository(); repository = TestingUtil.startRepositoryWithConfig("config/repo-config-invalid-persistence.json"); repository.start(); }
/** * Start the repository using the supplied repository configuration. Note that this does <i>not</i> create a session. * * @param doc the document containing the configuration; may not be null * @param repoName the name of the repository; may not be null * @throws Exception if there is a problem starting the repository */ protected void startRepositoryWith( Document doc, String repoName ) throws Exception { RepositoryConfiguration config = new RepositoryConfiguration(doc, repoName, new TestingEnvironment()); repository = new JcrRepository(config); repository.start(); }
protected JcrRepository repository( Map<?, ?> parameters, String repositoryURL ) throws RepositoryException { String repositoryName = repositoryNameFrom(repositoryURL, parameters); JcrRepository repository = lookForAlreadyDeployedRepositoryKey(repositoryURL); if (repository != null) { return repository; } RepositoryConfiguration configuration = loadRepositoryConfigurationFrom(repositoryURL); repository = lookForAlreadyDeployedRepositoryName(configuration.getName()); if (repository != null) { return StringUtil.isBlank(repositoryName) || configuration.getName().equalsIgnoreCase(repositoryName) ? repository : null; } // Now deploy the new repository ... try { repository = ENGINE.deploy(configuration); repository.start(); // The name might not match the configuration's name ... if (StringUtil.isBlank(repositoryName) || repository.getName().equals(repositoryName)) { return repository; } LOG.warn(JcrI18n.repositoryNotFound, repositoryName, repositoryURL, parameters); return null; } catch (RepositoryException re) { throw re; } catch (Exception e) { throw new RepositoryException(e); } }
protected JcrRepository repository( Map<?, ?> parameters, String repositoryURL ) throws RepositoryException { String repositoryName = repositoryNameFrom(repositoryURL, parameters); JcrRepository repository = lookForAlreadyDeployedRepositoryKey(repositoryURL); if (repository != null) { return repository; } RepositoryConfiguration configuration = loadRepositoryConfigurationFrom(repositoryURL); repository = lookForAlreadyDeployedRepositoryName(configuration.getName()); if (repository != null) { return StringUtil.isBlank(repositoryName) || configuration.getName().equalsIgnoreCase(repositoryName) ? repository : null; } // Now deploy the new repository ... try { repository = ENGINE.deploy(configuration); repository.start(); // The name might not match the configuration's name ... if (StringUtil.isBlank(repositoryName) || repository.getName().equals(repositoryName)) { return repository; } LOG.warn(JcrI18n.repositoryNotFound, repositoryName, repositoryURL, parameters); return null; } catch (RepositoryException re) { throw re; } catch (Exception e) { throw new RepositoryException(e); } }
protected void startRepository() throws Exception { RepositoryConfiguration repositoryConfiguration = createRepositoryConfiguration(REPO_NAME); repositoryConfiguration = repositoryConfiguration.with(new TestingEnvironment()); repository = new JcrRepository(repositoryConfiguration); repository.start(); session = repository.login(); }
@Test @FixFor( "MODE-2387" ) public void shouldStartRepositoryWithCustomSettingsForLocalIndexProvider() throws Exception { shutdownDefaultRepository(); FileUtil.delete("target/local_index_custom_settings_test_repository"); repository = TestingUtil.startRepositoryWithConfig("config/local-index-provider-with-custom-settings.json"); repository.start(); }
/** * 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(); }
protected final void completeRestore(RestoreOptions options) throws ExecutionException, Exception { if (getState() == State.RESTORING) { logger.debug("Shutting down '{0}' after content has been restored", getName()); doShutdown(false); logger.debug("Starting '{0}' after content has been restored", getName()); start(); logger.debug("Started '{0}' after content has been restored; beginning indexing of content", getName()); if (options.reindexContentOnFinish()) { // Reindex all content ... queryManager().cleanAndReindex(false); logger.debug("Completed reindexing all content in '{0}' after restore.", getName()); } } }
protected final void completeRestore(RestoreOptions options) throws ExecutionException, Exception { if (getState() == State.RESTORING) { logger.debug("Shutting down '{0}' after content has been restored", getName()); doShutdown(false); logger.debug("Starting '{0}' after content has been restored", getName()); start(); logger.debug("Started '{0}' after content has been restored; beginning indexing of content", getName()); if (options.reindexContentOnFinish()) { // Reindex all content ... queryManager().cleanAndReindex(false); logger.debug("Completed reindexing all content in '{0}' after restore.", getName()); } } }
@Before public void beforeEach() throws Exception { repository = new JcrRepository(new RepositoryConfiguration("repoName", new TestingEnvironment())); repository.start(); print = false; }
protected static void startRepository( RepositoryConfiguration configuration ) throws Exception { TestingEnvironment environment = new TestingEnvironment(); RepositoryConfiguration config = configuration != null ? new RepositoryConfiguration(configuration.getDocument(), configuration.getName(), environment) : new RepositoryConfiguration(REPO_NAME, environment); repository = new JcrRepository(config); repository.start(); session = repository.login(); }
@Override protected void startRepositoryWithConfiguration( Document doc ) throws Exception { stopRepository(); RepositoryConfiguration config = new RepositoryConfiguration(doc, REPO_NAME).with(new TestingEnvironment()); repository = new JcrRepository(config); repository.start(); session = repository.login(); rootNode = session.getRootNode(); addSequencingListeners(session); }
@Override protected void startRepositoryWithConfiguration( InputStream configInputStream ) throws Exception { stopRepository(); RepositoryConfiguration config = RepositoryConfiguration.read(configInputStream, REPO_NAME).with(new TestingEnvironment()); Problems problems = config.validate(); if (problems.hasProblems()) { System.out.println(problems); fail("Problems encountered during repository startup: " + problems); } repository = new JcrRepository(config); repository.start(); session = repository.login(); rootNode = session.getRootNode(); addSequencingListeners(session); }
@Before public void beforeEach() throws Exception { config = new RepositoryConfiguration("repoName").with(new TestingEnvironment()); repository = new JcrRepository(config); repository.start(); context = repository.runningState().context(); repoTypeManager = repository.nodeTypeManager(); session = repository.login(); }
@Before public void beforeEach() throws Exception { config = new RepositoryConfiguration("repoName").with(new TestingEnvironment()); repository = new JcrRepository(config); repository.start(); SessionCache systemCache = repository.createSystemSession(repository.runningState().context(), false); system = new SystemContent(systemCache); }
@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()); }