docs/modules/databases/cassandra.md
This example connects to the Cassandra cluster:
Define a container:
<!--codeinclude-->Container definition inside_block:container-definition
<!--/codeinclude-->Build a CqlSession:
Building CqlSession inside_block:cql-session
<!--/codeinclude-->Define a container with custom cassandra.yaml located in a directory cassandra-auth-required-configuration:
Running init script with required authentication inside_block:init-with-auth
<!--/codeinclude-->If you override the default cassandra.yaml with a version setting the property client_encryption_options.optional
to false, you have to provide a valid client certificate and key (PEM format) when you initialize your container:
SSL setup inside_block:with-ssl-config
<!--/codeinclude-->!!! hint To generate the client certificate and key, please refer to this documentation.
Add the following dependency to your pom.xml/build.gradle file:
=== "Gradle"
groovy testImplementation "org.testcontainers:testcontainers-cassandra:{{latest_version}}"
=== "Maven"
xml <dependency> <groupId>org.testcontainers</groupId> <artifactId>testcontainers-cassandra</artifactId> <version>{{latest_version}}</version> <scope>test</scope> </dependency>