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/09 16:09:30 UTC
[camel-quarkus] branch master updated: chore(reflection): add
CamelContext and StreamCachingStrategy to the list of reflective classes
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 be7e1ff chore(reflection): add CamelContext and StreamCachingStrategy to the list of reflective classes
new 9810800 Merge pull request #193 from lburgazzoli/context-reflection
be7e1ff is described below
commit be7e1ff11a1b64853a97ad4e5604dd0b6cd748ff
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Mon Sep 9 15:11:47 2019 +0200
chore(reflection): add CamelContext and StreamCachingStrategy to the list of reflective classes
---
.../quarkus/core/deployment/SubstrateProcessor.java | 7 ++++++-
.../org/apache/camel/quarkus/core/CamelServlet.java | 17 +++++++++++++++++
.../java/org/apache/camel/quarkus/core/CamelTest.java | 15 +++++++++++++++
3 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/SubstrateProcessor.java b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/SubstrateProcessor.java
index de54556..dc8420b 100644
--- a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/SubstrateProcessor.java
+++ b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/SubstrateProcessor.java
@@ -36,6 +36,7 @@ import io.quarkus.deployment.builditem.substrate.ReflectiveMethodBuildItem;
import io.quarkus.deployment.builditem.substrate.SubstrateConfigBuildItem;
import io.quarkus.deployment.builditem.substrate.SubstrateResourceBuildItem;
import io.quarkus.deployment.builditem.substrate.SubstrateResourceBundleBuildItem;
+import org.apache.camel.CamelContext;
import org.apache.camel.Component;
import org.apache.camel.Consumer;
import org.apache.camel.Converter;
@@ -44,6 +45,7 @@ import org.apache.camel.Producer;
import org.apache.camel.TypeConverter;
import org.apache.camel.spi.ExchangeFormatter;
import org.apache.camel.spi.ScheduledPollConsumerScheduler;
+import org.apache.camel.spi.StreamCachingStrategy;
import org.jboss.jandex.AnnotationTarget.Kind;
import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.ClassInfo;
@@ -61,7 +63,10 @@ class SubstrateProcessor {
TypeConverter.class,
ExchangeFormatter.class,
ScheduledPollConsumerScheduler.class,
- Component.class);
+ Component.class,
+ CamelContext.class,
+ StreamCachingStrategy.class,
+ StreamCachingStrategy.SpoolUsedHeapMemoryLimit.class);
@Inject
BuildProducer<ReflectiveClassBuildItem> reflectiveClass;
diff --git a/integration-tests/core/test/src/main/java/org/apache/camel/quarkus/core/CamelServlet.java b/integration-tests/core/test/src/main/java/org/apache/camel/quarkus/core/CamelServlet.java
index a2b4ba2..a88916e 100644
--- a/integration-tests/core/test/src/main/java/org/apache/camel/quarkus/core/CamelServlet.java
+++ b/integration-tests/core/test/src/main/java/org/apache/camel/quarkus/core/CamelServlet.java
@@ -24,11 +24,13 @@ import javax.inject.Inject;
import javax.json.Json;
import javax.json.JsonObject;
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 org.apache.camel.ExtendedCamelContext;
import org.apache.camel.Route;
import org.apache.camel.component.log.LogComponent;
import org.apache.camel.component.timer.TimerComponent;
@@ -102,4 +104,19 @@ public class CamelServlet {
return null;
}
+
+ @Path("/context/name")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String getCamelContextName() {
+ return runtime.getContext().getName();
+ }
+
+ @Path("/context/name")
+ @POST
+ @Produces(MediaType.TEXT_PLAIN)
+ public String setCamelContextName(String name) {
+ runtime.getContext().adapt(ExtendedCamelContext.class).setName(name);
+ return runtime.getContext().getName();
+ }
}
diff --git a/integration-tests/core/test/src/test/java/org/apache/camel/quarkus/core/CamelTest.java b/integration-tests/core/test/src/test/java/org/apache/camel/quarkus/core/CamelTest.java
index 45d3324..0d26aa5 100644
--- a/integration-tests/core/test/src/test/java/org/apache/camel/quarkus/core/CamelTest.java
+++ b/integration-tests/core/test/src/test/java/org/apache/camel/quarkus/core/CamelTest.java
@@ -20,12 +20,14 @@ import java.net.HttpURLConnection;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
import io.restassured.response.Response;
import org.junit.jupiter.api.Test;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@QuarkusTest
@@ -61,4 +63,17 @@ public class CamelTest {
assertTrue(response.jsonPath().getBoolean("show-all"));
assertTrue(response.jsonPath().getBoolean("multi-line"));
}
+
+ @Test
+ public void testSetCamelContextName() {
+ Response response = RestAssured.get("/test/context/name").andReturn();
+
+ assertEquals(HttpURLConnection.HTTP_OK, response.getStatusCode());
+ assertNotEquals("my-ctx-name", response.body().asString());
+
+ RestAssured.given()
+ .contentType(ContentType.TEXT).body("my-ctx-name")
+ .post("/test/context/name")
+ .then().body(is("my-ctx-name"));
+ }
}