Search in sources :

Example 86 with InMemoryRepository

use of com.github.joschi.jadconfig.repositories.InMemoryRepository in project graylog2-server by Graylog2.

the class ElasticsearchConfigurationTest method throwValidationExceptionIfDataPathIsNotReadable.

@Test(expected = ValidationException.class)
public void throwValidationExceptionIfDataPathIsNotReadable() throws Exception {
    final File path = temporaryFolder.newFolder("elasticsearch-data");
    assumeTrue(path.setReadable(false));
    final ElasticsearchConfiguration configuration = new ElasticsearchConfiguration() {

        @Override
        public String getPathData() {
            return path.getAbsolutePath();
        }
    };
    new JadConfig(new InMemoryRepository(), configuration).process();
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) File(java.io.File) Test(org.junit.Test)

Example 87 with InMemoryRepository

use of com.github.joschi.jadconfig.repositories.InMemoryRepository in project graylog2-server by Graylog2.

the class ConfigurationTest method processValidProperties.

private Configuration processValidProperties() throws RepositoryException, ValidationException {
    Configuration configuration = new Configuration();
    new JadConfig(new InMemoryRepository(validProperties), configuration).process();
    return configuration;
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository)

Example 88 with InMemoryRepository

use of com.github.joschi.jadconfig.repositories.InMemoryRepository in project graylog2-server by Graylog2.

the class ConfigurationTest method leaderElectionTTLTimeoutTooShort.

@Test
public void leaderElectionTTLTimeoutTooShort() {
    validProperties.put("leader_election_mode", "automatic");
    validProperties.put("lock_service_lock_ttl", "3s");
    assertThatThrownBy(() -> {
        new JadConfig(new InMemoryRepository(validProperties), new Configuration()).process();
    }).isInstanceOf(ValidationException.class).hasMessageStartingWith("The minimum valid \"lock_service_lock_ttl\" is");
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) ValidationException(com.github.joschi.jadconfig.ValidationException) Test(org.junit.Test)

Example 89 with InMemoryRepository

use of com.github.joschi.jadconfig.repositories.InMemoryRepository in project graylog2-server by Graylog2.

the class PathConfigurationTest method testAllowedAuxiliaryPaths.

@Test
public void testAllowedAuxiliaryPaths() throws ValidationException, RepositoryException {
    validProperties.put("allowed_auxiliary_paths", "/permitted-dir,/another-valid-dir");
    PathConfiguration configuration = new PathConfiguration();
    final JadConfig jadConfig = new JadConfig(new InMemoryRepository(validProperties), configuration);
    jadConfig.process();
    assertEquals(2, configuration.getAllowedAuxiliaryPaths().size());
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) Test(org.junit.Test)

Example 90 with InMemoryRepository

use of com.github.joschi.jadconfig.repositories.InMemoryRepository in project graylog2-server by Graylog2.

the class PathConfigurationTest method testBaseConfiguration.

@Test
public void testBaseConfiguration() throws ValidationException, RepositoryException {
    PathConfiguration configuration = new PathConfiguration();
    final JadConfig jadConfig = new JadConfig(new InMemoryRepository(validProperties), configuration);
    jadConfig.process();
    assertEquals(BIN_PATH, configuration.getBinDir().toString());
    assertEquals(DATA_PATH, configuration.getDataDir().toString());
    assertEquals(PLUGINS_PATH, configuration.getPluginDir().toString());
    assertTrue(configuration.getAllowedAuxiliaryPaths().isEmpty());
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) Test(org.junit.Test)

Aggregations

InMemoryRepository (com.github.joschi.jadconfig.repositories.InMemoryRepository)117 Test (org.junit.Test)115 JadConfig (com.github.joschi.jadconfig.JadConfig)86 File (java.io.File)25 ValidationException (com.github.joschi.jadconfig.ValidationException)5 Ignore (org.junit.Ignore)4 ElasticsearchConfiguration (org.graylog2.configuration.ElasticsearchConfiguration)3 Settings (org.elasticsearch.common.settings.Settings)2 RepositoryException (com.github.joschi.jadconfig.RepositoryException)1 GuavaConverterFactory (com.github.joschi.jadconfig.guava.GuavaConverterFactory)1 HashMap (java.util.HashMap)1