Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test camel.threadpool.* set of properties #2781 #2825

Merged
merged 1 commit into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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;
Expand All @@ -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)
Expand Down
101 changes: 101 additions & 0 deletions integration-test-groups/foundation/core-thread-pools/pom.xml
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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());
}
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 {
}
Original file line number Diff line number Diff line change
@@ -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"));
}

}
1 change: 1 addition & 0 deletions integration-test-groups/foundation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down