Search in sources :

Example 21 with JadConfig

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

the class MongoDbConfigurationTest method validateSucceedsIfUriIsMissing.

@Test
public void validateSucceedsIfUriIsMissing() throws RepositoryException, ValidationException {
    MongoDbConfiguration configuration = new MongoDbConfiguration();
    new JadConfig(new InMemoryRepository(Collections.emptyMap()), configuration).process();
    assertEquals("mongodb://localhost/graylog", configuration.getUri());
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) Test(org.junit.Test)

Example 22 with JadConfig

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

the class MongoDbConfigurationTest method validateFailsIfUriIsInvalid.

@Test(expected = ValidationException.class)
public void validateFailsIfUriIsInvalid() throws RepositoryException, ValidationException {
    MongoDbConfiguration configuration = new MongoDbConfiguration();
    new JadConfig(new InMemoryRepository(singletonMap("mongodb_uri", "Boom")), configuration).process();
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) Test(org.junit.Test)

Example 23 with JadConfig

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

the class EsNodeProviderTest method zenUnicastHostsAreTrimmed.

@Test
public void zenUnicastHostsAreTrimmed() throws IOException, ValidationException, RepositoryException {
    Map<String, String> settings = ImmutableMap.of("password_secret", "thisisatest", "retention_strategy", "delete", "root_password_sha2", "thisisatest", "elasticsearch_discovery_zen_ping_unicast_hosts", " example.com,   example.net ");
    final ElasticsearchConfiguration config = new ElasticsearchConfiguration();
    new JadConfig(new InMemoryRepository(settings), config).process();
    final Settings nodeSettings = EsNodeProvider.readNodeSettings(config, nodeId);
    assertThat(nodeSettings.getAsArray("discovery.zen.ping.unicast.hosts")).contains("example.com", "example.net");
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) ElasticsearchConfiguration(org.graylog2.configuration.ElasticsearchConfiguration) Settings(org.elasticsearch.common.settings.Settings) Test(org.junit.Test)

Example 24 with JadConfig

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

the class EsNodeProviderTest method setupConfig.

private ElasticsearchConfiguration setupConfig(Map<String, String> settings) {
    // required params we don't care about in this test, so we set them to dummy values for all test cases
    settings.put("retention_strategy", "delete");
    ElasticsearchConfiguration configuration = new ElasticsearchConfiguration();
    try {
        new JadConfig(new InMemoryRepository(settings), configuration).process();
    } catch (ValidationException | RepositoryException e) {
        fail(e.getMessage());
    }
    return configuration;
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) ValidationException(com.github.joschi.jadconfig.ValidationException) ElasticsearchConfiguration(org.graylog2.configuration.ElasticsearchConfiguration) RepositoryException(com.github.joschi.jadconfig.RepositoryException)

Example 25 with JadConfig

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

the class ConfigurationTest method testWebListenUriIsAbsoluteURI.

@Test
public void testWebListenUriIsAbsoluteURI() throws RepositoryException, ValidationException {
    validProperties.put("web_listen_uri", "http://www.example.com:12900/web");
    Configuration configuration = new Configuration();
    new JadConfig(new InMemoryRepository(validProperties), configuration).process();
    assertThat(configuration.getWebListenUri()).isEqualTo(URI.create("http://www.example.com:12900/web/"));
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) Test(org.junit.Test)

Aggregations

JadConfig (com.github.joschi.jadconfig.JadConfig)66 InMemoryRepository (com.github.joschi.jadconfig.repositories.InMemoryRepository)65 Test (org.junit.Test)64 File (java.io.File)19 ElasticsearchConfiguration (org.graylog2.configuration.ElasticsearchConfiguration)3 Settings (org.elasticsearch.common.settings.Settings)2 RepositoryException (com.github.joschi.jadconfig.RepositoryException)1 ValidationException (com.github.joschi.jadconfig.ValidationException)1 HashMap (java.util.HashMap)1 PluginLoaderConfig (org.graylog2.plugin.PluginLoaderConfig)1