You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2019/09/12 05:41:42 UTC
[camel-quarkus] branch master updated: improve the paho integration
test
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push:
new d9943b2 improve the paho integration test
new 2abb646 Merge pull request #200 from zhfeng/improve-paho-tests
d9943b2 is described below
commit d9943b2f0a8893e07534fec6de1619568e08f20c
Author: Amos Feng <zf...@redhat.com>
AuthorDate: Thu Sep 12 09:40:38 2019 +0800
improve the paho integration test
---
.../quarkus/component/paho/it/PahoResource.java | 25 ++++++++++++++++----
.../component/paho/it/PahoRouteBuilder.java | 27 ----------------------
.../camel/quarkus/component/paho/it/PahoTest.java | 11 +++++++--
3 files changed, 29 insertions(+), 34 deletions(-)
diff --git a/integration-tests/paho/src/main/java/org/apache/camel/quarkus/component/paho/it/PahoResource.java b/integration-tests/paho/src/main/java/org/apache/camel/quarkus/component/paho/it/PahoResource.java
index 89324b1..a9cb51d 100644
--- a/integration-tests/paho/src/main/java/org/apache/camel/quarkus/component/paho/it/PahoResource.java
+++ b/integration-tests/paho/src/main/java/org/apache/camel/quarkus/component/paho/it/PahoResource.java
@@ -16,16 +16,19 @@
*/
package org.apache.camel.quarkus.component.paho.it;
+import org.apache.camel.ConsumerTemplate;
import org.apache.camel.ProducerTemplate;
import org.jboss.logging.Logger;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
@Path("/paho")
@ApplicationScoped
@@ -36,14 +39,26 @@ public class PahoResource {
@Inject
ProducerTemplate producerTemplate;
- @Path("/publish")
+ @Inject
+ ConsumerTemplate consumerTemplate;
+
+ @Path("/queue")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String get() {
+ final String message = consumerTemplate.receiveBody("paho:test/queue", String.class);
+ return message;
+ }
+
+ @Path("/queue")
@POST
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
- public String post(String message) throws Exception {
+ public Response publish(String message) {
LOG.infof("Sending to paho: %s", message);
- final String response = producerTemplate.requestBody("direct:paho", message, String.class);
- LOG.infof("Got response from paho: %s", response);
- return response;
+ producerTemplate.requestBody("paho:test/queue?retained=true", message, String.class);
+ LOG.infof("Sent to paho: %s", message);
+
+ return Response.ok().build();
}
}
diff --git a/integration-tests/paho/src/main/java/org/apache/camel/quarkus/component/paho/it/PahoRouteBuilder.java b/integration-tests/paho/src/main/java/org/apache/camel/quarkus/component/paho/it/PahoRouteBuilder.java
deleted file mode 100644
index 6e99ac9..0000000
--- a/integration-tests/paho/src/main/java/org/apache/camel/quarkus/component/paho/it/PahoRouteBuilder.java
+++ /dev/null
@@ -1,27 +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.paho.it;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class PahoRouteBuilder extends RouteBuilder {
- @Override
- public void configure() {
- from("direct:paho").to("paho:test/queue?autoReconnect=true");
- from("paho:test/queue").transform(body().convertToString()).to("log:paho?showAll=true");
- }
-}
diff --git a/integration-tests/paho/src/test/java/org/apache/camel/quarkus/component/paho/it/PahoTest.java b/integration-tests/paho/src/test/java/org/apache/camel/quarkus/component/paho/it/PahoTest.java
index b7c83b6..aeb0bdd 100644
--- a/integration-tests/paho/src/test/java/org/apache/camel/quarkus/component/paho/it/PahoTest.java
+++ b/integration-tests/paho/src/test/java/org/apache/camel/quarkus/component/paho/it/PahoTest.java
@@ -23,6 +23,7 @@ import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
+import io.restassured.internal.assertion.Assertion;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -33,9 +34,15 @@ class PahoTest {
@Test
public void test() {
final String msg = UUID.randomUUID().toString().replace("-", "");
- RestAssured.given() //
- .contentType(ContentType.TEXT).body(msg).post("/paho/publish") //
+
+ // publish the message to the queue
+ RestAssured.given()
+ .contentType(ContentType.TEXT).body(msg).post("/paho/queue") //
.then().statusCode(200);
+
+ // receive the message from the queue
+ String body = RestAssured.get("/paho/queue").asString();
+ Assertions.assertEquals(msg, body);
}
}