You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2020/02/20 08:26:14 UTC
[camel-quarkus] branch master updated: chore(test): add test for
bean(class, method)
This is an automated email from the ASF dual-hosted git repository.
lburgazzoli 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 bfd8feb chore(test): add test for bean(class, method)
bfd8feb is described below
commit bfd8febdf8f5786c7c710cb57a3bd9256679a74c
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Wed Feb 19 14:27:14 2020 +0100
chore(test): add test for bean(class, method)
---
.../apache/camel/quarkus/component/bean/CamelResource.java | 8 ++++++++
.../org/apache/camel/quarkus/component/bean/CamelRoute.java | 13 +++++++++++++
.../org/apache/camel/quarkus/component/bean/BeanTest.java | 10 ++++++++++
3 files changed, 31 insertions(+)
diff --git a/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/CamelResource.java b/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/CamelResource.java
index 26b8073..666a5a0 100644
--- a/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/CamelResource.java
+++ b/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/CamelResource.java
@@ -55,6 +55,14 @@ public class CamelResource {
return template.requestBody("direct:named", statement, String.class);
}
+ @Path("/method")
+ @POST
+ @Consumes(MediaType.TEXT_PLAIN)
+ @Produces(MediaType.TEXT_PLAIN)
+ public String method(String statement) {
+ return template.requestBody("direct:method", statement, String.class);
+ }
+
@Path("/increment")
@GET
@Produces(MediaType.TEXT_PLAIN)
diff --git a/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/CamelRoute.java b/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/CamelRoute.java
index f38d327..54787a0 100644
--- a/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/CamelRoute.java
+++ b/integration-tests/bean/src/main/java/org/apache/camel/quarkus/component/bean/CamelRoute.java
@@ -67,6 +67,10 @@ public class CamelRoute extends RouteBuilder {
.to("bean:namedBean?method=hello")
.to("log:named");
+ from("direct:method")
+ .bean(MyBean.class, "sayHello")
+ .to("log:named");
+
}
@SuppressWarnings("unchecked")
@@ -145,4 +149,13 @@ public class CamelRoute extends RouteBuilder {
}
}
+ @RegisterForReflection
+ public static class MyBean {
+ /**
+ * Just return an hello message.
+ */
+ public static String sayHello(String body) {
+ return "Hello " + body + " from the MyBean";
+ }
+ }
}
diff --git a/integration-tests/bean/src/test/java/org/apache/camel/quarkus/component/bean/BeanTest.java b/integration-tests/bean/src/test/java/org/apache/camel/quarkus/component/bean/BeanTest.java
index db2394f..9d06b26 100644
--- a/integration-tests/bean/src/test/java/org/apache/camel/quarkus/component/bean/BeanTest.java
+++ b/integration-tests/bean/src/test/java/org/apache/camel/quarkus/component/bean/BeanTest.java
@@ -49,6 +49,16 @@ public class BeanTest {
}
@Test
+ public void method() {
+ RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .body("Kermit")
+ .post("/bean/method")
+ .then()
+ .body(equalTo("Hello Kermit from the MyBean"));
+ }
+
+ @Test
public void inject() {
/* Ensure that @Inject works */