Search in sources :

Example 16 with ClassPathResource

use of com.github.nosan.embedded.cassandra.commons.ClassPathResource in project embedded-cassandra by nosan.

the class DefaultCassandraDatabaseFactoryTests method setConfigFileFile.

@Test
void setConfigFileFile(@TempDir Path workingDirectory) throws Exception {
    ClassPathResource resource = new ClassPathResource("cassandra-4.0.3.yaml");
    this.systemProperties.put("cassandra.config", new File(resource.toURI()));
    CassandraDatabase database = create(Version.parse("4.0.1"), workingDirectory);
    Map<String, String> systemProperties = database.getSystemProperties();
    Map<String, String> environmentVariables = database.getEnvironmentVariables();
    try (InputStream inputStream = resource.getInputStream()) {
        assertThat(new Yaml().loadAs(inputStream, Map.class)).containsAllEntriesOf(database.getConfigProperties());
    }
    try (InputStream inputStream = Files.newInputStream(database.getConfigurationFile())) {
        assertThat(new Yaml().loadAs(inputStream, Map.class)).containsAllEntriesOf(database.getConfigProperties());
    }
    assertThat(systemProperties.get("cassandra.config")).isEqualTo(database.getConfigurationFile().toUri().toString());
    assertThat(environmentVariables.get("JVM_EXTRA_OPTS")).contains("-Dcassandra.config=" + database.getConfigurationFile().toUri());
}
Also used : InputStream(java.io.InputStream) File(java.io.File) ClassPathResource(com.github.nosan.embedded.cassandra.commons.ClassPathResource) Yaml(org.yaml.snakeyaml.Yaml) Test(org.junit.jupiter.api.Test)

Example 17 with ClassPathResource

use of com.github.nosan.embedded.cassandra.commons.ClassPathResource in project embedded-cassandra by nosan.

the class DefaultCassandraDatabaseFactoryTests method setConfigFilePath.

@Test
void setConfigFilePath(@TempDir Path workingDirectory) throws Exception {
    ClassPathResource resource = new ClassPathResource("cassandra-4.0.3.yaml");
    this.systemProperties.put("cassandra.config", Paths.get(resource.toURI()));
    CassandraDatabase database = create(Version.parse("4.0.1"), workingDirectory);
    Map<String, String> systemProperties = database.getSystemProperties();
    Map<String, String> environmentVariables = database.getEnvironmentVariables();
    try (InputStream inputStream = resource.getInputStream()) {
        assertThat(new Yaml().loadAs(inputStream, Map.class)).containsAllEntriesOf(database.getConfigProperties());
    }
    try (InputStream inputStream = Files.newInputStream(database.getConfigurationFile())) {
        assertThat(new Yaml().loadAs(inputStream, Map.class)).containsAllEntriesOf(database.getConfigProperties());
    }
    assertThat(systemProperties.get("cassandra.config")).isEqualTo(database.getConfigurationFile().toUri().toString());
    assertThat(environmentVariables.get("JVM_EXTRA_OPTS")).contains("-Dcassandra.config=" + database.getConfigurationFile().toUri());
}
Also used : InputStream(java.io.InputStream) ClassPathResource(com.github.nosan.embedded.cassandra.commons.ClassPathResource) Yaml(org.yaml.snakeyaml.Yaml) Test(org.junit.jupiter.api.Test)

Example 18 with ClassPathResource

use of com.github.nosan.embedded.cassandra.commons.ClassPathResource in project embedded-cassandra by nosan.

the class DefaultCassandraDatabaseFactoryTests method setConfigFileUrl.

@Test
void setConfigFileUrl(@TempDir Path workingDirectory) throws Exception {
    ClassPathResource resource = new ClassPathResource("cassandra-4.0.3.yaml");
    this.systemProperties.put("cassandra.config", resource.toURL());
    CassandraDatabase database = create(Version.parse("4.0.1"), workingDirectory);
    Map<String, String> systemProperties = database.getSystemProperties();
    Map<String, String> environmentVariables = database.getEnvironmentVariables();
    try (InputStream inputStream = resource.getInputStream()) {
        assertThat(new Yaml().loadAs(inputStream, Map.class)).containsAllEntriesOf(database.getConfigProperties());
    }
    try (InputStream inputStream = Files.newInputStream(database.getConfigurationFile())) {
        assertThat(new Yaml().loadAs(inputStream, Map.class)).containsAllEntriesOf(database.getConfigProperties());
    }
    assertThat(systemProperties.get("cassandra.config")).isEqualTo(database.getConfigurationFile().toUri().toString());
    assertThat(environmentVariables.get("JVM_EXTRA_OPTS")).contains("-Dcassandra.config=" + database.getConfigurationFile().toUri());
}
Also used : InputStream(java.io.InputStream) ClassPathResource(com.github.nosan.embedded.cassandra.commons.ClassPathResource) Yaml(org.yaml.snakeyaml.Yaml) Test(org.junit.jupiter.api.Test)

Example 19 with ClassPathResource

use of com.github.nosan.embedded.cassandra.commons.ClassPathResource in project embedded-cassandra by nosan.

the class DefaultCassandraDatabaseFactoryTests method setConfigFileResource.

@Test
void setConfigFileResource(@TempDir Path workingDirectory) throws Exception {
    ClassPathResource resource = new ClassPathResource("cassandra-4.0.3.yaml");
    this.systemProperties.put("cassandra.config", resource);
    CassandraDatabase database = create(Version.parse("4.0.1"), workingDirectory);
    Map<String, String> systemProperties = database.getSystemProperties();
    Map<String, String> environmentVariables = database.getEnvironmentVariables();
    try (InputStream inputStream = resource.getInputStream()) {
        assertThat(new Yaml().loadAs(inputStream, Map.class)).containsAllEntriesOf(database.getConfigProperties());
    }
    try (InputStream inputStream = Files.newInputStream(database.getConfigurationFile())) {
        assertThat(new Yaml().loadAs(inputStream, Map.class)).containsAllEntriesOf(database.getConfigProperties());
    }
    assertThat(systemProperties.get("cassandra.config")).isEqualTo(database.getConfigurationFile().toUri().toString());
    assertThat(environmentVariables.get("JVM_EXTRA_OPTS")).contains("-Dcassandra.config=" + database.getConfigurationFile().toUri());
}
Also used : InputStream(java.io.InputStream) ClassPathResource(com.github.nosan.embedded.cassandra.commons.ClassPathResource) Yaml(org.yaml.snakeyaml.Yaml) Test(org.junit.jupiter.api.Test)

Example 20 with ClassPathResource

use of com.github.nosan.embedded.cassandra.commons.ClassPathResource in project embedded-cassandra by nosan.

the class DefaultCassandraDatabaseFactoryTests method prepareWorkingDirectory.

@BeforeEach
void prepareWorkingDirectory(@TempDir Path workingDirectory) throws IOException {
    Files.createDirectories(workingDirectory.resolve("bin"));
    Files.createDirectories(workingDirectory.resolve("conf"));
    try (InputStream is = new ClassPathResource("cassandra-4.0.3.yaml").getInputStream()) {
        Files.copy(is, workingDirectory.resolve("conf/cassandra.yaml"));
    }
}
Also used : InputStream(java.io.InputStream) ClassPathResource(com.github.nosan.embedded.cassandra.commons.ClassPathResource) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ClassPathResource (com.github.nosan.embedded.cassandra.commons.ClassPathResource)24 Test (org.junit.jupiter.api.Test)17 InputStream (java.io.InputStream)9 Yaml (org.yaml.snakeyaml.Yaml)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 MethodSource (org.junit.jupiter.params.provider.MethodSource)4 LinkedHashMap (java.util.LinkedHashMap)3 CassandraBuilder (com.github.nosan.embedded.cassandra.CassandraBuilder)1 JdkHttpClient (com.github.nosan.embedded.cassandra.commons.web.JdkHttpClient)1 File (java.io.File)1 InetSocketAddress (java.net.InetSocketAddress)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1