This is an automated email from the ASF dual-hosted git repository.
nfilotto pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karaf.git
The following commit(s) were added to refs/heads/main by this push:
new 46c465be Ref #342: Add camel-activemq integration test (#343)
46c465be is described below
commit 46c465be3c3645f44771c86519d6db3c187d3292
Author: lopushen <[email protected]>
AuthorDate: Wed Jun 12 11:27:30 2024 +0300
Ref #342: Add camel-activemq integration test (#343)
---
tests/features/camel-activemq/pom.xml | 41 ++++++++++++++
.../main/resources/OSGI-INF/blueprint/route.xml | 62 ++++++++++++++++++++
.../karaf/camel/itest/CamelActivemqITest.java | 66 ++++++++++++++++++++++
tests/features/pom.xml | 1 +
4 files changed, 170 insertions(+)
diff --git a/tests/features/camel-activemq/pom.xml
b/tests/features/camel-activemq/pom.xml
new file mode 100644
index 00000000..b4380b7b
--- /dev/null
+++ b/tests/features/camel-activemq/pom.xml
@@ -0,0 +1,41 @@
+<?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">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.karaf</groupId>
+ <artifactId>camel-karaf-features-test</artifactId>
+ <version>4.6.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-activemq-test</artifactId>
+ <name>Apache Camel :: Karaf :: Tests :: Features :: ActiveMQ</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>activemq</artifactId>
+ <version>${testcontainers-version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git
a/tests/features/camel-activemq/src/main/resources/OSGI-INF/blueprint/route.xml
b/tests/features/camel-activemq/src/main/resources/OSGI-INF/blueprint/route.xml
new file mode 100644
index 00000000..9e8347ab
--- /dev/null
+++
b/tests/features/camel-activemq/src/main/resources/OSGI-INF/blueprint/route.xml
@@ -0,0 +1,62 @@
+<?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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
+ xsi:schemaLocation="
+ http://www.osgi.org/xmlns/blueprint/v1.0.0
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
+ http://camel.apache.org/schema/blueprint
http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
+
+ <!-- Allow the use of system properties -->
+ <ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]" />
+ <bean id="activemqConfig"
class="org.apache.camel.component.activemq.ActiveMQConfiguration">
+ <property name="connectionFactory" ref="activemqConnectionFactory"/>
+ </bean>
+
+ <bean id="activemqConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
+ <argument value="tcp://$[activemq.host]:$[activemq.port]"/>
+ <property name="watchTopicAdvisories" value="false"/>
+ <property name="userName" value="$[activemq.username]"/>
+ <property name="password" value="$[activemq.password]"/>
+ </bean>
+
+ <bean id="activemq"
class="org.apache.camel.component.activemq.ActiveMQComponent">
+ <property name="configuration" ref="activemqConfig"/>
+ </bean>
+
+ <camelContext id="camel" xmlns="http://camel.apache.org/schema/blueprint">
+ <route id="activeMqProducerRoute">
+ <from uri="direct:camel-activemq-test"/>
+ <setBody>
+ <simple>Hello Camel</simple>
+ </setBody>
+ <log message="Sending message to ActiveMQ: ${body}"/>
+ <to uri="activemq:queue:activemqQueueName"/>
+ <log message="Message sent to ActiveMQ: ${body}"/>
+ </route>
+ <route id="activeMqConsumerRoute">
+ <from uri="activemq:queue:activemqQueueName"/>
+ <log message="Message received from ActiveMQ: ${body}"/>
+ <setBody>
+ <constant>OK</constant>
+ </setBody>
+ <to uri="mock:camel-activemq-test"/>
+ </route>
+ </camelContext>
+
+</blueprint>
\ No newline at end of file
diff --git
a/tests/features/camel-activemq/src/test/java/org/apache/karaf/camel/itest/CamelActivemqITest.java
b/tests/features/camel-activemq/src/test/java/org/apache/karaf/camel/itest/CamelActivemqITest.java
new file mode 100644
index 00000000..194f5334
--- /dev/null
+++
b/tests/features/camel-activemq/src/test/java/org/apache/karaf/camel/itest/CamelActivemqITest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.apache.karaf.camel.itest;
+
+import org.apache.camel.component.mock.MockEndpoint;
+import
org.apache.karaf.camel.itests.AbstractCamelSingleFeatureResultMockBasedRouteITest;
+import org.apache.karaf.camel.itests.CamelKarafTestHint;
+import org.apache.karaf.camel.itests.GenericContainerResource;
+import org.apache.karaf.camel.itests.PaxExamWithExternalResource;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.testcontainers.activemq.ActiveMQContainer;
+
+@CamelKarafTestHint(
+ externalResourceProvider =
CamelActivemqITest.ExternalResourceProviders.class,
+ isBlueprintTest = true)
+@RunWith(PaxExamWithExternalResource.class)
+@ExamReactorStrategy(PerClass.class)
+public class CamelActivemqITest extends
AbstractCamelSingleFeatureResultMockBasedRouteITest {
+
+ @Override
+ public void configureMock(MockEndpoint mock) {
+ mock.expectedBodiesReceived("OK");
+ }
+
+ @Test
+ public void testResultMock() throws Exception {
+ assertMockEndpointsSatisfied();
+ }
+
+ public static final class ExternalResourceProviders {
+
+ public static final String ACTIVEMQ_USER = "myUser";
+ public static final String ACTIVEMQ_PASSWORD = "myPassword";
+ public static final int ACTIVEMQ_ORIGINAL_PORT = 61616;
+
+ public static GenericContainerResource<ActiveMQContainer>
createActiveMQContainer() {
+
+ ActiveMQContainer activemqContainer = new
ActiveMQContainer("apache/activemq-classic:6.1.0")
+ .withUser(ACTIVEMQ_USER)
+ .withPassword(ACTIVEMQ_PASSWORD);
+
+ return new GenericContainerResource<>(activemqContainer,
+ resource -> {
+ resource.setProperty("activemq.host",
activemqContainer.getHost());
+ resource.setProperty("activemq.port",
Integer.toString(activemqContainer.getMappedPort(ACTIVEMQ_ORIGINAL_PORT)));
+ resource.setProperty("activemq.username",
ACTIVEMQ_USER);
+ resource.setProperty("activemq.password",
ACTIVEMQ_PASSWORD);
+ }
+ );
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/features/pom.xml b/tests/features/pom.xml
index b973a4a3..c9642824 100644
--- a/tests/features/pom.xml
+++ b/tests/features/pom.xml
@@ -37,6 +37,7 @@
</properties>
<modules>
+ <module>camel-activemq</module>
<module>camel-amqp</module>
<module>camel-aws2-ses</module>
<module>camel-aws2-sns</module>