From cae606c2b503758968ea097bd34d5ab7651989de Mon Sep 17 00:00:00 2001 From: Robbie Gemmell Date: Mon, 17 Apr 2023 17:45:42 +0100 Subject: [PATCH] simplify test dep, just trivially use artemis directly (cherry picked from commit ed62e5ebc085635c0a57ec6ab9ed6866601a39e7) with fixups --- integration-tests/pom.xml | 21 +++---- .../qpid/jms/it/QpidJmsReceiveTest.java | 5 +- .../quarkus/qpid/jms/it/QpidJmsSendTest.java | 5 +- .../jms/it/artemis/BrokerTestResource.java | 60 +++++++++++++++++++ 4 files changed, 77 insertions(+), 14 deletions(-) create mode 100644 integration-tests/src/test/java/org/amqphub/quarkus/qpid/jms/it/artemis/BrokerTestResource.java diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 7b626ed..3ab8571 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -28,7 +28,7 @@ Quarkus Qpid JMS integration tests module - 1.0.5 + 2.28.0 @@ -58,14 +58,20 @@ - io.quarkiverse.artemis - quarkus-test-artemis - ${quarkus-test-artemis-version} + org.apache.activemq + artemis-server + ${artemis-version} + test + + + org.apache.activemq + artemis-amqp-protocol + ${artemis-version} test io.quarkus - quarkus-jackson + quarkus-test-common test @@ -78,11 +84,6 @@ rest-assured test - - org.jboss.logging - commons-logging-jboss-logging - test - diff --git a/integration-tests/src/test/java/org/amqphub/quarkus/qpid/jms/it/QpidJmsReceiveTest.java b/integration-tests/src/test/java/org/amqphub/quarkus/qpid/jms/it/QpidJmsReceiveTest.java index d20dc9c..9a26164 100644 --- a/integration-tests/src/test/java/org/amqphub/quarkus/qpid/jms/it/QpidJmsReceiveTest.java +++ b/integration-tests/src/test/java/org/amqphub/quarkus/qpid/jms/it/QpidJmsReceiveTest.java @@ -17,6 +17,8 @@ import static org.amqphub.quarkus.qpid.jms.it.QpidJmsTestSupport.ENDPOINT_PATH; +import org.amqphub.quarkus.qpid.jms.it.artemis.BrokerTestResource; + import javax.jms.JMSContext; import javax.jms.JMSProducer; import javax.jms.Queue; @@ -25,14 +27,13 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import io.quarkus.artemis.test.ArtemisTestResource; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; import io.restassured.response.Response; @QuarkusTest -@QuarkusTestResource(ArtemisTestResource.class) +@QuarkusTestResource(BrokerTestResource.class) public class QpidJmsReceiveTest { /** diff --git a/integration-tests/src/test/java/org/amqphub/quarkus/qpid/jms/it/QpidJmsSendTest.java b/integration-tests/src/test/java/org/amqphub/quarkus/qpid/jms/it/QpidJmsSendTest.java index 6910951..2f5159b 100644 --- a/integration-tests/src/test/java/org/amqphub/quarkus/qpid/jms/it/QpidJmsSendTest.java +++ b/integration-tests/src/test/java/org/amqphub/quarkus/qpid/jms/it/QpidJmsSendTest.java @@ -17,6 +17,8 @@ import static org.amqphub.quarkus.qpid.jms.it.QpidJmsTestSupport.ENDPOINT_PATH; +import org.amqphub.quarkus.qpid.jms.it.artemis.BrokerTestResource; + import javax.jms.JMSConsumer; import javax.jms.JMSContext; import javax.jms.Queue; @@ -25,14 +27,13 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import io.quarkus.artemis.test.ArtemisTestResource; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; import io.restassured.response.Response; @QuarkusTest -@QuarkusTestResource(ArtemisTestResource.class) +@QuarkusTestResource(BrokerTestResource.class) public class QpidJmsSendTest { /** diff --git a/integration-tests/src/test/java/org/amqphub/quarkus/qpid/jms/it/artemis/BrokerTestResource.java b/integration-tests/src/test/java/org/amqphub/quarkus/qpid/jms/it/artemis/BrokerTestResource.java new file mode 100644 index 0000000..a3678ad --- /dev/null +++ b/integration-tests/src/test/java/org/amqphub/quarkus/qpid/jms/it/artemis/BrokerTestResource.java @@ -0,0 +1,60 @@ +/* +* Copyright 2023 the original author or authors. +* +* Licensed 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.amqphub.quarkus.qpid.jms.it.artemis; + +import java.io.File; +import java.nio.file.Paths; +import java.util.Collections; +import java.util.Map; + +import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ; +import org.apache.commons.io.FileUtils; + +import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; + +public class BrokerTestResource implements QuarkusTestResourceLifecycleManager { + + private EmbeddedActiveMQ embeddedBroker; + + @Override + public Map start() { + try { + // Matches what is defined in the broker.xml file in-tree. + File parentDir = Paths.get("./target/artemis").toFile(); + FileUtils.deleteDirectory(parentDir); + + embeddedBroker = new EmbeddedActiveMQ(); + embeddedBroker.start(); + } catch (Exception e) { + throw new RuntimeException("Problem starting embedded ActiveMQ Artemis broker", e); + } + + return Collections.emptyMap(); + } + + @Override + public void stop() { + if (embeddedBroker == null) { + return; + } + + try { + embeddedBroker.stop(); + } catch (Exception e) { + throw new RuntimeException("Problem stopping embedded ActiveMQ Artemis broker", e); + } + } +} \ No newline at end of file