Search in sources :

Example 11 with ClassPathResource

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

the class WorkingDirectoryCustomizerTests method copy.

@Test
void copy(@TempDir Path directory) throws IOException {
    ClassPathResource resource = new ClassPathResource("schema.cql");
    WorkingDirectoryCustomizer.addResource(resource, "conf/schema.cql").customize(directory, CassandraBuilder.DEFAULT_VERSION);
    WorkingDirectoryCustomizer.addResource(resource, "schema.cql").customize(directory, CassandraBuilder.DEFAULT_VERSION);
    WorkingDirectoryCustomizer.addResource(resource, "bin/tools/schema.cql").customize(directory, CassandraBuilder.DEFAULT_VERSION);
    try (InputStream inputStream = resource.getInputStream()) {
        byte[] expected = StreamUtils.toByteArray(inputStream);
        assertThat(directory.resolve("conf/schema.cql")).hasBinaryContent(expected);
        assertThat(directory.resolve("schema.cql")).hasBinaryContent(expected);
        assertThat(directory.resolve("bin/tools/schema.cql")).hasBinaryContent(expected);
    }
}
Also used : InputStream(java.io.InputStream) ClassPathResource(com.github.nosan.embedded.cassandra.commons.ClassPathResource) Test(org.junit.jupiter.api.Test)

Example 12 with ClassPathResource

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

the class CqlDataSetTests method ofResources.

@Test
void ofResources() {
    CqlDataSet dataSet = CqlDataSet.ofResources(new ClassPathResource("schema.cql"));
    assertStatements(dataSet);
    assertThat(dataSet.getScripts()).hasSize(1);
}
Also used : ClassPathResource(com.github.nosan.embedded.cassandra.commons.ClassPathResource) Test(org.junit.jupiter.api.Test)

Example 13 with ClassPathResource

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

the class CqlScriptTests method ofResource.

@Test
void ofResource() {
    CqlScript script = CqlScript.ofResource(new ClassPathResource("schema.cql"));
    assertThat(script.getStatements()).containsExactly("CREATE KEYSPACE test WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }");
}
Also used : ClassPathResource(com.github.nosan.embedded.cassandra.commons.ClassPathResource) Test(org.junit.jupiter.api.Test)

Example 14 with ClassPathResource

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

the class ResourceCqlScriptTests method testGetStatementsFail.

@Test
void testGetStatementsFail() {
    ClassPathResource resource = new ClassPathResource(UUID.randomUUID().toString());
    assertThatThrownBy(() -> new ResourceCqlScript(resource).getStatements()).hasStackTraceContaining("Could not open a stream for");
}
Also used : ClassPathResource(com.github.nosan.embedded.cassandra.commons.ClassPathResource) Test(org.junit.jupiter.api.Test)

Example 15 with ClassPathResource

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

the class CassandraExamples method clientEncryptionOptions.

private void clientEncryptionOptions() {
    // tag::client-encryption-options[]
    ClassPathResource keystore = new ClassPathResource("server.keystore");
    ClassPathResource truststore = new ClassPathResource("server.truststore");
    new CassandraBuilder().addWorkingDirectoryResource(keystore, "conf/server.keystore").addWorkingDirectoryResource(truststore, "conf/server.truststore").addConfigProperty("client_encryption_options.enabled", true).addConfigProperty("client_encryption_options.require_client_auth", true).addConfigProperty("client_encryption_options.optional", false).addConfigProperty("client_encryption_options.keystore", "conf/server.keystore").addConfigProperty("client_encryption_options.truststore", "conf/server.truststore").addConfigProperty("client_encryption_options.keystore_password", "123456").addConfigProperty("client_encryption_options.truststore_password", "123456").addConfigProperty("native_transport_port_ssl", 9142).build();
// end::client-encryption-options[]
}
Also used : CassandraBuilder(com.github.nosan.embedded.cassandra.CassandraBuilder) ClassPathResource(com.github.nosan.embedded.cassandra.commons.ClassPathResource)

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