Search in sources :

Example 56 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 57 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 58 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 59 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 60 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

JadConfig (com.github.joschi.jadconfig.JadConfig)65 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