File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
main/java/org/testcontainers/containers
test/java/org/testcontainers/containers Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 2121/**
2222 * Cassandra container
2323 *
24- * Supports 2.x and 3.x Cassandra versions
24+ * Testcontainers implementation for Apache Cassandra.
2525 */
2626public class CassandraContainer <SELF extends CassandraContainer <SELF >> extends GenericContainer <SELF > {
2727
Original file line number Diff line number Diff line change 1+ package org .testcontainers .containers ;
2+
3+ import com .datastax .oss .driver .api .core .CqlIdentifier ;
4+ import com .datastax .oss .driver .api .core .CqlSession ;
5+ import com .datastax .oss .driver .api .core .metadata .schema .KeyspaceMetadata ;
6+ import org .junit .Rule ;
7+ import org .junit .Test ;
8+
9+ import static org .assertj .core .api .Assertions .assertThat ;
10+
11+ public class CassandraServer4Test {
12+
13+ @ Rule
14+ public CassandraContainer <?> cassandra = new CassandraContainer <>("cassandra:4.1.1" );
15+
16+ @ Test
17+ public void testCassandraGetContactPoint () {
18+ try (
19+ CqlSession session = CqlSession
20+ .builder ()
21+ .addContactPoint (this .cassandra .getContactPoint ())
22+ .withLocalDatacenter (this .cassandra .getLocalDatacenter ())
23+ .build ()
24+ ) {
25+ session .execute (
26+ "CREATE KEYSPACE IF NOT EXISTS test WITH replication = \n " +
27+ "{'class':'SimpleStrategy','replication_factor':'1'};"
28+ );
29+
30+ KeyspaceMetadata keyspace = session .getMetadata ().getKeyspaces ().get (CqlIdentifier .fromCql ("test" ));
31+
32+ assertThat (keyspace ).as ("test keyspace created" ).isNotNull ();
33+ }
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments