Skip to content

Commit

Permalink
Add test against Apache Cassandra 4 (#7013)
Browse files Browse the repository at this point in the history
Fixes #7012


Co-authored-by: Eddú Meléndez Gonzales <[email protected]>
  • Loading branch information
wakingrufus and eddumelendez authored May 8, 2023
1 parent cce90eb commit 730f689
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* Cassandra container
*
* Supports 2.x and 3.x Cassandra versions
* Testcontainers implementation for Apache Cassandra.
*/
public class CassandraContainer<SELF extends CassandraContainer<SELF>> extends GenericContainer<SELF> {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.testcontainers.containers;

import com.datastax.oss.driver.api.core.CqlIdentifier;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata;
import org.junit.Rule;
import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class CassandraServer4Test {

@Rule
public CassandraContainer<?> cassandra = new CassandraContainer<>("cassandra:4.1.1");

@Test
public void testCassandraGetContactPoint() {
try (
CqlSession session = CqlSession
.builder()
.addContactPoint(this.cassandra.getContactPoint())
.withLocalDatacenter(this.cassandra.getLocalDatacenter())
.build()
) {
session.execute(
"CREATE KEYSPACE IF NOT EXISTS test WITH replication = \n" +
"{'class':'SimpleStrategy','replication_factor':'1'};"
);

KeyspaceMetadata keyspace = session.getMetadata().getKeyspaces().get(CqlIdentifier.fromCql("test"));

assertThat(keyspace).as("test keyspace created").isNotNull();
}
}
}

0 comments on commit 730f689

Please sign in to comment.