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 ca31209d2f17658267510959e7916f93b4d37718 Author: Amos Feng <zf...@redhat.com> AuthorDate: Fri Jun 11 12:56:20 2021 +0800 introduce integration-tests-support-activemq --- integration-tests-support/activemq/pom.xml | 102 +++++++++++++++++++ .../support/activemq/ActiveMQTestResource.java | 113 +++++++++++++++++++++ .../activemq/src/main}/resources/broker.xml | 7 -- integration-tests-support/pom.xml | 1 + integration-tests/amqp/pom.xml | 4 +- .../component/amqp/it/ActiveMQTestResource.java | 75 -------------- .../camel/quarkus/component/amqp/it/AmqpTest.java | 6 +- integration-tests/jta/pom.xml | 22 +--- .../component/jta/it/ActiveMQXATestResource.java | 70 ------------- .../camel/quarkus/component/jta/it/JtaTest.java | 6 +- integration-tests/messaging/pom.xml | 27 +---- .../messaging/it/ActiveMQTestResource.java | 75 -------------- .../quarkus/component/messaging/it/JmsTest.java | 6 +- .../messaging/src/test/resources/broker.xml | 19 ---- poms/bom-test/pom.xml | 5 + 15 files changed, 242 insertions(+), 296 deletions(-) diff --git a/integration-tests-support/activemq/pom.xml b/integration-tests-support/activemq/pom.xml new file mode 100644 index 0000000..d551e14 --- /dev/null +++ b/integration-tests-support/activemq/pom.xml @@ -0,0 +1,102 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-tests-support</artifactId> + <version>2.0.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>camel-quarkus-integration-tests-support-activemq</artifactId> + <name>Camel Quarkus :: Integration Tests :: Support :: ActiveMQ</name> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bom-test</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>artemis-server</artifactId> + <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> + <exclusion> + <groupId>org.apache.commons</groupId> + <artifactId>commons-pool2</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>artemis-amqp-protocol</artifactId> + </dependency> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>artemis-mqtt-protocol</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-test-support</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.jboss.jandex</groupId> + <artifactId>jandex-maven-plugin</artifactId> + <executions> + <execution> + <id>make-index</id> + <goals> + <goal>jandex</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> + diff --git a/integration-tests-support/activemq/src/main/java/org/apache/camel/quarkus/test/support/activemq/ActiveMQTestResource.java b/integration-tests-support/activemq/src/main/java/org/apache/camel/quarkus/test/support/activemq/ActiveMQTestResource.java new file mode 100644 index 0000000..57b6647 --- /dev/null +++ b/integration-tests-support/activemq/src/main/java/org/apache/camel/quarkus/test/support/activemq/ActiveMQTestResource.java @@ -0,0 +1,113 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.test.support.activemq; + +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; + +import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; +import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ; +import org.apache.camel.quarkus.test.AvailablePortFinder; +import org.apache.commons.io.FileUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ActiveMQTestResource implements QuarkusTestResourceLifecycleManager { + + private static final Logger LOGGER = LoggerFactory.getLogger(ActiveMQTestResource.class); + private static final String ACTIVEMQ_USERNAME = "artemis"; + private static final String ACTIVEMQ_PASSWORD = "simetraehcapa"; + + private QuarkusEmbeddedMQ embedded; + private String[] modules; + + @Override + public void init(Map<String, String> initArgs) { + initArgs.forEach((name, value) -> { + if (name.equals("modules")) { + modules = value.split(","); + } + }); + } + + @Override + public Map<String, String> start() { + LOGGER.info("start embedded ActiveMQ server"); + + try { + FileUtils.deleteDirectory(Paths.get("./target/artemis").toFile()); + int port = AvailablePortFinder.getNextAvailable(); + String brokerUrlTcp = String.format("tcp://127.0.0.1:%d", port); + String brokerUrlWs = String.format("ws://127.0.0.1:%d", port); + String brokerUrlAmqp = String.format("amqp://127.0.0.1:%d", port); + + embedded = new QuarkusEmbeddedMQ(); + + embedded.init(); + embedded.getActiveMQServer().getConfiguration().addAcceptorConfiguration("activemq", brokerUrlTcp); + embedded.getActiveMQServer().getConfiguration().addConnectorConfiguration("activemq", brokerUrlTcp); + embedded.start(); + + Map<String, String> result = new LinkedHashMap<>(); + + if (modules != null) { + Arrays.stream(modules).forEach(module -> { + if (module.equals("quarkus.artemis")) { + LOGGER.info("add module " + module); + result.put("quarkus.artemis.url", brokerUrlTcp); + result.put("quarkus.artemis.username", ACTIVEMQ_USERNAME); + result.put("quarkus.artemis.password", ACTIVEMQ_PASSWORD); + } else if (module.equals("quarkus.qpid-jms")) { + result.put("quarkus.qpid-jms.url", brokerUrlAmqp); + result.put("quarkus.qpid-jms.username", ACTIVEMQ_USERNAME); + result.put("quarkus.qpid-jms.password", ACTIVEMQ_PASSWORD); + } else if (module.startsWith("camel.component")) { + result.put(module + ".brokerUrl", brokerUrlTcp); + result.put(module + ".username", ACTIVEMQ_USERNAME); + result.put(module + ".password", ACTIVEMQ_PASSWORD); + } else if (module.equals("broker-url.ws")) { + result.put("broker-url.ws", brokerUrlWs); + } + }); + } + + return result; + } catch (Exception e) { + throw new RuntimeException("Could not start embedded ActiveMQ server", e); + } + } + + @Override + public void stop() { + if (embedded == null) { + return; + } + try { + embedded.stop(); + } catch (Exception e) { + throw new RuntimeException("Could not stop embedded ActiveMQ server", e); + } + } +} + +class QuarkusEmbeddedMQ extends EmbeddedActiveMQ { + public void init() throws Exception { + super.initStart(); + } +} diff --git a/integration-tests/jta/src/test/resources/broker.xml b/integration-tests-support/activemq/src/main/resources/broker.xml similarity index 73% rename from integration-tests/jta/src/test/resources/broker.xml rename to integration-tests-support/activemq/src/main/resources/broker.xml index f262064..a2c47f9 100644 --- a/integration-tests/jta/src/test/resources/broker.xml +++ b/integration-tests-support/activemq/src/main/resources/broker.xml @@ -5,13 +5,6 @@ <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> diff --git a/integration-tests-support/pom.xml b/integration-tests-support/pom.xml index b19cfac..33d1c5e 100644 --- a/integration-tests-support/pom.xml +++ b/integration-tests-support/pom.xml @@ -36,6 +36,7 @@ </description> <modules> + <module>activemq</module> <module>aws2</module> <module>azure</module> <module>custom-dataformat</module> diff --git a/integration-tests/amqp/pom.xml b/integration-tests/amqp/pom.xml index 67fa288..80b8677 100644 --- a/integration-tests/amqp/pom.xml +++ b/integration-tests/amqp/pom.xml @@ -51,8 +51,8 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.testcontainers</groupId> - <artifactId>testcontainers</artifactId> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-tests-support-activemq</artifactId> <scope>test</scope> </dependency> diff --git a/integration-tests/amqp/src/test/java/org/apache/camel/quarkus/component/amqp/it/ActiveMQTestResource.java b/integration-tests/amqp/src/test/java/org/apache/camel/quarkus/component/amqp/it/ActiveMQTestResource.java deleted file mode 100644 index d0bafef..0000000 --- a/integration-tests/amqp/src/test/java/org/apache/camel/quarkus/component/amqp/it/ActiveMQTestResource.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.quarkus.component.amqp.it; - -import java.util.Map; - -import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; -import org.apache.camel.util.CollectionHelper; -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 AMQP_PORT = 5672; - - private GenericContainer container; - - @Override - public Map<String, String> start() { - LOGGER.info(TestcontainersConfiguration.getInstance().toString()); - - try { - container = new GenericContainer(ACTIVEMQ_IMAGE) - .withExposedPorts(AMQP_PORT) - .withLogConsumer(new Slf4jLogConsumer(LOGGER)) - .withEnv("BROKER_CONFIG_MAX_DISK_USAGE", "100") - .waitingFor(Wait.forListeningPort()); - - container.start(); - - String brokerUrl = String.format("amqp://127.0.0.1:%d", container.getMappedPort(AMQP_PORT)); - - return CollectionHelper.mapOf( - "quarkus.qpid-jms.url", brokerUrl, - "quarkus.qpid-jms.username", ACTIVEMQ_USERNAME, - "quarkus.qpid-jms.password", ACTIVEMQ_PASSWORD); - - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @Override - public void stop() { - try { - if (container != null) { - container.stop(); - } - } catch (Exception e) { - // Ignored - } - } -} diff --git a/integration-tests/amqp/src/test/java/org/apache/camel/quarkus/component/amqp/it/AmqpTest.java b/integration-tests/amqp/src/test/java/org/apache/camel/quarkus/component/amqp/it/AmqpTest.java index a591af7..06d43b6 100644 --- a/integration-tests/amqp/src/test/java/org/apache/camel/quarkus/component/amqp/it/AmqpTest.java +++ b/integration-tests/amqp/src/test/java/org/apache/camel/quarkus/component/amqp/it/AmqpTest.java @@ -17,15 +17,19 @@ package org.apache.camel.quarkus.component.amqp.it; import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.common.ResourceArg; import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; import io.restassured.http.ContentType; +import org.apache.camel.quarkus.test.support.activemq.ActiveMQTestResource; import org.junit.jupiter.api.Test; import static org.hamcrest.core.Is.is; @QuarkusTest -@QuarkusTestResource(ActiveMQTestResource.class) +@QuarkusTestResource(initArgs = { + @ResourceArg(name = "modules", value = "quarkus.qpid-jms") +}, value = ActiveMQTestResource.class) class AmqpTest { @Test diff --git a/integration-tests/jta/pom.xml b/integration-tests/jta/pom.xml index 5dc4143..57ee0a4 100644 --- a/integration-tests/jta/pom.xml +++ b/integration-tests/jta/pom.xml @@ -97,27 +97,9 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-server</artifactId> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-tests-support-activemq</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 deleted file mode 100644 index c810b35..0000000 --- a/integration-tests/jta/src/test/java/org/apache/camel/quarkus/component/jta/it/ActiveMQXATestResource.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -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; - -public class ActiveMQXATestResource implements QuarkusTestResourceLifecycleManager { - - private static final Logger LOGGER = LoggerFactory.getLogger(ActiveMQXATestResource.class); - private static final String ACTIVEMQ_USERNAME = "artemis"; - private static final String ACTIVEMQ_PASSWORD = "simetraehcapa"; - private static final int ACTIVEMQ_PORT = 61616; - - private EmbeddedActiveMQ embedded; - - @Override - public Map<String, String> start() { - LOGGER.info("start embedded ActiveMQ server"); - - try { - FileUtils.deleteDirectory(Paths.get("./target/artemis").toFile()); - embedded = new EmbeddedActiveMQ(); - embedded.start(); - - String brokerUrlTcp = String.format("tcp://127.0.0.1:%d", ACTIVEMQ_PORT); - - return CollectionHelper.mapOf( - "quarkus.artemis.url", brokerUrlTcp, - "quarkus.artemis.username", ACTIVEMQ_USERNAME, - "quarkus.artemis.password", ACTIVEMQ_PASSWORD); - - } catch (Exception e) { - throw new RuntimeException("Could not start embedded ActiveMQ server", e); - } - } - - @Override - public void stop() { - if (embedded == null) { - return; - } - try { - embedded.stop(); - } catch (Exception e) { - throw new RuntimeException("Could not stop embedded ActiveMQ server", e); - } - } -} diff --git a/integration-tests/jta/src/test/java/org/apache/camel/quarkus/component/jta/it/JtaTest.java b/integration-tests/jta/src/test/java/org/apache/camel/quarkus/component/jta/it/JtaTest.java index af1defc..3c32225 100644 --- a/integration-tests/jta/src/test/java/org/apache/camel/quarkus/component/jta/it/JtaTest.java +++ b/integration-tests/jta/src/test/java/org/apache/camel/quarkus/component/jta/it/JtaTest.java @@ -23,10 +23,12 @@ import java.sql.SQLException; import java.sql.Statement; import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.common.ResourceArg; import io.quarkus.test.h2.H2DatabaseTestResource; import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; import io.restassured.http.ContentType; +import org.apache.camel.quarkus.test.support.activemq.ActiveMQTestResource; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -36,7 +38,9 @@ import static org.hamcrest.Matchers.is; @QuarkusTest @QuarkusTestResource(H2DatabaseTestResource.class) -@QuarkusTestResource(ActiveMQXATestResource.class) +@QuarkusTestResource(initArgs = { + @ResourceArg(name = "modules", value = "quarkus.artemis") +}, value = ActiveMQTestResource.class) class JtaTest { @Test diff --git a/integration-tests/messaging/pom.xml b/integration-tests/messaging/pom.xml index cc9b410..b8e4e5f 100644 --- a/integration-tests/messaging/pom.xml +++ b/integration-tests/messaging/pom.xml @@ -83,31 +83,8 @@ <scope>test</scope> </dependency> <dependency> - <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> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-tests-support-activemq</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 deleted file mode 100644 index 4445db4..0000000 --- a/integration-tests/messaging/src/test/java/org/apache/camel/quarkus/component/messaging/it/ActiveMQTestResource.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -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; - -public class ActiveMQTestResource implements QuarkusTestResourceLifecycleManager { - - private static final Logger LOGGER = LoggerFactory.getLogger(ActiveMQTestResource.class); - private static final String ACTIVEMQ_USERNAME = "artemis"; - private static final String ACTIVEMQ_PASSWORD = "simetraehcapa"; - private static final int ACTIVEMQ_PORT = 61616; - - private EmbeddedActiveMQ embedded; - - @Override - public Map<String, String> start() { - LOGGER.info("start embedded ActiveMQ server"); - - try { - FileUtils.deleteDirectory(Paths.get("./target/artemis").toFile()); - embedded = new EmbeddedActiveMQ(); - embedded.start(); - - 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, - "quarkus.artemis.username", ACTIVEMQ_USERNAME, - "quarkus.artemis.password", ACTIVEMQ_PASSWORD, - "camel.component.paho.brokerUrl", brokerUrlTcp, - "camel.component.paho.username", ACTIVEMQ_USERNAME, - "camel.component.paho.password", ACTIVEMQ_PASSWORD, - "broker-url.ws", brokerUrlWs); - - } catch (Exception e) { - throw new RuntimeException("Could not start embedded ActiveMQ server", e); - } - } - - @Override - public void stop() { - if (embedded == null) { - return; - } - try { - embedded.stop(); - } catch (Exception e) { - throw new RuntimeException("Could not stop embedded ActiveMQ server", e); - } - } -} diff --git a/integration-tests/messaging/src/test/java/org/apache/camel/quarkus/component/messaging/it/JmsTest.java b/integration-tests/messaging/src/test/java/org/apache/camel/quarkus/component/messaging/it/JmsTest.java index 6df6eae..58be3ab 100644 --- a/integration-tests/messaging/src/test/java/org/apache/camel/quarkus/component/messaging/it/JmsTest.java +++ b/integration-tests/messaging/src/test/java/org/apache/camel/quarkus/component/messaging/it/JmsTest.java @@ -20,10 +20,12 @@ import java.util.HashMap; import java.util.Map; import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.common.ResourceArg; import io.quarkus.test.junit.DisabledOnNativeImage; import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; import io.restassured.http.ContentType; +import org.apache.camel.quarkus.test.support.activemq.ActiveMQTestResource; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -32,7 +34,9 @@ import static org.hamcrest.core.Is.is; import static org.junit.jupiter.api.Assertions.assertTrue; @QuarkusTest -@QuarkusTestResource(ActiveMQTestResource.class) +@QuarkusTestResource(initArgs = { + @ResourceArg(name = "modules", value = "quarkus.artemis,camel.component.paho,broker-url.ws") +}, value = ActiveMQTestResource.class) class JmsTest { @ParameterizedTest diff --git a/integration-tests/messaging/src/test/resources/broker.xml b/integration-tests/messaging/src/test/resources/broker.xml deleted file mode 100644 index f262064..0000000 --- a/integration-tests/messaging/src/test/resources/broker.xml +++ /dev/null @@ -1,19 +0,0 @@ -<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/poms/bom-test/pom.xml b/poms/bom-test/pom.xml index 718f5eb..24517e6 100644 --- a/poms/bom-test/pom.xml +++ b/poms/bom-test/pom.xml @@ -60,6 +60,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-tests-support-activemq</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-integration-tests-support-aws2</artifactId> <version>${camel-quarkus.version}</version> </dependency>