Search in sources :

Example 21 with ClassPathResource

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

the class DefaultCassandraIntegrationTests method testSuccessWhenCustomCassandraYaml.

@ParameterizedTest
@MethodSource("versions")
void testSuccessWhenCustomCassandraYaml(Version version) throws Throwable {
    ClassPathResource configFile = new ClassPathResource(String.format("cassandra-random-%s.yaml", version));
    this.builder.version(version).addSystemProperty("cassandra.jmx.local.port", 0).configFile(configFile);
    this.runner.run((cassandra, throwable) -> {
        assertThat(throwable).doesNotThrowAnyException();
        assertThat(cassandra.getName()).isNotBlank();
        assertThat(cassandra.getWorkingDirectory()).isNotNull();
        assertThat(cassandra.getVersion()).isEqualTo(version);
        assertThat(cassandra.isRunning()).isTrue();
        Settings settings = cassandra.getSettings();
        SessionFactory sessionFactory = new SessionFactory();
        sessionFactory.address = settings.getAddress();
        sessionFactory.port = settings.getPort();
        createScheme(sessionFactory);
    });
}
Also used : ClassPathResource(com.github.nosan.embedded.cassandra.commons.ClassPathResource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 22 with ClassPathResource

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

the class DefaultCassandraIntegrationTests method testSuccessWhenSslServerEnabled.

@ParameterizedTest
@MethodSource("versions")
void testSuccessWhenSslServerEnabled(Version version) throws Throwable {
    Map<String, Object> serverEncryptionOptions = new LinkedHashMap<>();
    serverEncryptionOptions.put("internode_encryption", "all");
    serverEncryptionOptions.put("enable_legacy_ssl_storage_port", "true");
    serverEncryptionOptions.put("optional", false);
    serverEncryptionOptions.put("enabled", true);
    serverEncryptionOptions.put("require_client_auth", true);
    serverEncryptionOptions.put("keystore", new ClassPathResource("server.keystore"));
    serverEncryptionOptions.put("keystore_password", "123456");
    serverEncryptionOptions.put("truststore", new ClassPathResource("server.truststore"));
    serverEncryptionOptions.put("truststore_password", "123456");
    this.builder.version(version).addConfigProperty("server_encryption_options", serverEncryptionOptions);
    this.runner.run((cassandra, throwable) -> {
        assertThat(throwable).doesNotThrowAnyException();
        assertThat(cassandra.getName()).isNotBlank();
        assertThat(cassandra.getWorkingDirectory()).isNotNull();
        assertThat(cassandra.getVersion()).isEqualTo(version);
        assertThat(cassandra.isRunning()).isTrue();
        Settings settings = cassandra.getSettings();
        assertThat(settings.getSslPort()).isNull();
        SessionFactory sessionFactory = new SessionFactory();
        sessionFactory.address = settings.getAddress();
        sessionFactory.port = settings.getPort();
        createScheme(sessionFactory);
    });
}
Also used : ClassPathResource(com.github.nosan.embedded.cassandra.commons.ClassPathResource) LinkedHashMap(java.util.LinkedHashMap) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 23 with ClassPathResource

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

the class CassandraBuilderTests method systemProperties.

@Test
void systemProperties() {
    ClassPathResource resource = new ClassPathResource("test.txt");
    assertThat(this.builder.addSystemProperty("cassandra.rpc_port", 9160).build()).hasFieldOrPropertyWithValue("databaseFactory.systemProperties", mapOf("cassandra.rpc_port", 9160));
    assertThat(this.builder.addSystemProperties(mapOf("cassandra.config", resource)).build()).hasFieldOrPropertyWithValue("databaseFactory.systemProperties", mapOf("cassandra.rpc_port", 9160, "cassandra.config", resource));
    assertThat(this.builder.systemProperties(mapOf("cassandra.config", resource)).build()).hasFieldOrPropertyWithValue("databaseFactory.systemProperties", mapOf("cassandra.config", resource));
}
Also used : ClassPathResource(com.github.nosan.embedded.cassandra.commons.ClassPathResource) Test(org.junit.jupiter.api.Test)

Example 24 with ClassPathResource

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

the class CassandraBuilderTests method configurationFile.

@Test
void configurationFile() {
    ClassPathResource resource = new ClassPathResource("test.txt");
    assertThat(this.builder.configFile(resource).build()).hasFieldOrPropertyWithValue("databaseFactory.systemProperties", mapOf("cassandra.config", resource));
}
Also used : ClassPathResource(com.github.nosan.embedded.cassandra.commons.ClassPathResource) Test(org.junit.jupiter.api.Test)

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