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