This is an automated email from the ASF dual-hosted git repository. aldettinger 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 34e43c6 Add route configuration test coverage for endpoint route builder #2078 34e43c6 is described below commit 34e43c6d339bdc461cd811a6a9378a8c8075dcf9 Author: aldettinger <aldettin...@gmail.com> AuthorDate: Tue Nov 16 14:30:54 2021 +0100 Add route configuration test coverage for endpoint route builder #2078 --- ...ConfigurationsEndpointConfigurationBuilder.java | 29 +++++++++++++++ .../RouteConfigurationsEndpointRouteBuilder.java | 43 ++++++++++++++++++++++ .../RouteConfigurationsResource.java | 8 ++++ .../RouteConfigurationsTest.java | 11 ++++++ 4 files changed, 91 insertions(+) diff --git a/integration-test-groups/foundation/route-configurations/src/main/java/org/apache/camel/quarkus/core/it/routeconfigurations/RouteConfigurationsEndpointConfigurationBuilder.java b/integration-test-groups/foundation/route-configurations/src/main/java/org/apache/camel/quarkus/core/it/routeconfigurations/RouteConfigurationsEndpointConfigurationBuilder.java new file mode 100644 index 0000000..65708e6 --- /dev/null +++ b/integration-test-groups/foundation/route-configurations/src/main/java/org/apache/camel/quarkus/core/it/routeconfigurations/RouteConfigurationsEndpointConfigurationBuilder.java @@ -0,0 +1,29 @@ +/* + * 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.it.routeconfigurations; + +import org.apache.camel.builder.endpoint.EndpointRouteConfigurationBuilder; + +public class RouteConfigurationsEndpointConfigurationBuilder extends EndpointRouteConfigurationBuilder { + @Override + public void configuration() { + routeConfiguration("endpointRouteConfigurationWithExplicitId") + .onException(RouteConfigurationsException.class) + .handled(true) + .setBody(constant("onException has been triggered in endpointRouteConfigurationWithExplicitId")); + } +} diff --git a/integration-test-groups/foundation/route-configurations/src/main/java/org/apache/camel/quarkus/core/it/routeconfigurations/RouteConfigurationsEndpointRouteBuilder.java b/integration-test-groups/foundation/route-configurations/src/main/java/org/apache/camel/quarkus/core/it/routeconfigurations/RouteConfigurationsEndpointRouteBuilder.java new file mode 100644 index 0000000..c96fd4b --- /dev/null +++ b/integration-test-groups/foundation/route-configurations/src/main/java/org/apache/camel/quarkus/core/it/routeconfigurations/RouteConfigurationsEndpointRouteBuilder.java @@ -0,0 +1,43 @@ +/* + * 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.it.routeconfigurations; + +import org.apache.camel.Exchange; +import org.apache.camel.Processor; +import org.apache.camel.builder.endpoint.EndpointRouteBuilder; + +public class RouteConfigurationsEndpointRouteBuilder extends EndpointRouteBuilder { + + @Override + public void configure() { + from(direct("endpointRouteConfigurationWithExplicitId")) + .routeConfigurationId("endpointRouteConfigurationWithExplicitId") + .process(new Processor() { + @Override + public void process(Exchange exchange) throws RouteConfigurationsException { + String body = exchange.getIn().getBody(String.class); + if ("explicit-endpoint-exception".equals(body)) { + String message = "Intentional exception to trigger onException in endpointRouteConfigurationWithExplicitId"; + throw new RouteConfigurationsException(message); + } + exchange.getMessage() + .setBody("onException has NOT been triggered in endpointRouteConfigurationWithExplicitId"); + } + }); + } + +} diff --git a/integration-test-groups/foundation/route-configurations/src/main/java/org/apache/camel/quarkus/core/it/routeconfigurations/RouteConfigurationsResource.java b/integration-test-groups/foundation/route-configurations/src/main/java/org/apache/camel/quarkus/core/it/routeconfigurations/RouteConfigurationsResource.java index 39e39ae..1739bcb 100644 --- a/integration-test-groups/foundation/route-configurations/src/main/java/org/apache/camel/quarkus/core/it/routeconfigurations/RouteConfigurationsResource.java +++ b/integration-test-groups/foundation/route-configurations/src/main/java/org/apache/camel/quarkus/core/it/routeconfigurations/RouteConfigurationsResource.java @@ -49,6 +49,14 @@ public class RouteConfigurationsResource { return producerTemplate.requestBody("direct:fallbackRouteConfiguration", content, String.class); } + @Path("/route-configurations/endpointRouteConfigurationWithExplicitId") + @GET + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.TEXT_PLAIN) + public String endpointRouteConfigurationWithExplicitId(String content) { + return producerTemplate.requestBody("direct:endpointRouteConfigurationWithExplicitId", content, String.class); + } + @Path("/route-configurations/xmlRoute") @GET @Produces(MediaType.TEXT_PLAIN) diff --git a/integration-test-groups/foundation/route-configurations/src/test/java/org/apache/camel/quarkus/core/it/routeconfigurations/RouteConfigurationsTest.java b/integration-test-groups/foundation/route-configurations/src/test/java/org/apache/camel/quarkus/core/it/routeconfigurations/RouteConfigurationsTest.java index 32ad5eb..de9d935 100644 --- a/integration-test-groups/foundation/route-configurations/src/test/java/org/apache/camel/quarkus/core/it/routeconfigurations/RouteConfigurationsTest.java +++ b/integration-test-groups/foundation/route-configurations/src/test/java/org/apache/camel/quarkus/core/it/routeconfigurations/RouteConfigurationsTest.java @@ -70,6 +70,17 @@ public class RouteConfigurationsTest { } @Test + public void sendExceptionContentToEndpointRouteConfigurationWithExplicitIdShouldTriggerOnException() { + String expected = "onException has been triggered in endpointRouteConfigurationWithExplicitId"; + RestAssured.given() + .body("explicit-endpoint-exception") + .when() + .get("/core/route-configurations/endpointRouteConfigurationWithExplicitId") + .then() + .body(is(expected)); + } + + @Test public void sendContentToYamlRouteShouldTriggerOnExceptionInXmlRouteConfiguration() { String expected = "onException has been triggered in xmlRouteConfiguration"; RestAssured.given()