From 9c076e22b225cc6d48ebea223a8b5448cf488b52 Mon Sep 17 00:00:00 2001 From: Robert Stupp Date: Tue, 1 Oct 2024 22:55:35 +0200 Subject: [PATCH] Fix deprecation of `o.t.containers.CassandraContainer` + `KafkaContainer` ... in favor of `org.testcontainers.cassandra.CassandraContainer` and `org.testcontainers.kafka.KafkaContainer`. It seems that has been introduced by the testcontainers bump in #9675. --- .../ri/kafka/AbstractKafkaEventSubscriberTests.java | 5 +++-- .../AbstractCassandraBackendTestFactory.java | 12 ++++++------ .../cassandratests/CassandraBackendTestFactory.java | 4 ++-- .../cassandratests/ScyllaDBBackendTestFactory.java | 4 ++-- .../AbstractCassandraBackendTestFactory.java | 12 ++++++------ .../cassandra2tests/CassandraBackendTestFactory.java | 4 ++-- .../cassandra2tests/ScyllaDBBackendTestFactory.java | 4 ++-- 7 files changed, 23 insertions(+), 22 deletions(-) diff --git a/events/ri/src/intTest/java/org/projectnessie/events/ri/kafka/AbstractKafkaEventSubscriberTests.java b/events/ri/src/intTest/java/org/projectnessie/events/ri/kafka/AbstractKafkaEventSubscriberTests.java index d79efbef440..d56dbd83e1e 100644 --- a/events/ri/src/intTest/java/org/projectnessie/events/ri/kafka/AbstractKafkaEventSubscriberTests.java +++ b/events/ri/src/intTest/java/org/projectnessie/events/ri/kafka/AbstractKafkaEventSubscriberTests.java @@ -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 { @@ -77,7 +77,8 @@ abstract class AbstractKafkaEventSubscriberTests { .name("kafka") .containerClass(ITKafkaAvroEventSubscriber.class) .build() - .dockerImageName(null)) + .dockerImageName(null) + .asCompatibleSubstituteFor("apache/kafka")) .withNetwork(NETWORK) .withNetworkAliases("broker"); diff --git a/versioned/storage/cassandra-tests/src/main/java/org/projectnessie/versioned/storage/cassandratests/AbstractCassandraBackendTestFactory.java b/versioned/storage/cassandra-tests/src/main/java/org/projectnessie/versioned/storage/cassandratests/AbstractCassandraBackendTestFactory.java index b92638f7911..41eff9e44ba 100644 --- a/versioned/storage/cassandra-tests/src/main/java/org/projectnessie/versioned/storage/cassandratests/AbstractCassandraBackendTestFactory.java +++ b/versioned/storage/cassandra-tests/src/main/java/org/projectnessie/versioned/storage/cassandratests/AbstractCassandraBackendTestFactory.java @@ -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; @@ -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; @@ -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 args; - private CassandraContainer container; + private CassandraContainer container; private InetSocketAddress hostAndPort; private String localDc; @@ -116,8 +116,8 @@ public void start(Optional 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); @@ -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() { diff --git a/versioned/storage/cassandra-tests/src/main/java/org/projectnessie/versioned/storage/cassandratests/CassandraBackendTestFactory.java b/versioned/storage/cassandra-tests/src/main/java/org/projectnessie/versioned/storage/cassandratests/CassandraBackendTestFactory.java index d6399582016..f8b754531dc 100644 --- a/versioned/storage/cassandra-tests/src/main/java/org/projectnessie/versioned/storage/cassandratests/CassandraBackendTestFactory.java +++ b/versioned/storage/cassandra-tests/src/main/java/org/projectnessie/versioned/storage/cassandratests/CassandraBackendTestFactory.java @@ -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 { @@ -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); } } diff --git a/versioned/storage/cassandra-tests/src/main/java/org/projectnessie/versioned/storage/cassandratests/ScyllaDBBackendTestFactory.java b/versioned/storage/cassandra-tests/src/main/java/org/projectnessie/versioned/storage/cassandratests/ScyllaDBBackendTestFactory.java index 2fdd1d8e4c2..8e6f58b8154 100644 --- a/versioned/storage/cassandra-tests/src/main/java/org/projectnessie/versioned/storage/cassandratests/ScyllaDBBackendTestFactory.java +++ b/versioned/storage/cassandra-tests/src/main/java/org/projectnessie/versioned/storage/cassandratests/ScyllaDBBackendTestFactory.java @@ -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 { @@ -47,5 +47,5 @@ public String getName() { } @Override - protected void configureContainer(CassandraContainer c) {} + protected void configureContainer(CassandraContainer c) {} } diff --git a/versioned/storage/cassandra2-tests/src/main/java/org/projectnessie/versioned/storage/cassandra2tests/AbstractCassandraBackendTestFactory.java b/versioned/storage/cassandra2-tests/src/main/java/org/projectnessie/versioned/storage/cassandra2tests/AbstractCassandraBackendTestFactory.java index d89aab1a6fd..a0820500a24 100644 --- a/versioned/storage/cassandra2-tests/src/main/java/org/projectnessie/versioned/storage/cassandra2tests/AbstractCassandraBackendTestFactory.java +++ b/versioned/storage/cassandra2-tests/src/main/java/org/projectnessie/versioned/storage/cassandra2tests/AbstractCassandraBackendTestFactory.java @@ -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; @@ -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; @@ -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 args; - private CassandraContainer container; + private CassandraContainer container; private InetSocketAddress hostAndPort; private String localDc; @@ -117,8 +117,8 @@ public void start(Optional 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); @@ -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() { diff --git a/versioned/storage/cassandra2-tests/src/main/java/org/projectnessie/versioned/storage/cassandra2tests/CassandraBackendTestFactory.java b/versioned/storage/cassandra2-tests/src/main/java/org/projectnessie/versioned/storage/cassandra2tests/CassandraBackendTestFactory.java index 18cabfaea8b..7bf8093f78c 100644 --- a/versioned/storage/cassandra2-tests/src/main/java/org/projectnessie/versioned/storage/cassandra2tests/CassandraBackendTestFactory.java +++ b/versioned/storage/cassandra2-tests/src/main/java/org/projectnessie/versioned/storage/cassandra2tests/CassandraBackendTestFactory.java @@ -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 { @@ -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); } } diff --git a/versioned/storage/cassandra2-tests/src/main/java/org/projectnessie/versioned/storage/cassandra2tests/ScyllaDBBackendTestFactory.java b/versioned/storage/cassandra2-tests/src/main/java/org/projectnessie/versioned/storage/cassandra2tests/ScyllaDBBackendTestFactory.java index 18e0c5d1738..41986f7e100 100644 --- a/versioned/storage/cassandra2-tests/src/main/java/org/projectnessie/versioned/storage/cassandra2tests/ScyllaDBBackendTestFactory.java +++ b/versioned/storage/cassandra2-tests/src/main/java/org/projectnessie/versioned/storage/cassandra2tests/ScyllaDBBackendTestFactory.java @@ -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 { @@ -47,5 +47,5 @@ public String getName() { } @Override - protected void configureContainer(CassandraContainer c) {} + protected void configureContainer(CassandraContainer c) {} }