Skip to content

Commit

Permalink
Fix deprecation of o.t.containers.CassandraContainer + `KafkaContai…
Browse files Browse the repository at this point in the history
…ner`

... in favor of `org.testcontainers.cassandra.CassandraContainer` and `org.testcontainers.kafka.KafkaContainer`. It seems that has been introduced by the testcontainers bump in #9675.
  • Loading branch information
snazy committed Oct 1, 2024
1 parent b444b12 commit 9c076e2
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
import org.projectnessie.model.ImmutableCommitMeta;
import org.projectnessie.model.Reference;
import org.projectnessie.nessie.testing.containerspec.ContainerSpecHelper;
import org.testcontainers.containers.KafkaContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.kafka.KafkaContainer;

@TestInstance(Lifecycle.PER_CLASS)
abstract class AbstractKafkaEventSubscriberTests {
Expand All @@ -77,7 +77,8 @@ abstract class AbstractKafkaEventSubscriberTests {
.name("kafka")
.containerClass(ITKafkaAvroEventSubscriber.class)
.build()
.dockerImageName(null))
.dockerImageName(null)
.asCompatibleSubstituteFor("apache/kafka"))
.withNetwork(NETWORK)
.withNetworkAliases("broker");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package org.projectnessie.versioned.storage.cassandratests;

import static java.lang.String.format;
import static org.testcontainers.containers.CassandraContainer.CQL_PORT;

import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.metadata.Metadata;
Expand All @@ -32,7 +31,7 @@
import org.projectnessie.versioned.storage.testextension.BackendTestFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.CassandraContainer;
import org.testcontainers.cassandra.CassandraContainer;
import org.testcontainers.containers.ContainerLaunchException;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.utility.DockerImageName;
Expand All @@ -42,11 +41,12 @@ public abstract class AbstractCassandraBackendTestFactory implements BackendTest
private static final Logger LOGGER =
LoggerFactory.getLogger(AbstractCassandraBackendTestFactory.class);
public static final String KEYSPACE_FOR_TEST = "nessie";
public static final Integer CQL_PORT = 9042;

private final String dbName;
private final List<String> args;

private CassandraContainer<?> container;
private CassandraContainer container;
private InetSocketAddress hostAndPort;
private String localDc;

Expand Down Expand Up @@ -116,8 +116,8 @@ public void start(Optional<String> containerNetworkId) {
.asCompatibleSubstituteFor("cassandra");

for (int retry = 0; ; retry++) {
CassandraContainer<?> c =
new CassandraContainer<>(dockerImageName)
CassandraContainer c =
new CassandraContainer(dockerImageName)
.withLogConsumer(new Slf4jLogConsumer(LOGGER))
.withCommand(args.toArray(new String[0]));
configureContainer(c);
Expand Down Expand Up @@ -160,7 +160,7 @@ public String getLocalDc() {
return localDc;
}

protected abstract void configureContainer(CassandraContainer<?> c);
protected abstract void configureContainer(CassandraContainer c);

@Override
public void start() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import static java.util.Collections.emptyList;

import org.projectnessie.versioned.storage.cassandra.CassandraBackendFactory;
import org.testcontainers.containers.CassandraContainer;
import org.testcontainers.cassandra.CassandraContainer;

public class CassandraBackendTestFactory extends AbstractCassandraBackendTestFactory {

Expand All @@ -37,7 +37,7 @@ public String getName() {
}

@Override
protected void configureContainer(CassandraContainer<?> c) {
protected void configureContainer(CassandraContainer c) {
c.withEnv("JVM_OPTS", JVM_OPTS_TEST);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import static java.lang.String.format;
import static java.util.Arrays.asList;

import org.testcontainers.containers.CassandraContainer;
import org.testcontainers.cassandra.CassandraContainer;

public class ScyllaDBBackendTestFactory extends AbstractCassandraBackendTestFactory {

Expand All @@ -47,5 +47,5 @@ public String getName() {
}

@Override
protected void configureContainer(CassandraContainer<?> c) {}
protected void configureContainer(CassandraContainer c) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package org.projectnessie.versioned.storage.cassandra2tests;

import static java.lang.String.format;
import static org.testcontainers.containers.CassandraContainer.CQL_PORT;

import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.metadata.Metadata;
Expand All @@ -32,7 +31,7 @@
import org.projectnessie.versioned.storage.testextension.BackendTestFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.CassandraContainer;
import org.testcontainers.cassandra.CassandraContainer;
import org.testcontainers.containers.ContainerLaunchException;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.utility.DockerImageName;
Expand All @@ -42,11 +41,12 @@ public abstract class AbstractCassandraBackendTestFactory implements BackendTest
private static final Logger LOGGER =
LoggerFactory.getLogger(AbstractCassandraBackendTestFactory.class);
public static final String KEYSPACE_FOR_TEST = "nessie";
public static final Integer CQL_PORT = 9042;

private final String dbName;
private final List<String> args;

private CassandraContainer<?> container;
private CassandraContainer container;
private InetSocketAddress hostAndPort;
private String localDc;

Expand Down Expand Up @@ -117,8 +117,8 @@ public void start(Optional<String> containerNetworkId) {
.asCompatibleSubstituteFor("cassandra");

for (int retry = 0; ; retry++) {
CassandraContainer<?> c =
new CassandraContainer<>(dockerImageName)
CassandraContainer c =
new CassandraContainer(dockerImageName)
.withLogConsumer(new Slf4jLogConsumer(LOGGER))
.withCommand(args.toArray(new String[0]));
configureContainer(c);
Expand Down Expand Up @@ -161,7 +161,7 @@ public String getLocalDc() {
return localDc;
}

protected abstract void configureContainer(CassandraContainer<?> c);
protected abstract void configureContainer(CassandraContainer c);

@Override
public void start() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import static java.util.Collections.emptyList;

import org.projectnessie.versioned.storage.cassandra2.Cassandra2BackendFactory;
import org.testcontainers.containers.CassandraContainer;
import org.testcontainers.cassandra.CassandraContainer;

public class CassandraBackendTestFactory extends AbstractCassandraBackendTestFactory {

Expand All @@ -37,7 +37,7 @@ public String getName() {
}

@Override
protected void configureContainer(CassandraContainer<?> c) {
protected void configureContainer(CassandraContainer c) {
c.withEnv("JVM_OPTS", JVM_OPTS_TEST);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import static java.lang.String.format;
import static java.util.Arrays.asList;

import org.testcontainers.containers.CassandraContainer;
import org.testcontainers.cassandra.CassandraContainer;

public class ScyllaDBBackendTestFactory extends AbstractCassandraBackendTestFactory {

Expand All @@ -47,5 +47,5 @@ public String getName() {
}

@Override
protected void configureContainer(CassandraContainer<?> c) {}
protected void configureContainer(CassandraContainer c) {}
}

0 comments on commit 9c076e2

Please sign in to comment.