This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch 2.13.x in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 5e2b1ae93278415ebe0630310205a24bd5303e4b Author: Peter Palaga <[email protected]> AuthorDate: Sun Oct 30 17:31:14 2022 +0100 Test CXF service having an Implementation class in the application --- .../cxf-soap/cxf-soap-server/pom.xml | 5 ++++ .../cxf/soap/server/it/CxfSoapRoutes.java | 30 ++++++++++++++++++++++ .../component/cxf/soap/server/it/EchoService.java | 26 +++++++++++++++++++ .../cxf/soap/server/it/EchoServiceImpl.java | 29 +++++++++++++++++++++ .../cxf/soap/server/it/CxfSoapServiceTest.java | 17 ++++++++++++ 5 files changed, 107 insertions(+) diff --git a/integration-test-groups/cxf-soap/cxf-soap-server/pom.xml b/integration-test-groups/cxf-soap/cxf-soap-server/pom.xml index 48c995e08b..22059d2fca 100644 --- a/integration-test-groups/cxf-soap/cxf-soap-server/pom.xml +++ b/integration-test-groups/cxf-soap/cxf-soap-server/pom.xml @@ -97,6 +97,11 @@ <artifactId>rest-assured</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>io.quarkiverse.cxf</groupId> + <artifactId>quarkus-cxf-test-util</artifactId> + <scope>test</scope> + </dependency> </dependencies> <profiles> diff --git a/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/CxfSoapRoutes.java b/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/CxfSoapRoutes.java index f68cc39d62..200a84e42c 100644 --- a/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/CxfSoapRoutes.java +++ b/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/CxfSoapRoutes.java @@ -42,6 +42,13 @@ public class CxfSoapRoutes extends RouteBuilder { from("cxf:bean:codeFirstServiceEndpoint") .setBody().constant("Hello CamelQuarkusCXF"); + + from("cxf:bean:echoServiceResponseFromRoute") + .setBody(exchange -> exchange.getMessage().getBody(String.class) + " from Camel route"); + + from("cxf:bean:echoServiceResponseFromImpl")// no body set here; the response comes from EchoServiceImpl + .log("${body}"); + } @Produces @@ -75,4 +82,27 @@ public class CxfSoapRoutes extends RouteBuilder { result.getFeatures().add(loggingFeature); return result; } + + @Produces + @ApplicationScoped + @Named + CxfEndpoint echoServiceResponseFromRoute() { + final CxfEndpoint result = new CxfEndpoint(); + result.setServiceClass(EchoServiceImpl.class); + result.setAddress("/echo-route"); + result.getFeatures().add(loggingFeature); + return result; + } + + @Produces + @ApplicationScoped + @Named + CxfEndpoint echoServiceResponseFromImpl() { + final CxfEndpoint result = new CxfEndpoint(); + result.setServiceClass(EchoServiceImpl.class); + result.setAddress("/echo-impl"); + result.getFeatures().add(loggingFeature); + return result; + } + } diff --git a/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/EchoService.java b/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/EchoService.java new file mode 100644 index 0000000000..758d1bb174 --- /dev/null +++ b/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/EchoService.java @@ -0,0 +1,26 @@ +/* + * 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.component.cxf.soap.server.it; + +import javax.jws.WebService; + +@WebService(targetNamespace = EchoService.TARGET_NS, name = "EchoService") +public interface EchoService { + public static final String TARGET_NS = "http://it.server.soap.cxf.component.quarkus.camel.apache.org/"; + + String echo(String text); +} diff --git a/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/EchoServiceImpl.java b/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/EchoServiceImpl.java new file mode 100644 index 0000000000..e41f7d798a --- /dev/null +++ b/integration-test-groups/cxf-soap/cxf-soap-server/src/main/java/org/apache/camel/quarkus/component/cxf/soap/server/it/EchoServiceImpl.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.component.cxf.soap.server.it; + +import javax.jws.WebService; + +@WebService(name = "EchoService", serviceName = "EchoService", targetNamespace = EchoService.TARGET_NS) +public class EchoServiceImpl implements EchoService { + + @Override + public String echo(String text) { + return text; + } + +} diff --git a/integration-test-groups/cxf-soap/cxf-soap-server/src/test/java/org/apache/camel/quarkus/component/cxf/soap/server/it/CxfSoapServiceTest.java b/integration-test-groups/cxf-soap/cxf-soap-server/src/test/java/org/apache/camel/quarkus/component/cxf/soap/server/it/CxfSoapServiceTest.java index 1348caa3d6..90b91a0a10 100644 --- a/integration-test-groups/cxf-soap/cxf-soap-server/src/test/java/org/apache/camel/quarkus/component/cxf/soap/server/it/CxfSoapServiceTest.java +++ b/integration-test-groups/cxf-soap/cxf-soap-server/src/test/java/org/apache/camel/quarkus/component/cxf/soap/server/it/CxfSoapServiceTest.java @@ -20,6 +20,7 @@ import javax.xml.ws.BindingProvider; import com.helloworld.service.HelloPortType; import com.helloworld.service.HelloService; +import io.quarkiverse.cxf.test.QuarkusCxfClientTestUtil; import io.quarkus.runtime.LaunchMode; import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; @@ -69,4 +70,20 @@ class CxfSoapServiceTest { org.junit.jupiter.api.Assertions.assertTrue(response.contains("Hello CamelQuarkusCXF")); } + @Test + public void echoServiceResponseFromRoute() { + /* We setServiceClass(EchoServiceImpl.class) in org.apache.camel.quarkus.component.cxf.soap.server.it.CxfSoapRoutes.echoServiceResponseFromRoute() + * and at the same time we set the body in the associated Camel route definition. What we do in the route should have a higher prio */ + final EchoService echo = QuarkusCxfClientTestUtil.getClient(EchoService.class, "/soapservice/echo-route"); + Assertions.assertEquals("Hello there! from Camel route", echo.echo("Hello there!")); + } + + @Test + public void echoServiceResponseFromImpl() { + /* We setServiceClass(EchoServiceImpl.class) in org.apache.camel.quarkus.component.cxf.soap.server.it.CxfSoapRoutes.echoServiceResponseFromImpl() + * but we do not set the body in the associated Camel route definition. Hence the response should come from EchoServiceImpl */ + final EchoService echo = QuarkusCxfClientTestUtil.getClient(EchoService.class, "/soapservice/echo-impl"); + Assertions.assertEquals("Hello there!", echo.echo("Hello there!")); + } + }
