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());
}
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());
}
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());
}
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());
}
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"));
}
}
Aggregations