Skip to content

Commit

Permalink
Introduce a common set of extendable messaging tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnetherton authored and ppalaga committed Aug 11, 2021
1 parent 2a09b7b commit 01719a2
Show file tree
Hide file tree
Showing 62 changed files with 2,913 additions and 522 deletions.
22 changes: 19 additions & 3 deletions integration-tests/activemq/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@
<description>Integration tests for Camel Quarkus ActiveMQ extension</description>

<dependencies>
<!-- Messaging extension to test -->
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-activemq</artifactId>
</dependency>

<!-- Inherit base messaging routes -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-test-messaging-jms</artifactId>
</dependency>

<!-- test dependencies -->
Expand All @@ -56,6 +59,20 @@
<scope>test</scope>
</dependency>

<!-- Inherit base messaging tests -->
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-test-messaging-common</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-test-messaging-jms</artifactId>
<type>test-jar</type>
<scope>test</scope>
</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 -->
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
Expand All @@ -72,7 +89,6 @@
</dependency>
</dependencies>


<profiles>
<profile>
<id>native</id>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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.activemq.it;

import java.util.Arrays;
import java.util.Collections;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Singleton;
import javax.jms.ConnectionFactory;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.camel.quarkus.component.messaging.it.Person;
import org.apache.camel.support.DefaultExchangeHolder;
import org.eclipse.microprofile.config.inject.ConfigProperty;

@ApplicationScoped
public class ActiveMQConnectionFactoryProducer {

@ConfigProperty(name = "camel.component.activemq.broker-url")
String brokerUrl;

@Singleton
@javax.enterprise.inject.Produces
public ConnectionFactory connectionFactory() {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerUrl);
factory.setTrustedPackages(Arrays.asList(
Collections.class.getPackageName(),
DefaultExchangeHolder.class.getPackageName(),
IllegalStateException.class.getPackageName(),
Person.class.getPackageName()));
return factory;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,10 @@

import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.Test;

import static org.hamcrest.core.Is.is;
import org.apache.camel.quarkus.messaging.jms.AbstractJmsMessagingTest;

@QuarkusTest
@QuarkusTestResource(ActiveMQTestResource.class)
class ActiveMQTest {

@Test
public void testActiveMQComponent() {
String message = "Hello Camel Quarkus ActiveMQ";

RestAssured.given()
.contentType(ContentType.TEXT)
.body(message)
.post("/activemq/{queueName}", "test-queue")
.then()
.statusCode(201);
class ActiveMQTest extends AbstractJmsMessagingTest {

RestAssured.given()
.contentType(ContentType.TEXT)
.get("/activemq/{queueName}", "test-queue")
.then()
.statusCode(200)
.body(is(message));
}
}
20 changes: 18 additions & 2 deletions integration-tests/amqp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-amqp</artifactId>
</dependency>

<!-- Inherit base messaging routes -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-test-messaging-jms</artifactId>
</dependency>

<!-- test dependencies -->
Expand All @@ -56,6 +58,20 @@
<scope>test</scope>
</dependency>

<!-- Inherit base messaging tests -->
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-test-messaging-common</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-test-messaging-jms</artifactId>
<type>test-jar</type>
<scope>test</scope>
</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 -->
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,23 @@
*/
package org.apache.camel.quarkus.component.amqp.it;

import java.net.URI;

import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.jms.ConnectionFactory;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.apache.camel.ConsumerTemplate;
import org.apache.camel.ProducerTemplate;

@Path("/amqp")
public class AmqpResource {

@Inject
ProducerTemplate producerTemplate;

@Inject
ConsumerTemplate consumerTemplate;
ConnectionFactory connectionFactory;

@Path("/{queueName}")
@GET
@Path("/connection/factory")
@Produces(MediaType.TEXT_PLAIN)
public String consumeAmqpMessage(@PathParam("queueName") String queueName) {
return consumerTemplate.receiveBody("amqp:queue:" + queueName, 5000, String.class);
}

@Path("/{queueName}")
@POST
@Consumes(MediaType.TEXT_PLAIN)
public Response produceAmqpMessage(@PathParam("queueName") String queueName, String message) throws Exception {
producerTemplate.sendBody("amqp:queue:" + queueName, message);
return Response.created(new URI("https://camel.apache.org/")).build();
public String connectionFactoryImplementation() {
return connectionFactory.getClass().getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,23 @@
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.messaging.jms.AbstractJmsMessagingTest;
import org.apache.camel.quarkus.test.support.activemq.ActiveMQTestResource;
import org.junit.jupiter.api.Test;

import static org.hamcrest.core.Is.is;
import static org.hamcrest.Matchers.startsWith;

@QuarkusTest
@QuarkusTestResource(initArgs = {
@ResourceArg(name = "modules", value = "quarkus.qpid-jms")
}, value = ActiveMQTestResource.class)
class AmqpTest {
class AmqpTest extends AbstractJmsMessagingTest {

@Test
public void testAmqpComponent() {
String message = "Hello Camel Quarkus Amqp";

RestAssured.given()
.contentType(ContentType.TEXT)
.body(message)
.post("/amqp/amqp-test-queue")
.then()
.statusCode(201);

RestAssured.given()
.contentType(ContentType.TEXT)
.get("/amqp/amqp-test-queue")
public void connectionFactoryImplementation() {
RestAssured.get("/amqp/connection/factory")
.then()
.statusCode(200)
.body(is(message));
.body(startsWith("org.amqphub.quarkus.qpid.jms"));
}
}
129 changes: 129 additions & 0 deletions integration-tests/jms-artemis-client/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?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.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests</artifactId>
<version>2.2.0-SNAPSHOT</version>
</parent>

<artifactId>camel-quarkus-integration-test-jms-artemis-client</artifactId>
<name>Camel Quarkus :: Integration Tests :: JMS Artemis Client</name>
<description>Integration tests for Camel Quarkus JMS extension with the Apache ActiveMQ Artemis Client</description>

<dependencies>
<!-- Messaging extension to test -->
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-jms</artifactId>
</dependency>

<!-- Inherit base messaging routes -->
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-test-messaging-jms</artifactId>
</dependency>

<!-- The JMS client library to test with -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-artemis-jms</artifactId>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests-support-activemq</artifactId>
<scope>test</scope>
</dependency>

<!-- Inherit base messaging tests -->
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-test-messaging-common</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-test-messaging-jms</artifactId>
<type>test-jar</type>
<scope>test</scope>
</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 -->
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-jms-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

</dependencies>

<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>

0 comments on commit 01719a2

Please sign in to comment.