You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2020/12/17 07:37:34 UTC
[camel-kafka-connector] 01/02: Adjust the SJMS2 tests to use the
new test infra from Camel
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch camel-master
in repository https://gitbox.apache.org/repos/asf/camel-kafka-connector.git
commit 12daf826922fcdd82ff78c4e1c7a7f81f9c8bce7
Author: Otavio Rodolfo Piske <op...@redhat.com>
AuthorDate: Fri Nov 13 14:01:29 2020 +0100
Adjust the SJMS2 tests to use the new test infra from Camel
---
tests/itests-sjms2/pom.xml | 24 ++++
.../sjms2/services/ArtemisContainer.java | 142 ---------------------
.../sjms2/services/ContainerLocalService.java | 60 ---------
.../sjms2/services/JMSContainer.java | 44 -------
.../kafkaconnector/sjms2/services/JMSService.java | 60 ---------
.../sjms2/services/JMSServiceFactory.java | 48 -------
.../services/QpidDispatchRouterContainer.java | 71 -----------
.../sjms2/services/RemoteJMSService.java | 46 -------
.../sjms2/sink/CamelSinkJMSITCase.java | 21 +--
.../sjms2/source/CamelSourceJMSITCase.java | 19 ++-
.../source/CamelSourceJMSWithAggregation.java | 15 ++-
.../sjms2/services/artemis/Dockerfile | 33 -----
.../sjms2/services/qpid-dispatch-router/Dockerfile | 19 ---
13 files changed, 59 insertions(+), 543 deletions(-)
diff --git a/tests/itests-sjms2/pom.xml b/tests/itests-sjms2/pom.xml
index a07bff4..c4fcba8 100644
--- a/tests/itests-sjms2/pom.xml
+++ b/tests/itests-sjms2/pom.xml
@@ -39,6 +39,30 @@
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-infra-common</artifactId>
+ <version>${camel.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-infra-messaging-common</artifactId>
+ <version>${camel.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-infra-dispatch-router</artifactId>
+ <version>${camel.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-sjms2</artifactId>
</dependency>
diff --git a/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/services/ArtemisContainer.java b/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/services/ArtemisContainer.java
deleted file mode 100644
index dddcd66..0000000
--- a/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/services/ArtemisContainer.java
+++ /dev/null
@@ -1,142 +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.kafkaconnector.sjms2.services;
-
-import java.util.Properties;
-
-import org.testcontainers.containers.wait.strategy.Wait;
-import org.testcontainers.images.builder.ImageFromDockerfile;
-
-public class ArtemisContainer extends JMSContainer {
- private static final int DEFAULT_MQTT_PORT = 1883;
- private static final int DEFAULT_AMQP_PORT = 5672;
- private static final int DEFAULT_ADMIN_PORT = 8161;
- private static final int DEFAULT_ACCEPTOR_PORT = 61616;
-
-
- public ArtemisContainer() {
- super(new ImageFromDockerfile("apache-artemis:ckc", false)
- .withFileFromClasspath("Dockerfile",
- "org/apache/camel/kafkaconnector/sjms2/services/artemis/Dockerfile"));
-
- withExposedPorts(DEFAULT_MQTT_PORT, DEFAULT_AMQP_PORT,
- DEFAULT_ADMIN_PORT, DEFAULT_ACCEPTOR_PORT);
-
- waitingFor(Wait.forListeningPort());
- }
-
-
- /**
- * Gets the port number used for exchanging messages using the AMQP protocol
- * @return the port number
- */
- public int getAMQPPort() {
- return getMappedPort(DEFAULT_AMQP_PORT);
- }
-
-
- /**
- * Gets the end point URL used exchanging messages using the AMQP protocol (ie.: tcp://host:${amqp.port})
- * @return the end point URL as a string
- */
- public String getAMQPEndpoint() {
- return String.format("tcp://%s:%d", getContainerIpAddress(), getAMQPPort());
- }
-
-
- /**
- * Gets the port number used for exchanging messages using the MQTT protocol
- * @return the port number
- */
- public int getMQTTPort() {
- return getMappedPort(DEFAULT_MQTT_PORT);
- }
-
-
- /**
- * Gets the end point URL used exchanging messages using the MQTT protocol (ie.: tcp://host:${mqtt.port})
- * @return the end point URL as a string
- */
- public String getMQTTEndpoint() {
- return String.format("tcp://%s:%d", getContainerIpAddress(), getMQTTPort());
- }
-
-
- /**
- * Gets the port number used for accessing the web management console or the management API
- * @return the port number
- */
- public int getAdminPort() {
- return getMappedPort(DEFAULT_ADMIN_PORT);
- }
-
-
- /**
- * Gets the end point URL used for accessing the web management console or the management API
- * @return the admin URL as a string
- */
- public String getAdminURL() {
- return String.format("http://%s:%d", getContainerIpAddress(), getAdminPort());
- }
-
-
- /**
- * Gets the port number used for exchanging messages using the default acceptor port
- * @return the port number
- */
- public int getDefaultAcceptorPort() {
- return getMappedPort(DEFAULT_ACCEPTOR_PORT);
- }
-
-
- /**
- * Gets the end point URL used exchanging messages through the default acceptor port
- * @return the end point URL as a string
- */
- public String getDefaultEndpoint() {
- return String.format("tcp://%s:%d", getContainerIpAddress(), getDefaultAcceptorPort());
- }
-
-
- /**
- * Gets the port number used for exchanging messages using the Openwire protocol
- * @return the port number
- */
- public int getOpenwirePort() {
- return getDefaultAcceptorPort();
- }
-
-
- /**
- * Gets the end point URL used exchanging messages using the Openwire protocol (ie.: tcp://host:${amqp.port})
- * @return the end point URL as a string
- */
- public String getOpenwireEndpoint() {
- return String.format("tcp://%s:%d", getContainerIpAddress(), getOpenwirePort());
- }
-
- @Override
- public Properties getConnectionProperties() {
- Properties properties = new Properties();
-
- properties.put("camel.component.sjms2.connection-factory", "#class:org.apache.activemq.ActiveMQConnectionFactory");
- properties.put("camel.component.sjms2.connection-factory.brokerURL", getDefaultEndpoint());
-
- return properties;
- }
-}
diff --git a/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/services/ContainerLocalService.java b/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/services/ContainerLocalService.java
deleted file mode 100644
index 9929f41..0000000
--- a/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/services/ContainerLocalService.java
+++ /dev/null
@@ -1,60 +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.kafkaconnector.sjms2.services;
-
-import java.util.Properties;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A specialized container that can be used to create Apache Artemis broker
- * instances.
- */
-public class ContainerLocalService implements JMSService {
- private static final Logger LOG = LoggerFactory.getLogger(ContainerLocalService.class);
-
- private final JMSContainer container;
-
- public ContainerLocalService(JMSContainer container) {
- this.container = container;
- }
-
- @Override
- public Properties getConnectionProperties() {
- return container.getConnectionProperties();
- }
-
- @Override
- public String getDefaultEndpoint() {
- return container.getDefaultEndpoint();
- }
-
- @Override
- public void initialize() {
- LOG.info("Trying to start the JMS broker container");
- container.start();
- LOG.info("JMS broker running at address {}", container.getDefaultEndpoint());
- }
-
- @Override
- public void shutdown() {
- LOG.info("Stopping JMS broker container");
- container.stop();
- }
-}
diff --git a/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/services/JMSContainer.java b/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/services/JMSContainer.java
deleted file mode 100644
index 65171d9..0000000
--- a/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/services/JMSContainer.java
+++ /dev/null
@@ -1,44 +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.kafkaconnector.sjms2.services;
-
-import java.util.Properties;
-
-import org.testcontainers.containers.GenericContainer;
-import org.testcontainers.images.builder.ImageFromDockerfile;
-
-public abstract class JMSContainer extends GenericContainer<JMSContainer> {
-
-
- public JMSContainer(ImageFromDockerfile dockerfile) {
- super(dockerfile);
- }
-
- /**
- * Gets the connection properties for accessing the service
- * @return
- */
- public abstract Properties getConnectionProperties();
-
-
- /**
- * Gets the end point URL used exchanging messages through the default acceptor port
- * @return the end point URL as a string
- */
- public abstract String getDefaultEndpoint();
-}
diff --git a/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/services/JMSService.java b/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/services/JMSService.java
deleted file mode 100644
index 902562a..0000000
--- a/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/services/JMSService.java
+++ /dev/null
@@ -1,60 +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.kafkaconnector.sjms2.services;
-
-import java.util.Properties;
-
-import org.junit.jupiter.api.extension.AfterAllCallback;
-import org.junit.jupiter.api.extension.BeforeAllCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-
-public interface JMSService extends BeforeAllCallback, AfterAllCallback {
-
- /**
- * Gets the connection properties for accessing the service
- * @return
- */
- Properties getConnectionProperties();
-
- /**
- * Gets the default endpoint for the JMS service (ie.: amqp://host:port, or tcp://host:port, etc)
- * @return the endpoint URL as a string in the specific format used by the service
- */
- String getDefaultEndpoint();
-
- /**
- * Perform any initialization necessary
- */
- void initialize();
-
- /**
- * Shuts down the service after the test has completed
- */
- void shutdown();
-
-
- @Override
- default void beforeAll(ExtensionContext extensionContext) throws Exception {
- initialize();
- }
-
- @Override
- default void afterAll(ExtensionContext extensionContext) throws Exception {
- shutdown();
- }
-}
diff --git a/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/services/JMSServiceFactory.java b/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/services/JMSServiceFactory.java
deleted file mode 100644
index 572374a..0000000
--- a/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/services/JMSServiceFactory.java
+++ /dev/null
@@ -1,48 +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.kafkaconnector.sjms2.services;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class JMSServiceFactory {
- private static final Logger LOG = LoggerFactory.getLogger(JMSServiceFactory.class);
-
- private JMSServiceFactory() {
- }
-
- public static JMSService createService() {
- String jmsInstanceType = System.getProperty("jms-service.instance.type");
-
- if (jmsInstanceType == null || jmsInstanceType.equals("local-dispatch-router-container")) {
- return new ContainerLocalService(new QpidDispatchRouterContainer());
- }
-
- if (jmsInstanceType.equals("local-artemis-container")) {
- return new ContainerLocalService(new ArtemisContainer());
- }
-
- if (jmsInstanceType.equals("remote")) {
- return new RemoteJMSService();
- }
-
- LOG.error("Invalid JMS instance type: {}. Must be one of 'remote', 'local-artemis-container' or 'local-dispatch-router-container",
- jmsInstanceType);
- throw new UnsupportedOperationException("Invalid JMS instance type");
- }
-}
diff --git a/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/services/QpidDispatchRouterContainer.java b/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/services/QpidDispatchRouterContainer.java
deleted file mode 100644
index 83f6175..0000000
--- a/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/services/QpidDispatchRouterContainer.java
+++ /dev/null
@@ -1,71 +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.kafkaconnector.sjms2.services;
-
-import java.util.Properties;
-
-import org.testcontainers.containers.wait.strategy.Wait;
-import org.testcontainers.images.builder.ImageFromDockerfile;
-
-public class QpidDispatchRouterContainer extends JMSContainer {
- private static final int DEFAULT_AMQP_PORT = 5672;
-
-
- public QpidDispatchRouterContainer() {
- super(new ImageFromDockerfile("qpid-dispatch:ckc", false)
- .withFileFromClasspath("Dockerfile",
- "org/apache/camel/kafkaconnector/sjms2/services/qpid-dispatch-router/Dockerfile"));
-
- withExposedPorts(DEFAULT_AMQP_PORT);
-
- waitingFor(Wait.forListeningPort());
- }
-
-
- /**
- * Gets the port number used for exchanging messages using the AMQP protocol
- * @return the port number
- */
- public int getAMQPPort() {
- return getMappedPort(DEFAULT_AMQP_PORT);
- }
-
-
- /**
- * Gets the end point URL used exchanging messages using the AMQP protocol (ie.: tcp://host:${amqp.port})
- * @return the end point URL as a string
- */
- public String getAMQPEndpoint() {
- return String.format("amqp://%s:%d", getContainerIpAddress(), getAMQPPort());
- }
-
- @Override
- public String getDefaultEndpoint() {
- return getAMQPEndpoint();
- }
-
- @Override
- public Properties getConnectionProperties() {
- Properties properties = new Properties();
-
- properties.put("camel.component.sjms2.connection-factory", "#class:org.apache.qpid.jms.JmsConnectionFactory");
- properties.put("camel.component.sjms2.connection-factory.remoteURI", getDefaultEndpoint());
-
- return properties;
- }
-}
diff --git a/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/services/RemoteJMSService.java b/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/services/RemoteJMSService.java
deleted file mode 100644
index 6779f98..0000000
--- a/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/services/RemoteJMSService.java
+++ /dev/null
@@ -1,46 +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.kafkaconnector.sjms2.services;
-
-import java.util.Properties;
-
-import org.apache.camel.kafkaconnector.common.utils.PropertyUtils;
-
-public class RemoteJMSService implements JMSService {
-
-
- @Override
- public void initialize() {
- // NO-OP
- }
-
- @Override
- public void shutdown() {
- // NO-OP
- }
-
- @Override
- public Properties getConnectionProperties() {
- return PropertyUtils.getProperties();
- }
-
- @Override
- public String getDefaultEndpoint() {
- return System.getProperty("jms.broker.address");
- }
-}
diff --git a/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/sink/CamelSinkJMSITCase.java b/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/sink/CamelSinkJMSITCase.java
index 36b50f2..1b1054f 100644
--- a/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/sink/CamelSinkJMSITCase.java
+++ b/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/sink/CamelSinkJMSITCase.java
@@ -33,8 +33,9 @@ import org.apache.camel.kafkaconnector.common.clients.kafka.KafkaClient;
import org.apache.camel.kafkaconnector.common.utils.TestUtils;
import org.apache.camel.kafkaconnector.sjms2.clients.JMSClient;
import org.apache.camel.kafkaconnector.sjms2.common.SJMS2Common;
-import org.apache.camel.kafkaconnector.sjms2.services.JMSService;
-import org.apache.camel.kafkaconnector.sjms2.services.JMSServiceFactory;
+import org.apache.camel.test.infra.dispatch.router.services.DispatchRouterContainer;
+import org.apache.camel.test.infra.messaging.services.MessagingService;
+import org.apache.camel.test.infra.messaging.services.MessagingServiceBuilder;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
@@ -43,8 +44,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.junit.jupiter.Testcontainers;
-import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Integration tests for the JMS sink
@@ -52,7 +53,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
@Testcontainers
public class CamelSinkJMSITCase extends AbstractKafkaTest {
@RegisterExtension
- public static JMSService jmsService = JMSServiceFactory.createService();
+ public static MessagingService jmsService = MessagingServiceBuilder
+ .newBuilder(DispatchRouterContainer::new)
+ .withEndpointProvider(DispatchRouterContainer::defaultEndpoint)
+ .withPropertiesProvider(DispatchRouterContainer::connectionProperties)
+ .build();
private static final Logger LOG = LoggerFactory.getLogger(CamelSinkJMSITCase.class);
@@ -66,7 +71,7 @@ public class CamelSinkJMSITCase extends AbstractKafkaTest {
@BeforeEach
public void setUp() {
- LOG.info("JMS service running at {}", jmsService.getDefaultEndpoint());
+ LOG.info("JMS service running at {}", jmsService.defaultEndpoint());
received = 0;
}
@@ -124,7 +129,7 @@ public class CamelSinkJMSITCase extends AbstractKafkaTest {
ConnectorPropertyFactory connectorPropertyFactory = CamelJMSPropertyFactory
.basic()
.withTopics(TestUtils.getDefaultTestTopic(this.getClass()))
- .withConnectionProperties(jmsService.getConnectionProperties())
+ .withConnectionProperties(jmsService.connectionProperties())
.withDestinationName(SJMS2Common.DEFAULT_JMS_QUEUE);
runTest(connectorPropertyFactory);
@@ -142,7 +147,7 @@ public class CamelSinkJMSITCase extends AbstractKafkaTest {
ConnectorPropertyFactory connectorPropertyFactory = CamelJMSPropertyFactory
.basic()
.withTopics(TestUtils.getDefaultTestTopic(this.getClass()))
- .withConnectionProperties(jmsService.getConnectionProperties())
+ .withConnectionProperties(jmsService.connectionProperties())
.withUrl(SJMS2Common.DEFAULT_JMS_QUEUE)
.buildUrl();
@@ -158,7 +163,7 @@ public class CamelSinkJMSITCase extends AbstractKafkaTest {
JMSClient jmsClient = null;
try {
- jmsClient = JMSClient.newClient(jmsService.getDefaultEndpoint());
+ jmsClient = JMSClient.newClient(jmsService.defaultEndpoint());
jmsClient.start();
diff --git a/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/source/CamelSourceJMSITCase.java b/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/source/CamelSourceJMSITCase.java
index c5564ce..7f0f5c4 100644
--- a/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/source/CamelSourceJMSITCase.java
+++ b/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/source/CamelSourceJMSITCase.java
@@ -25,8 +25,9 @@ import org.apache.camel.kafkaconnector.common.clients.kafka.KafkaClient;
import org.apache.camel.kafkaconnector.common.utils.TestUtils;
import org.apache.camel.kafkaconnector.sjms2.clients.JMSClient;
import org.apache.camel.kafkaconnector.sjms2.common.SJMS2Common;
-import org.apache.camel.kafkaconnector.sjms2.services.JMSService;
-import org.apache.camel.kafkaconnector.sjms2.services.JMSServiceFactory;
+import org.apache.camel.test.infra.dispatch.router.services.DispatchRouterContainer;
+import org.apache.camel.test.infra.messaging.services.MessagingService;
+import org.apache.camel.test.infra.messaging.services.MessagingServiceBuilder;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -47,7 +48,11 @@ import static org.junit.jupiter.api.Assertions.fail;
@Testcontainers
public class CamelSourceJMSITCase extends AbstractKafkaTest {
@RegisterExtension
- public static JMSService jmsService = JMSServiceFactory.createService();
+ public static MessagingService jmsService = MessagingServiceBuilder
+ .newBuilder(DispatchRouterContainer::new)
+ .withPropertiesProvider(DispatchRouterContainer::connectionProperties)
+ .withEndpointProvider(DispatchRouterContainer::defaultEndpoint)
+ .build();
private static final Logger LOG = LoggerFactory.getLogger(CamelSourceJMSITCase.class);
@@ -63,7 +68,7 @@ public class CamelSourceJMSITCase extends AbstractKafkaTest {
@BeforeEach
public void setUp() {
received = 0;
- jmsClient = JMSClient.newClient(jmsService.getDefaultEndpoint());
+ jmsClient = JMSClient.newClient(jmsService.defaultEndpoint());
}
private <T> boolean checkRecord(ConsumerRecord<String, T> record) {
@@ -101,7 +106,7 @@ public class CamelSourceJMSITCase extends AbstractKafkaTest {
.basic()
.withKafkaTopic(TestUtils.getDefaultTestTopic(this.getClass()))
.withDestinationName(SJMS2Common.DEFAULT_JMS_QUEUE)
- .withConnectionProperties(jmsService.getConnectionProperties());
+ .withConnectionProperties(jmsService.connectionProperties());
runBasicStringTest(connectorPropertyFactory);
} catch (Exception e) {
@@ -116,7 +121,7 @@ public class CamelSourceJMSITCase extends AbstractKafkaTest {
try {
ConnectorPropertyFactory connectorPropertyFactory = CamelJMSPropertyFactory
.basic()
- .withConnectionProperties(jmsService.getConnectionProperties())
+ .withConnectionProperties(jmsService.connectionProperties())
.withKafkaTopic(TestUtils.getDefaultTestTopic(this.getClass()))
.withUrl(SJMS2Common.DEFAULT_JMS_QUEUE)
.buildUrl();
@@ -139,7 +144,7 @@ public class CamelSourceJMSITCase extends AbstractKafkaTest {
.basic()
.withKafkaTopic(TestUtils.getDefaultTestTopic(this.getClass()) + jmsQueueName)
.withDestinationName(jmsQueueName)
- .withConnectionProperties(jmsService.getConnectionProperties());
+ .withConnectionProperties(jmsService.connectionProperties());
connectorPropertyFactory.log();
getKafkaConnectService().initializeConnector(connectorPropertyFactory);
diff --git a/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/source/CamelSourceJMSWithAggregation.java b/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/source/CamelSourceJMSWithAggregation.java
index 187b25c..0a66154 100644
--- a/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/source/CamelSourceJMSWithAggregation.java
+++ b/tests/itests-sjms2/src/test/java/org/apache/camel/kafkaconnector/sjms2/source/CamelSourceJMSWithAggregation.java
@@ -25,8 +25,9 @@ import org.apache.camel.kafkaconnector.common.clients.kafka.KafkaClient;
import org.apache.camel.kafkaconnector.common.utils.TestUtils;
import org.apache.camel.kafkaconnector.sjms2.clients.JMSClient;
import org.apache.camel.kafkaconnector.sjms2.common.SJMS2Common;
-import org.apache.camel.kafkaconnector.sjms2.services.JMSService;
-import org.apache.camel.kafkaconnector.sjms2.services.JMSServiceFactory;
+import org.apache.camel.test.infra.dispatch.router.services.DispatchRouterContainer;
+import org.apache.camel.test.infra.messaging.services.MessagingService;
+import org.apache.camel.test.infra.messaging.services.MessagingServiceBuilder;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -40,7 +41,11 @@ import static org.junit.jupiter.api.Assertions.fail;
public class CamelSourceJMSWithAggregation extends AbstractKafkaTest {
@RegisterExtension
- public static JMSService jmsService = JMSServiceFactory.createService();
+ public static MessagingService jmsService = MessagingServiceBuilder
+ .newBuilder(DispatchRouterContainer::new)
+ .withPropertiesProvider(DispatchRouterContainer::connectionProperties)
+ .withEndpointProvider(DispatchRouterContainer::defaultEndpoint)
+ .build();
private static final Logger LOG = LoggerFactory.getLogger(CamelSourceJMSITCase.class);
@@ -61,7 +66,7 @@ public class CamelSourceJMSWithAggregation extends AbstractKafkaTest {
@BeforeEach
public void setUp() {
received = 0;
- jmsClient = JMSClient.newClient(jmsService.getDefaultEndpoint());
+ jmsClient = JMSClient.newClient(jmsService.defaultEndpoint());
for (int i = 0; i < sentSize - 1; i++) {
expectedMessage += "hello;\n";
@@ -107,7 +112,7 @@ public class CamelSourceJMSWithAggregation extends AbstractKafkaTest {
.basic()
.withKafkaTopic(TestUtils.getDefaultTestTopic(this.getClass()))
.withDestinationName(queueName)
- .withConnectionProperties(jmsService.getConnectionProperties())
+ .withConnectionProperties(jmsService.connectionProperties())
.withAggregate("org.apache.camel.kafkaconnector.aggregator.StringAggregator", sentSize,
1000);
diff --git a/tests/itests-sjms2/src/test/resources/org/apache/camel/kafkaconnector/sjms2/services/artemis/Dockerfile b/tests/itests-sjms2/src/test/resources/org/apache/camel/kafkaconnector/sjms2/services/artemis/Dockerfile
deleted file mode 100644
index 1cfd66e..0000000
--- a/tests/itests-sjms2/src/test/resources/org/apache/camel/kafkaconnector/sjms2/services/artemis/Dockerfile
+++ /dev/null
@@ -1,33 +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.
-FROM centos:8 as artemis-base
-MAINTAINER Otavio Rodolfo Piske <an...@gmail.com>
-ARG ARTEMIS_VERSION
-ENV ARTEMIS_VERSION ${ARTEMIS_VERSION:-2.7.0}
-ARG ARTEMIS_JOURNAL
-ENV ARTEMIS_JOURNAL ${ARTEMIS_JOURNAL:-aio}
-ENV JMS_BROKER_ROOT /opt/camel-kafka-connector/artemis/
-EXPOSE 1883 5672 8161 61616
-RUN dnf install -y java-1.8.0-openjdk-headless libaio tar gzip && dnf clean all
-ENV JAVA_HOME /etc/alternatives/jre
-RUN mkdir -p ${JMS_BROKER_ROOT}
-WORKDIR ${JMS_BROKER_ROOT}
-RUN curl https://archive.apache.org/dist/activemq/activemq-artemis/${ARTEMIS_VERSION}/apache-artemis-${ARTEMIS_VERSION}-bin.tar.gz -o apache-artemis.tar.gz && \
- mkdir -p apache-artemis && tar --strip-components=1 -xvf apache-artemis.tar.gz -C apache-artemis && \
- rm -f apache-artemis.tar.gz
-
-FROM artemis-base as artemis
-RUN ${JMS_BROKER_ROOT}/apache-artemis/bin/artemis create --${ARTEMIS_JOURNAL} --relax-jolokia --allow-anonymous --http-host 0.0.0.0 --user admin --password "admin" --role amq --data /artemis-storage ${JMS_BROKER_ROOT}/apache-artemis-instance
-CMD [ "sh", "-c", "./apache-artemis-instance/bin/artemis run" ]
\ No newline at end of file
diff --git a/tests/itests-sjms2/src/test/resources/org/apache/camel/kafkaconnector/sjms2/services/qpid-dispatch-router/Dockerfile b/tests/itests-sjms2/src/test/resources/org/apache/camel/kafkaconnector/sjms2/services/qpid-dispatch-router/Dockerfile
deleted file mode 100644
index 5f55073..0000000
--- a/tests/itests-sjms2/src/test/resources/org/apache/camel/kafkaconnector/sjms2/services/qpid-dispatch-router/Dockerfile
+++ /dev/null
@@ -1,19 +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.
-FROM fedora:31
-MAINTAINER Otavio Rodolfo Piske <an...@gmail.com>
-EXPOSE 5672
-RUN dnf install -y qpid-dispatch-router
-CMD [ "sh", "-c", "/usr/sbin/qdrouterd" ]
\ No newline at end of file