This is an automated email from the ASF dual-hosted git repository.
ppalaga pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new d4026e8 Test camel.threadpool.* set of properties #2781
d4026e8 is described below
commit d4026e84697c042aad31b76faa980e8de2d54f0f
Author: aldettinger <[email protected]>
AuthorDate: Tue Jun 22 18:37:34 2021 +0200
Test camel.threadpool.* set of properties #2781
---
.../main/CamelMainNativeImageProcessor.java | 10 +-
.../foundation/core-thread-pools/pom.xml | 101 +++++++++++++++++++++
.../quarkus/core/CoreThreadPoolsResource.java | 53 +++++++++++
.../src/main/resources/application.properties | 27 ++++++
.../camel/quarkus/core/CoreThreadPoolsIT.java | 23 +++++
.../camel/quarkus/core/CoreThreadPoolsTest.java | 38 ++++++++
integration-test-groups/foundation/pom.xml | 1 +
7 files changed, 250 insertions(+), 3 deletions(-)
diff --git
a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/main/CamelMainNativeImageProcessor.java
b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/main/CamelMainNativeImageProcessor.java
index 4af3d7f..870ccc3 100644
---
a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/main/CamelMainNativeImageProcessor.java
+++
b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/main/CamelMainNativeImageProcessor.java
@@ -24,6 +24,7 @@ import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import
io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import org.apache.camel.main.ThreadPoolProfileConfigurationProperties;
import org.apache.camel.quarkus.core.deployment.main.spi.CamelMainEnabled;
import org.apache.camel.support.ResourceHelper;
import org.apache.camel.util.AntPathMatcher;
@@ -33,17 +34,20 @@ public class CamelMainNativeImageProcessor {
private static final Logger LOG =
Logger.getLogger(CamelMainNativeImageProcessor.class);
@BuildStep(onlyIf = CamelMainEnabled.class)
- ReflectiveClassBuildItem reflectiveCLasses() {
+ void reflectiveCLasses(BuildProducer<ReflectiveClassBuildItem> producer) {
// TODO: The classes below are needed to fix
https://github.com/apache/camel-quarkus/issues/1005
// but we need to investigate why it does not fail with Java 1.8
- return new ReflectiveClassBuildItem(
+ producer.produce(new ReflectiveClassBuildItem(
true,
false,
org.apache.camel.main.Resilience4jConfigurationProperties.class,
org.apache.camel.model.Resilience4jConfigurationDefinition.class,
org.apache.camel.model.Resilience4jConfigurationCommon.class,
org.apache.camel.spi.RestConfiguration.class,
- org.apache.camel.quarkus.main.CamelMainApplication.class);
+ org.apache.camel.quarkus.main.CamelMainApplication.class));
+
+ // Needed for camel.threadpool.* properties
+ producer.produce(new ReflectiveClassBuildItem(true, false,
ThreadPoolProfileConfigurationProperties.class));
}
@BuildStep(onlyIf = CamelMainEnabled.class)
diff --git a/integration-test-groups/foundation/core-thread-pools/pom.xml
b/integration-test-groups/foundation/core-thread-pools/pom.xml
new file mode 100644
index 0000000..2e52520
--- /dev/null
+++ b/integration-test-groups/foundation/core-thread-pools/pom.xml
@@ -0,0 +1,101 @@
+<?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">
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-tests-foundation</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>camel-quarkus-integration-test-core-threadpools</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: Core Thread Pools ::
Tests</name>
+ <description>The camel quarkus integration tests for camel.threadpool.*
properties</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy</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>
+
+ <!-- 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-core-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>
diff --git
a/integration-test-groups/foundation/core-thread-pools/src/main/java/org/apache/camel/quarkus/core/CoreThreadPoolsResource.java
b/integration-test-groups/foundation/core-thread-pools/src/main/java/org/apache/camel/quarkus/core/CoreThreadPoolsResource.java
new file mode 100644
index 0000000..79e369f
--- /dev/null
+++
b/integration-test-groups/foundation/core-thread-pools/src/main/java/org/apache/camel/quarkus/core/CoreThreadPoolsResource.java
@@ -0,0 +1,53 @@
+/*
+ * 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.core;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+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.CamelContext;
+import org.apache.camel.spi.ThreadPoolProfile;
+
+@Path("/core")
+@ApplicationScoped
+public class CoreThreadPoolsResource {
+
+ @Inject
+ CamelContext context;
+
+ @Path("/thread-pools/{id}")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String threadPools(@PathParam("id") String threadPoolId) {
+ ThreadPoolProfile tp;
+ if ("default".equals(threadPoolId)) {
+ tp =
context.getExecutorServiceManager().getDefaultThreadPoolProfile();
+ } else {
+ tp =
context.getExecutorServiceManager().getThreadPoolProfile(threadPoolId);
+ if (tp == null) {
+ throw new IllegalArgumentException("No thread pool profile
found for id " + threadPoolId);
+ }
+ }
+ return String.format("%s|%s|%s|%s|%s|%s", tp.getId(),
tp.isDefaultProfile(), tp.getPoolSize(), tp.getMaxPoolSize(),
+ tp.getMaxQueueSize(), tp.getRejectedPolicy());
+ }
+}
diff --git
a/integration-test-groups/foundation/core-thread-pools/src/main/resources/application.properties
b/integration-test-groups/foundation/core-thread-pools/src/main/resources/application.properties
new file mode 100644
index 0000000..0fbf082
--- /dev/null
+++
b/integration-test-groups/foundation/core-thread-pools/src/main/resources/application.properties
@@ -0,0 +1,27 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+#
+# Camel
+#
+camel.threadpool.pool-size = 5
+camel.threadpool.max-pool-size = 10
+camel.threadpool.max-queue-size = 20
+camel.threadpool.rejectedPolicy = DiscardOldest
+camel.threadpool.config[customPool].id = customPool
+camel.threadpool.config[customPool].pool-size = 1
+camel.threadpool.config[customPool].rejectedPolicy = Abort
diff --git
a/integration-test-groups/foundation/core-thread-pools/src/test/java/org/apache/camel/quarkus/core/CoreThreadPoolsIT.java
b/integration-test-groups/foundation/core-thread-pools/src/test/java/org/apache/camel/quarkus/core/CoreThreadPoolsIT.java
new file mode 100644
index 0000000..213d0dd
--- /dev/null
+++
b/integration-test-groups/foundation/core-thread-pools/src/test/java/org/apache/camel/quarkus/core/CoreThreadPoolsIT.java
@@ -0,0 +1,23 @@
+/*
+ * 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.core;
+
+import io.quarkus.test.junit.NativeImageTest;
+
+@NativeImageTest
+public class CoreThreadPoolsIT extends CoreThreadPoolsTest {
+}
diff --git
a/integration-test-groups/foundation/core-thread-pools/src/test/java/org/apache/camel/quarkus/core/CoreThreadPoolsTest.java
b/integration-test-groups/foundation/core-thread-pools/src/test/java/org/apache/camel/quarkus/core/CoreThreadPoolsTest.java
new file mode 100644
index 0000000..959bf9f
--- /dev/null
+++
b/integration-test-groups/foundation/core-thread-pools/src/test/java/org/apache/camel/quarkus/core/CoreThreadPoolsTest.java
@@ -0,0 +1,38 @@
+/*
+ * 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.core;
+
+import io.quarkus.test.junit.QuarkusTest;
+import org.junit.jupiter.api.Test;
+
+import static io.restassured.RestAssured.get;
+import static org.hamcrest.Matchers.is;
+
+@QuarkusTest
+public class CoreThreadPoolsTest {
+
+ @Test
+ public void testDefaultThreadPoolConfiguredByProperties() {
+
get("/core/thread-pools/default").then().body(is("default|true|5|10|20|DiscardOldest"));
+ }
+
+ @Test
+ public void testCustomThreadPoolsConfiguredByProperties() {
+
get("/core/thread-pools/customPool").then().body(is("customPool|false|1|10|20|Abort"));
+ }
+
+}
diff --git a/integration-test-groups/foundation/pom.xml
b/integration-test-groups/foundation/pom.xml
index c0bb2fe..a646243 100644
--- a/integration-test-groups/foundation/pom.xml
+++ b/integration-test-groups/foundation/pom.xml
@@ -39,6 +39,7 @@
<module>core</module>
<module>core-annotations</module>
<module>core-languages</module>
+ <module>core-thread-pools</module>
<module>customized-log-component</module>
<module>direct</module>
<module>log</module>