Search in sources :

Example 81 with InMemoryRepository

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

the class ElasticsearchConfigurationTest method throwValidationExceptionIfHomePathParentIsNotReadable.

@Test(expected = ValidationException.class)
public void throwValidationExceptionIfHomePathParentIsNotReadable() throws Exception {
    final File parent = temporaryFolder.newFolder("elasticsearch");
    final File path = new File(parent, "home");
    assumeTrue(path.mkdir());
    assumeTrue(parent.setReadable(false));
    final ElasticsearchConfiguration configuration = new ElasticsearchConfiguration() {

        @Override
        public String getPathHome() {
            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 82 with InMemoryRepository

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

the class ElasticsearchConfigurationTest method testGetPathData.

@Test
public void testGetPathData() throws ValidationException, RepositoryException {
    final ElasticsearchConfiguration configuration = new ElasticsearchConfiguration();
    new JadConfig(new InMemoryRepository(), configuration).process();
    assertEquals(configuration.getPathData(), "data/elasticsearch");
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) Test(org.junit.Test)

Example 83 with InMemoryRepository

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

the class ElasticsearchConfigurationTest method testIsClientNode.

@Test
public void testIsClientNode() throws ValidationException, RepositoryException {
    final Map<String, String> props = new HashMap<>();
    final ElasticsearchConfiguration configuration1 = new ElasticsearchConfiguration();
    new JadConfig(new InMemoryRepository(), configuration1).process();
    assertTrue(configuration1.isClientNode());
    final ElasticsearchConfiguration configuration2 = new ElasticsearchConfiguration();
    props.put("elasticsearch_node_data", "false");
    new JadConfig(new InMemoryRepository(props), configuration2).process();
    assertTrue(configuration2.isClientNode());
    final ElasticsearchConfiguration configuration3 = new ElasticsearchConfiguration();
    props.put("elasticsearch_node_data", "true");
    new JadConfig(new InMemoryRepository(props), configuration3).process();
    assertFalse(configuration3.isClientNode());
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 84 with InMemoryRepository

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

the class ElasticsearchConfigurationTest method throwValidationExceptionIfDataPathParentIsNotReadable.

@Test(expected = ValidationException.class)
public void throwValidationExceptionIfDataPathParentIsNotReadable() throws Exception {
    final File parent = temporaryFolder.newFolder("elasticsearch");
    final File path = new File(parent, "data");
    assumeTrue(path.mkdir());
    assumeTrue(parent.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 85 with InMemoryRepository

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

the class ElasticsearchConfigurationTest method throwValidationExceptionIfDataPathIsNotADirectory.

@Test(expected = ValidationException.class)
public void throwValidationExceptionIfDataPathIsNotADirectory() throws Exception {
    final File path = temporaryFolder.newFile("elasticsearch-data");
    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)

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