Cassandra Module

Usage example

This example connects to the Cassandra Cluster, creates a keyspaces and asserts that is has been created.

public class SomeTest {

    public CassandraContainer cassandra = new CassandraContainer();

    public void test(){
        Cluster cluster = cassandra.getCluster();

        try(Session session = cluster.connect()) {

            session.execute("CREATE KEYSPACE IF NOT EXISTS test WITH replication = \n" +

            List<KeyspaceMetadata> keyspaces = session.getCluster().getMetadata().getKeyspaces();
            List<KeyspaceMetadata> filteredKeyspaces = keyspaces
                    .filter(km -> km.getName().equals("test"))

            assertEquals(1, filteredKeyspaces.size());


Adding this module to your project dependencies

Add the following dependency to your pom.xml/build.gradle file:

testImplementation "org.testcontainers:cassandra:1.15.3"