This is an automated email from the ASF dual-hosted git repository. ppalaga pushed a commit to branch quarkus-main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 526e32fbab29017343c16cf7a1547c0b6098e90c Author: Amos Feng <zf...@redhat.com> AuthorDate: Tue Jun 8 08:49:51 2021 +0800 Fix #2727 to use embeddedActiveMQ for messageing and jta integration tests --- integration-tests/jta/pom.xml | 22 +++++++++++-- .../component/jta/it/ActiveMQXATestResource.java | 36 +++++++++------------ .../jta/src/test/resources/broker.xml | 19 +++++++++++ integration-tests/messaging/pom.xml | 27 ++++++++++++++-- .../messaging/it/ActiveMQTestResource.java | 37 ++++++++++------------ .../messaging/src/test/resources/broker.xml | 19 +++++++++++ 6 files changed, 114 insertions(+), 46 deletions(-) diff --git a/integration-tests/jta/pom.xml b/integration-tests/jta/pom.xml index 3773e86..5dc4143 100644 --- a/integration-tests/jta/pom.xml +++ b/integration-tests/jta/pom.xml @@ -97,9 +97,27 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.testcontainers</groupId> - <artifactId>testcontainers</artifactId> + <groupId>org.apache.activemq</groupId> + <artifactId>artemis-server</artifactId> <scope>test</scope> + <exclusions> + <exclusion> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-json_1.0_spec</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.johnzon</groupId> + <artifactId>johnzon-core</artifactId> + </exclusion> + <exclusion> + <groupId>org.jboss.logmanager</groupId> + <artifactId>jboss-logmanager</artifactId> + </exclusion> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> </dependency> <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory --> diff --git a/integration-tests/jta/src/test/java/org/apache/camel/quarkus/component/jta/it/ActiveMQXATestResource.java b/integration-tests/jta/src/test/java/org/apache/camel/quarkus/component/jta/it/ActiveMQXATestResource.java index 823b311..c810b35 100644 --- a/integration-tests/jta/src/test/java/org/apache/camel/quarkus/component/jta/it/ActiveMQXATestResource.java +++ b/integration-tests/jta/src/test/java/org/apache/camel/quarkus/component/jta/it/ActiveMQXATestResource.java @@ -16,42 +16,35 @@ */ package org.apache.camel.quarkus.component.jta.it; +import java.nio.file.Paths; import java.util.Map; import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; +import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ; import org.apache.camel.util.CollectionHelper; +import org.apache.commons.io.FileUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.output.Slf4jLogConsumer; -import org.testcontainers.containers.wait.strategy.Wait; -import org.testcontainers.utility.TestcontainersConfiguration; public class ActiveMQXATestResource implements QuarkusTestResourceLifecycleManager { private static final Logger LOGGER = LoggerFactory.getLogger(ActiveMQXATestResource.class); - private static final String ACTIVEMQ_IMAGE = "vromero/activemq-artemis:2.11.0-alpine"; private static final String ACTIVEMQ_USERNAME = "artemis"; private static final String ACTIVEMQ_PASSWORD = "simetraehcapa"; private static final int ACTIVEMQ_PORT = 61616; - private GenericContainer<?> container; + private EmbeddedActiveMQ embedded; @Override public Map<String, String> start() { - LOGGER.info(TestcontainersConfiguration.getInstance().toString()); + LOGGER.info("start embedded ActiveMQ server"); try { - container = new GenericContainer<>(ACTIVEMQ_IMAGE) - .withExposedPorts(ACTIVEMQ_PORT) - .withLogConsumer(new Slf4jLogConsumer(LOGGER)) - .withEnv("BROKER_CONFIG_MAX_DISK_USAGE", "100") - .waitingFor(Wait.forListeningPort()); + FileUtils.deleteDirectory(Paths.get("./target/artemis").toFile()); + embedded = new EmbeddedActiveMQ(); + embedded.start(); - container.start(); - - String brokerUrlTcp = String.format("tcp://%s:%d/", container.getContainerIpAddress(), - container.getMappedPort(ACTIVEMQ_PORT)); + String brokerUrlTcp = String.format("tcp://127.0.0.1:%d", ACTIVEMQ_PORT); return CollectionHelper.mapOf( "quarkus.artemis.url", brokerUrlTcp, @@ -59,18 +52,19 @@ public class ActiveMQXATestResource implements QuarkusTestResourceLifecycleManag "quarkus.artemis.password", ACTIVEMQ_PASSWORD); } catch (Exception e) { - throw new RuntimeException(e); + throw new RuntimeException("Could not start embedded ActiveMQ server", e); } } @Override public void stop() { + if (embedded == null) { + return; + } try { - if (container != null) { - container.stop(); - } + embedded.stop(); } catch (Exception e) { - // ignored + throw new RuntimeException("Could not stop embedded ActiveMQ server", e); } } } diff --git a/integration-tests/jta/src/test/resources/broker.xml b/integration-tests/jta/src/test/resources/broker.xml new file mode 100644 index 0000000..f262064 --- /dev/null +++ b/integration-tests/jta/src/test/resources/broker.xml @@ -0,0 +1,19 @@ +<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd"> + <core xmlns="urn:activemq:core"> + <paging-directory>./target/artemis/paging</paging-directory> + <bindings-directory>./target/artemis/bindings</bindings-directory> + <journal-directory>./target/artemis/journal</journal-directory> + <large-messages-directory>./target/artemis/large-messages</large-messages-directory> + + <connectors> + <connector name="activemq">tcp://localhost:61616</connector> + </connectors> + <acceptors> + <acceptor name="activemq">tcp://localhost:61616</acceptor> + </acceptors> + + <max-disk-usage>-1</max-disk-usage> + <security-enabled>false</security-enabled> + + </core> +</configuration> diff --git a/integration-tests/messaging/pom.xml b/integration-tests/messaging/pom.xml index 449ba67..cc9b410 100644 --- a/integration-tests/messaging/pom.xml +++ b/integration-tests/messaging/pom.xml @@ -83,8 +83,31 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.testcontainers</groupId> - <artifactId>testcontainers</artifactId> + <groupId>org.apache.activemq</groupId> + <artifactId>artemis-server</artifactId> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-json_1.0_spec</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.johnzon</groupId> + <artifactId>johnzon-core</artifactId> + </exclusion> + <exclusion> + <groupId>org.jboss.logmanager</groupId> + <artifactId>jboss-logmanager</artifactId> + </exclusion> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>artemis-mqtt-protocol</artifactId> <scope>test</scope> </dependency> diff --git a/integration-tests/messaging/src/test/java/org/apache/camel/quarkus/component/messaging/it/ActiveMQTestResource.java b/integration-tests/messaging/src/test/java/org/apache/camel/quarkus/component/messaging/it/ActiveMQTestResource.java index 4934e81..4445db4 100644 --- a/integration-tests/messaging/src/test/java/org/apache/camel/quarkus/component/messaging/it/ActiveMQTestResource.java +++ b/integration-tests/messaging/src/test/java/org/apache/camel/quarkus/component/messaging/it/ActiveMQTestResource.java @@ -16,42 +16,36 @@ */ package org.apache.camel.quarkus.component.messaging.it; +import java.nio.file.Paths; import java.util.Map; import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; +import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ; import org.apache.camel.util.CollectionHelper; +import org.apache.commons.io.FileUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.output.Slf4jLogConsumer; -import org.testcontainers.containers.wait.strategy.Wait; -import org.testcontainers.utility.TestcontainersConfiguration; public class ActiveMQTestResource implements QuarkusTestResourceLifecycleManager { private static final Logger LOGGER = LoggerFactory.getLogger(ActiveMQTestResource.class); - private static final String ACTIVEMQ_IMAGE = "vromero/activemq-artemis:2.11.0-alpine"; private static final String ACTIVEMQ_USERNAME = "artemis"; private static final String ACTIVEMQ_PASSWORD = "simetraehcapa"; private static final int ACTIVEMQ_PORT = 61616; - private GenericContainer<?> container; + private EmbeddedActiveMQ embedded; @Override public Map<String, String> start() { - LOGGER.info(TestcontainersConfiguration.getInstance().toString()); + LOGGER.info("start embedded ActiveMQ server"); try { - container = new GenericContainer<>(ACTIVEMQ_IMAGE) - .withExposedPorts(ACTIVEMQ_PORT) - .withLogConsumer(new Slf4jLogConsumer(LOGGER)) - .withEnv("BROKER_CONFIG_MAX_DISK_USAGE", "100") - .waitingFor(Wait.forListeningPort()); + FileUtils.deleteDirectory(Paths.get("./target/artemis").toFile()); + embedded = new EmbeddedActiveMQ(); + embedded.start(); - container.start(); - - String brokerUrlTcp = String.format("tcp://127.0.0.1:%d", container.getMappedPort(ACTIVEMQ_PORT)); - String brokerUrlWs = String.format("ws://127.0.0.1:%d", container.getMappedPort(ACTIVEMQ_PORT)); + String brokerUrlTcp = String.format("tcp://127.0.0.1:%d", ACTIVEMQ_PORT); + String brokerUrlWs = String.format("ws://127.0.0.1:%d", ACTIVEMQ_PORT); return CollectionHelper.mapOf( "quarkus.artemis.url", brokerUrlTcp, @@ -63,18 +57,19 @@ public class ActiveMQTestResource implements QuarkusTestResourceLifecycleManager "broker-url.ws", brokerUrlWs); } catch (Exception e) { - throw new RuntimeException(e); + throw new RuntimeException("Could not start embedded ActiveMQ server", e); } } @Override public void stop() { + if (embedded == null) { + return; + } try { - if (container != null) { - container.stop(); - } + embedded.stop(); } catch (Exception e) { - // ignored + throw new RuntimeException("Could not stop embedded ActiveMQ server", e); } } } diff --git a/integration-tests/messaging/src/test/resources/broker.xml b/integration-tests/messaging/src/test/resources/broker.xml new file mode 100644 index 0000000..f262064 --- /dev/null +++ b/integration-tests/messaging/src/test/resources/broker.xml @@ -0,0 +1,19 @@ +<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd"> + <core xmlns="urn:activemq:core"> + <paging-directory>./target/artemis/paging</paging-directory> + <bindings-directory>./target/artemis/bindings</bindings-directory> + <journal-directory>./target/artemis/journal</journal-directory> + <large-messages-directory>./target/artemis/large-messages</large-messages-directory> + + <connectors> + <connector name="activemq">tcp://localhost:61616</connector> + </connectors> + <acceptors> + <acceptor name="activemq">tcp://localhost:61616</acceptor> + </acceptors> + + <max-disk-usage>-1</max-disk-usage> + <security-enabled>false</security-enabled> + + </core> +</configuration>