From c42bef214b2aca50182951f3965fab519e689300 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Mon, 12 Aug 2024 09:16:41 +0200 Subject: [PATCH] Drop MongoDB test resource: we have Dev Services now --- .../org/acme/mongodb/FruitResourceTest.java | 2 -- .../org/acme/mongodb/MongoDbResource.java | 33 ------------------- 2 files changed, 35 deletions(-) delete mode 100644 mongodb-quickstart/src/test/java/org/acme/mongodb/MongoDbResource.java diff --git a/mongodb-quickstart/src/test/java/org/acme/mongodb/FruitResourceTest.java b/mongodb-quickstart/src/test/java/org/acme/mongodb/FruitResourceTest.java index 2500a78bfe..38c0b72cd9 100644 --- a/mongodb-quickstart/src/test/java/org/acme/mongodb/FruitResourceTest.java +++ b/mongodb-quickstart/src/test/java/org/acme/mongodb/FruitResourceTest.java @@ -1,6 +1,5 @@ package org.acme.mongodb; -import io.quarkus.test.common.WithTestResource; import org.apache.http.HttpStatus; import org.assertj.core.api.Assertions; import org.junit.jupiter.params.ParameterizedTest; @@ -12,7 +11,6 @@ import io.restassured.http.ContentType; @QuarkusTest -@WithTestResource(MongoDbResource.class) public class FruitResourceTest { @ParameterizedTest diff --git a/mongodb-quickstart/src/test/java/org/acme/mongodb/MongoDbResource.java b/mongodb-quickstart/src/test/java/org/acme/mongodb/MongoDbResource.java deleted file mode 100644 index 160fa22069..0000000000 --- a/mongodb-quickstart/src/test/java/org/acme/mongodb/MongoDbResource.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.acme.mongodb; - -import java.util.HashMap; -import java.util.Map; - -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy; - -import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; - -public class MongoDbResource implements QuarkusTestResourceLifecycleManager { - public static final String MONGO_IMAGE_NAME = "mongo:4.2.6"; - public static final int MONGO_PORT = 27017; - - private GenericContainer mongoContainer; - - @Override - public Map start() { - mongoContainer = new GenericContainer<>(MONGO_IMAGE_NAME).withExposedPorts(MONGO_PORT); - mongoContainer.waitingFor(new HostPortWaitStrategy()).start(); - Map properties = new HashMap<>(); - properties.put("quarkus.mongodb.connection-string", - String.format("mongodb://%s:%d", mongoContainer.getHost(), mongoContainer.getMappedPort(MONGO_PORT))); - return properties; - } - - @Override - public void stop() { - if (mongoContainer != null) { - mongoContainer.stop(); - } - } -}