/** * Create a copy of this configuration that uses the supplied environment. * * @param environment the environment that should be used for the repository; may be null * @return the new configuration; never null */ public RepositoryConfiguration with( Environment environment ) { return new RepositoryConfiguration(doc.clone(), docName, environment); }
/** * Create a copy of this configuration that uses the supplied document name. * * @param docName the new document name; may be null * @return the new configuration; never null */ public RepositoryConfiguration withName( String docName ) { return new RepositoryConfiguration(doc.clone(), docName, environment); }
/** * Create a copy of this configuration that uses the supplied environment. * * @param environment the environment that should be used for the repository; may be null * @return the new configuration; never null */ public RepositoryConfiguration with( Environment environment ) { return new RepositoryConfiguration(doc.clone(), docName, environment); }
/** * Create a copy of this configuration that uses the supplied document name. * * @param docName the new document name; may be null * @return the new configuration; never null */ public RepositoryConfiguration withName( String docName ) { return new RepositoryConfiguration(doc.clone(), docName, environment); }
/** * Resolve the supplied URL to a JSON document, read the contents, and parse into a {@link RepositoryConfiguration}. * * @param url the URL; may not be null * @return the parsed repository configuration; never null * @throws ParsingException if the content could not be parsed as a valid JSON document */ public static RepositoryConfiguration read( URL url ) throws ParsingException { CheckArg.isNotNull(url, "url"); Document doc = Json.read(url); return new RepositoryConfiguration(doc, withoutExtension(url.getFile())); }
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; }
@Before public void beforeEach() throws Exception { repository = new JcrRepository(new RepositoryConfiguration("repoName", new TestingEnvironment())); repository.start(); print = false; }
@Test public void shouldAlwaysReturnNonNullSecurityComponent() { RepositoryConfiguration config = new RepositoryConfiguration("repoName"); assertThat(config.getSecurity(), is(notNullValue())); }
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(); }
@Test public void shouldAlwaysReturnNonNullSequencingComponent() { RepositoryConfiguration config = new RepositoryConfiguration("repoName"); assertThat(config.getSequencing(), is(notNullValue())); }
@Test public void shouldNotConfigureJaasByDefault() { RepositoryConfiguration config = new RepositoryConfiguration("repoName"); Security security = config.getSecurity(); JaasSecurity jaas = security.getJaas(); assertThat(jaas, is(nullValue())); }
@FixFor( "MODE-2160" ) @Test public void shouldAlwaysReturnNonNullIndexesComponentForNoIndexes() { RepositoryConfiguration config = new RepositoryConfiguration("repoName"); assertThat(config.getIndexes(), is(notNullValue())); }
@Test public void shouldConfigureAnonymousByDefault() { RepositoryConfiguration config = new RepositoryConfiguration("repoName"); Security security = config.getSecurity(); AnonymousSecurity anon = security.getAnonymous(); assertThat(anon, is(notNullValue())); assertThat(anon.getAnonymousUsername(), is(RepositoryConfiguration.Default.ANONYMOUS_USERNAME)); assertThat(anon.getAnonymousRoles(), is(RepositoryConfiguration.Default.ANONYMOUS_ROLES)); }
@Test( expected = ConfigurationException.class ) public void shouldFailToDeployRepositoryConfigurationWithoutName() throws Throwable { config = new RepositoryConfiguration(); // without a name! assertThat(config.validate().hasErrors(), is(true)); engine.start(); engine.deploy(config); }
@FixFor( "MODE-1988" ) @Test public void shouldEnableDocumentOptimizationWithEmptyDocumentOptimizationField() { Document doc = Schematic.newDocument(FieldName.NAME, "repoName", FieldName.STORAGE, Schematic.newDocument(FieldName.DOCUMENT_OPTIMIZATION, Schematic.newDocument())); RepositoryConfiguration config = new RepositoryConfiguration(doc, "repoName"); DocumentOptimization opt = config.getDocumentOptimization(); assertThat(opt, is(notNullValue())); assertThat(opt.isEnabled(), is(false)); }
@FixFor( "MODE-1988" ) @Test public void shouldDisableDocumentOptimizationWithoutValidChildCountTargetValue() { Document docOpt = Schematic.newDocument(FieldName.OPTIMIZATION_CHILD_COUNT_TOLERANCE, 10); Document doc = Schematic.newDocument(FieldName.NAME, "repoName", FieldName.STORAGE, Schematic.newDocument(FieldName.DOCUMENT_OPTIMIZATION, docOpt)); RepositoryConfiguration config = new RepositoryConfiguration(doc, "repoName"); DocumentOptimization opt = config.getDocumentOptimization(); assertThat(opt, is(notNullValue())); assertThat(opt.isEnabled(), is(false)); }
@Test @FixFor( "MODE-2556" ) public void journalShouldBeDisabledIfConfigurationSectionIsMissing() { Document doc = Schematic.newDocument(FieldName.NAME, "repoName"); RepositoryConfiguration config = new RepositoryConfiguration(doc, "repoName"); assertFalse(config.getJournaling().isEnabled()); }
@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); }
@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); }
@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(); }