This is an automated email from the ASF dual-hosted git repository.
claudio4j pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new e20b758148b2 Fix testcontainer deprecated classes and fix mongodb test
(#20067)
e20b758148b2 is described below
commit e20b758148b2f9d3a81227e541ffe1350dd8e08b
Author: Claudio Miranda <[email protected]>
AuthorDate: Fri Nov 28 23:26:29 2025 +0000
Fix testcontainer deprecated classes and fix mongodb test (#20067)
Fix TC renaming of container packages
Fix mongodb test, since it was failing because the changestream feature
works with a replicaset
---
.../org/apache/camel/component/dhis2/Environment.java | 6 +++---
.../slot/integration/PgReplicationITSupport.java | 4 ++--
.../camel/pgevent/integration/PgEventITSupport.java | 9 ++++-----
.../services/GooglePubSubLocalContainerInfraService.java | 2 +-
.../services/MongoDBLocalContainerInfraService.java | 3 ++-
.../mongodb/services/MongoDBLocalContainerService.java | 2 +-
.../neo4j/services/Neo4jLocalContainerInfraService.java | 2 +-
.../services/PostgresLocalContainerInfraService.java | 15 +++++++++------
.../postgres/services/PostgresLocalContainerService.java | 3 ++-
.../infra/postgres/services/PostgresServiceFactory.java | 2 +-
.../pulsar/services/PulsarLocalContainerInfraService.java | 2 +-
11 files changed, 27 insertions(+), 23 deletions(-)
diff --git
a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Environment.java
b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Environment.java
index 06b8ea5a4ca2..95518d199359 100644
---
a/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Environment.java
+++
b/components/camel-dhis2/camel-dhis2-component/src/test/java/org/apache/camel/component/dhis2/Environment.java
@@ -30,8 +30,8 @@ import org.hisp.dhis.integration.sdk.api.Dhis2Client;
import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
-import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;
+import org.testcontainers.postgresql.PostgreSQLContainer;
import org.testcontainers.utility.DockerImageName;
public final class Environment {
@@ -44,7 +44,7 @@ public final class Environment {
private static final Network NETWORK = Network.newNetwork();
- private static final PostgreSQLContainer<?> POSTGRESQL_CONTAINER;
+ private static final PostgreSQLContainer POSTGRESQL_CONTAINER;
private static final GenericContainer<?> DHIS2_CONTAINER;
@@ -53,7 +53,7 @@ public final class Environment {
}
static {
- POSTGRESQL_CONTAINER = new PostgreSQLContainer<>(
+ POSTGRESQL_CONTAINER = new PostgreSQLContainer(
DockerImageName.parse("postgis/postgis:12-3.2-alpine").asCompatibleSubstituteFor("postgres"))
.withDatabaseName("dhis2")
.withNetworkAliases("db")
diff --git
a/components/camel-pg-replication-slot/src/test/java/org/apache/camel/component/pg/replication/slot/integration/PgReplicationITSupport.java
b/components/camel-pg-replication-slot/src/test/java/org/apache/camel/component/pg/replication/slot/integration/PgReplicationITSupport.java
index 54f81c03815b..a208e4f98118 100644
---
a/components/camel-pg-replication-slot/src/test/java/org/apache/camel/component/pg/replication/slot/integration/PgReplicationITSupport.java
+++
b/components/camel-pg-replication-slot/src/test/java/org/apache/camel/component/pg/replication/slot/integration/PgReplicationITSupport.java
@@ -20,7 +20,7 @@ package
org.apache.camel.component.pg.replication.slot.integration;
import
org.apache.camel.test.infra.postgres.services.PostgresLocalContainerService;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.extension.RegisterExtension;
-import org.testcontainers.containers.PostgreSQLContainer;
+import org.testcontainers.postgresql.PostgreSQLContainer;
import org.testcontainers.utility.DockerImageName;
public class PgReplicationITSupport extends CamelTestSupport {
@@ -29,7 +29,7 @@ public class PgReplicationITSupport extends CamelTestSupport {
static PostgresLocalContainerService service;
static {
- PostgreSQLContainer container = new PostgreSQLContainer<>(
+ PostgreSQLContainer container = new PostgreSQLContainer(
DockerImageName.parse(PostgresLocalContainerService.DEFAULT_POSTGRES_CONTAINER)
.asCompatibleSubstituteFor("postgres"))
.withDatabaseName("camel")
diff --git
a/components/camel-pgevent/src/test/java/org/apache/camel/pgevent/integration/PgEventITSupport.java
b/components/camel-pgevent/src/test/java/org/apache/camel/pgevent/integration/PgEventITSupport.java
index a99065081282..ca0633fc258b 100644
---
a/components/camel-pgevent/src/test/java/org/apache/camel/pgevent/integration/PgEventITSupport.java
+++
b/components/camel-pgevent/src/test/java/org/apache/camel/pgevent/integration/PgEventITSupport.java
@@ -23,10 +23,10 @@ import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.PostgreSQLContainer;
-import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.postgresql.PostgreSQLContainer;
public class PgEventITSupport extends CamelTestSupport {
+
@RegisterExtension
public static JDBCService service = JDBCServiceFactory
.builder()
@@ -38,7 +38,7 @@ public class PgEventITSupport extends CamelTestSupport {
protected static final String POSTGRES_PASSWORD = "mysecretpassword";
protected static final String POSTGRES_DB = "postgres";
- private static final Logger LOG =
LoggerFactory.getLogger(PgEventITSupport.class);
+ private static final Logger LOG =
LoggerFactory.getLogger(PgEventITSupport.class.getName());
private static PostgreSQLContainer container;
@@ -49,8 +49,7 @@ public class PgEventITSupport extends CamelTestSupport {
container.withUsername(POSTGRES_USER)
.withPassword(POSTGRES_PASSWORD)
- .withDatabaseName(POSTGRES_DB)
- .withLogConsumer(new Slf4jLogConsumer(LOG));
+ .withDatabaseName(POSTGRES_DB);
return new JDBCLocalContainerService<>(container);
}
diff --git
a/test-infra/camel-test-infra-google-pubsub/src/main/java/org/apache/camel/test/infra/google/pubsub/services/GooglePubSubLocalContainerInfraService.java
b/test-infra/camel-test-infra-google-pubsub/src/main/java/org/apache/camel/test/infra/google/pubsub/services/GooglePubSubLocalContainerInfraService.java
index ee86a4e6a00f..413de765afb1 100644
---
a/test-infra/camel-test-infra-google-pubsub/src/main/java/org/apache/camel/test/infra/google/pubsub/services/GooglePubSubLocalContainerInfraService.java
+++
b/test-infra/camel-test-infra-google-pubsub/src/main/java/org/apache/camel/test/infra/google/pubsub/services/GooglePubSubLocalContainerInfraService.java
@@ -23,7 +23,7 @@ import
org.apache.camel.test.infra.common.services.ContainerService;
import org.apache.camel.test.infra.google.pubsub.common.GooglePubSubProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.PubSubEmulatorContainer;
+import org.testcontainers.gcloud.PubSubEmulatorContainer;
import org.testcontainers.utility.DockerImageName;
@InfraService(service = GooglePubSubInfraService.class,
diff --git
a/test-infra/camel-test-infra-mongodb/src/main/java/org/apache/camel/test/infra/mongodb/services/MongoDBLocalContainerInfraService.java
b/test-infra/camel-test-infra-mongodb/src/main/java/org/apache/camel/test/infra/mongodb/services/MongoDBLocalContainerInfraService.java
index 44d3d899d4f7..0ac42a34505f 100644
---
a/test-infra/camel-test-infra-mongodb/src/main/java/org/apache/camel/test/infra/mongodb/services/MongoDBLocalContainerInfraService.java
+++
b/test-infra/camel-test-infra-mongodb/src/main/java/org/apache/camel/test/infra/mongodb/services/MongoDBLocalContainerInfraService.java
@@ -24,7 +24,7 @@ import
org.apache.camel.test.infra.common.services.ContainerService;
import org.apache.camel.test.infra.mongodb.common.MongoDBProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.MongoDBContainer;
+import org.testcontainers.mongodb.MongoDBContainer;
import org.testcontainers.utility.DockerImageName;
@InfraService(service = MongoDBInfraService.class,
@@ -58,6 +58,7 @@ public class MongoDBLocalContainerInfraService implements
MongoDBInfraService, C
public TestInfraMongoDBContainer(boolean fixedPort, String
imageName) {
super(DockerImageName.parse(imageName).asCompatibleSubstituteFor("mongo"));
addPort(fixedPort);
+ withReplicaSet();
}
private void addPort(boolean fixedPort) {
diff --git
a/test-infra/camel-test-infra-mongodb/src/test/java/org/apache/camel/test/infra/mongodb/services/MongoDBLocalContainerService.java
b/test-infra/camel-test-infra-mongodb/src/test/java/org/apache/camel/test/infra/mongodb/services/MongoDBLocalContainerService.java
index 4a120c941374..c607a10f98bd 100644
---
a/test-infra/camel-test-infra-mongodb/src/test/java/org/apache/camel/test/infra/mongodb/services/MongoDBLocalContainerService.java
+++
b/test-infra/camel-test-infra-mongodb/src/test/java/org/apache/camel/test/infra/mongodb/services/MongoDBLocalContainerService.java
@@ -16,7 +16,7 @@
*/
package org.apache.camel.test.infra.mongodb.services;
-import org.testcontainers.containers.MongoDBContainer;
+import org.testcontainers.mongodb.MongoDBContainer;
public class MongoDBLocalContainerService extends
MongoDBLocalContainerInfraService implements MongoDBService {
public MongoDBLocalContainerService() {
diff --git
a/test-infra/camel-test-infra-neo4j/src/main/java/org/apache/camel/test/infra/neo4j/services/Neo4jLocalContainerInfraService.java
b/test-infra/camel-test-infra-neo4j/src/main/java/org/apache/camel/test/infra/neo4j/services/Neo4jLocalContainerInfraService.java
index 5d16874eed90..2048cf7d394f 100644
---
a/test-infra/camel-test-infra-neo4j/src/main/java/org/apache/camel/test/infra/neo4j/services/Neo4jLocalContainerInfraService.java
+++
b/test-infra/camel-test-infra-neo4j/src/main/java/org/apache/camel/test/infra/neo4j/services/Neo4jLocalContainerInfraService.java
@@ -25,7 +25,7 @@ import
org.apache.camel.test.infra.common.services.ContainerService;
import org.apache.camel.test.infra.neo4j.common.Neo4jProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.Neo4jContainer;
+import org.testcontainers.neo4j.Neo4jContainer;
import org.testcontainers.utility.DockerImageName;
@InfraService(service = Neo4jInfraService.class,
diff --git
a/test-infra/camel-test-infra-postgres/src/main/java/org/apache/camel/test/infra/postgres/services/PostgresLocalContainerInfraService.java
b/test-infra/camel-test-infra-postgres/src/main/java/org/apache/camel/test/infra/postgres/services/PostgresLocalContainerInfraService.java
index 54619cd71f8e..d64e5f4839f0 100644
---
a/test-infra/camel-test-infra-postgres/src/main/java/org/apache/camel/test/infra/postgres/services/PostgresLocalContainerInfraService.java
+++
b/test-infra/camel-test-infra-postgres/src/main/java/org/apache/camel/test/infra/postgres/services/PostgresLocalContainerInfraService.java
@@ -23,18 +23,20 @@ import
org.apache.camel.test.infra.common.services.ContainerService;
import org.apache.camel.test.infra.postgres.common.PostgresProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.PostgreSQLContainer;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.postgresql.PostgreSQLContainer;
import org.testcontainers.utility.DockerImageName;
@InfraService(service = PostgresInfraService.class,
description = "Postgres SQL Database",
serviceAlias = { "postgres" })
-public class PostgresLocalContainerInfraService implements
PostgresInfraService, ContainerService<PostgreSQLContainer<?>> {
+public class PostgresLocalContainerInfraService implements
PostgresInfraService, ContainerService<PostgreSQLContainer> {
+
public static final String DEFAULT_POSTGRES_CONTAINER
=
LocalPropertyResolver.getProperty(PostgresLocalContainerInfraService.class,
PostgresProperties.POSTGRES_CONTAINER);
private static final Logger LOG =
LoggerFactory.getLogger(PostgresLocalContainerInfraService.class);
- private final PostgreSQLContainer<?> container;
+ private final PostgreSQLContainer container;
public PostgresLocalContainerInfraService() {
this(DEFAULT_POSTGRES_CONTAINER);
@@ -48,11 +50,11 @@ public class PostgresLocalContainerInfraService implements
PostgresInfraService,
}
}
- public PostgresLocalContainerInfraService(PostgreSQLContainer<?>
container) {
+ public PostgresLocalContainerInfraService(PostgreSQLContainer container) {
this.container = container;
}
- protected PostgreSQLContainer<?> initContainer(String imageName) {
+ protected PostgreSQLContainer initContainer(String imageName) {
class TestInfraPostgreSQLContainer extends PostgreSQLContainer {
public TestInfraPostgreSQLContainer(boolean fixedPort) {
super(DockerImageName.parse(imageName)
@@ -61,6 +63,7 @@ public class PostgresLocalContainerInfraService implements
PostgresInfraService,
if (fixedPort) {
addFixedExposedPort(5432, 5432);
}
+ withLogConsumer(new Slf4jLogConsumer(LOG));
}
}
@@ -92,7 +95,7 @@ public class PostgresLocalContainerInfraService implements
PostgresInfraService,
}
@Override
- public PostgreSQLContainer<?> getContainer() {
+ public PostgreSQLContainer getContainer() {
return container;
}
diff --git
a/test-infra/camel-test-infra-postgres/src/test/java/org/apache/camel/test/infra/postgres/services/PostgresLocalContainerService.java
b/test-infra/camel-test-infra-postgres/src/test/java/org/apache/camel/test/infra/postgres/services/PostgresLocalContainerService.java
index 0aa2b8f1cfa1..f9f5b377f062 100644
---
a/test-infra/camel-test-infra-postgres/src/test/java/org/apache/camel/test/infra/postgres/services/PostgresLocalContainerService.java
+++
b/test-infra/camel-test-infra-postgres/src/test/java/org/apache/camel/test/infra/postgres/services/PostgresLocalContainerService.java
@@ -16,9 +16,10 @@
*/
package org.apache.camel.test.infra.postgres.services;
-import org.testcontainers.containers.PostgreSQLContainer;
+import org.testcontainers.postgresql.PostgreSQLContainer;
public class PostgresLocalContainerService extends
PostgresLocalContainerInfraService implements PostgresService {
+
public PostgresLocalContainerService() {
super();
}
diff --git
a/test-infra/camel-test-infra-postgres/src/test/java/org/apache/camel/test/infra/postgres/services/PostgresServiceFactory.java
b/test-infra/camel-test-infra-postgres/src/test/java/org/apache/camel/test/infra/postgres/services/PostgresServiceFactory.java
index a2b40af6a954..e442ab10cc58 100644
---
a/test-infra/camel-test-infra-postgres/src/test/java/org/apache/camel/test/infra/postgres/services/PostgresServiceFactory.java
+++
b/test-infra/camel-test-infra-postgres/src/test/java/org/apache/camel/test/infra/postgres/services/PostgresServiceFactory.java
@@ -19,8 +19,8 @@ package org.apache.camel.test.infra.postgres.services;
import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder;
public final class PostgresServiceFactory {
- private PostgresServiceFactory() {
+ private PostgresServiceFactory() {
}
public static SimpleTestServiceBuilder<PostgresService> builder() {
diff --git
a/test-infra/camel-test-infra-pulsar/src/main/java/org/apache/camel/test/infra/pulsar/services/PulsarLocalContainerInfraService.java
b/test-infra/camel-test-infra-pulsar/src/main/java/org/apache/camel/test/infra/pulsar/services/PulsarLocalContainerInfraService.java
index 4471ab5ee3cc..dcc74082e6ad 100644
---
a/test-infra/camel-test-infra-pulsar/src/main/java/org/apache/camel/test/infra/pulsar/services/PulsarLocalContainerInfraService.java
+++
b/test-infra/camel-test-infra-pulsar/src/main/java/org/apache/camel/test/infra/pulsar/services/PulsarLocalContainerInfraService.java
@@ -25,7 +25,7 @@ import
org.apache.camel.test.infra.common.services.ContainerService;
import org.apache.camel.test.infra.pulsar.common.PulsarProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.PulsarContainer;
+import org.testcontainers.pulsar.PulsarContainer;
import org.testcontainers.utility.DockerImageName;
@InfraService(service = PulsarInfraService.class,