Skip to content

Commit 730f689

Browse files
Add test against Apache Cassandra 4 (#7013)
Fixes #7012 Co-authored-by: Eddú Meléndez Gonzales <eddu.melendez@gmail.com>
1 parent cce90eb commit 730f689

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

modules/cassandra/src/main/java/org/testcontainers/containers/CassandraContainer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/**
2222
* Cassandra container
2323
*
24-
* Supports 2.x and 3.x Cassandra versions
24+
* Testcontainers implementation for Apache Cassandra.
2525
*/
2626
public class CassandraContainer<SELF extends CassandraContainer<SELF>> extends GenericContainer<SELF> {
2727

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
}

0 commit comments

Comments
 (0)