You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2022/11/16 12:27:01 UTC

[camel-quarkus] 01/04: Cover endpoint URI based CXF definitions

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 052d4b05b0a561d3ad73bec6cd756bb1b1491d19
Author: Lukas Lowinger <ll...@redhat.com>
AuthorDate: Wed Nov 9 17:54:03 2022 +0100

    Cover endpoint URI based CXF definitions
---
 .../cxf/soap/client/it/CxfSoapClientResource.java      |  5 +++--
 .../cxf/soap/client/it/CxfSoapClientRoutes.java        | 18 +++++++++++++++---
 .../cxf/soap/client/it/CxfSoapClientTest.java          |  9 ++++++---
 .../component/cxf/soap/server/it/CxfSoapRoutes.java    |  6 +++++-
 .../cxf/soap/server/it/CxfSoapServiceTest.java         |  9 ++++++---
 5 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/integration-test-groups/cxf-soap/cxf-soap-client/src/main/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientResource.java b/integration-test-groups/cxf-soap/cxf-soap-client/src/main/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientResource.java
index f56f3ee3e1..7485357953 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-client/src/main/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientResource.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-client/src/main/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientResource.java
@@ -44,8 +44,9 @@ public class CxfSoapClientResource {
     @Consumes(MediaType.WILDCARD)
     @Produces(MediaType.TEXT_PLAIN)
     public Response sendSimpleRequest(@QueryParam("a") int a,
-            @QueryParam("b") int b) throws Exception {
-        final String response = producerTemplate.requestBody("direct:simple", new int[] { a, b }, String.class);
+            @QueryParam("b") int b, @QueryParam("endpointUri") String endpointUri) throws Exception {
+        final String response = producerTemplate.requestBody(String.format("direct:%s", endpointUri), new int[] { a, b },
+                String.class);
         return Response
                 .created(new URI("https://camel.apache.org/"))
                 .entity(response)
diff --git a/integration-test-groups/cxf-soap/cxf-soap-client/src/main/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientRoutes.java b/integration-test-groups/cxf-soap/cxf-soap-client/src/main/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientRoutes.java
index b79f75575e..c2f5d97823 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-client/src/main/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientRoutes.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-client/src/main/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientRoutes.java
@@ -41,9 +41,13 @@ public class CxfSoapClientRoutes extends RouteBuilder {
     @Override
     public void configure() {
 
-        from("direct:simple")
+        from("direct:simpleUriBean")
                 .to("cxf:bean:soapClientEndpoint?dataFormat=PAYLOAD");
 
+        from("direct:simpleUriAddress")
+                .to(String.format("cxf://%s?wsdlURL=%s&dataFormat=POJO&serviceClass=%s", calculatorServiceAddress(),
+                        calculatorServiceWsdlUrl(), CalculatorService.class.getName()));
+
         from("direct:operandsAdd")
                 .setHeader(CxfConstants.OPERATION_NAME).constant("addOperands")
                 .to("cxf:bean:soapClientEndpoint?dataFormat=POJO");
@@ -64,10 +68,18 @@ public class CxfSoapClientRoutes extends RouteBuilder {
     CxfEndpoint soapClientEndpoint() {
         final CxfEndpoint result = new CxfEndpoint();
         result.setServiceClass(CalculatorService.class);
-        result.setAddress(serviceBaseUri + "/calculator-ws/CalculatorService");
-        result.setWsdlURL("wsdl/CalculatorService.wsdl");
+        result.setAddress(calculatorServiceAddress());
+        result.setWsdlURL(calculatorServiceWsdlUrl());
         result.getFeatures().add(loggingFeature);
         return result;
     }
 
+    private String calculatorServiceAddress() {
+        return serviceBaseUri + "/calculator-ws/CalculatorService";
+    }
+
+    private String calculatorServiceWsdlUrl() {
+        return "wsdl/CalculatorService.wsdl";
+    }
+
 }
diff --git a/integration-test-groups/cxf-soap/cxf-soap-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientTest.java b/integration-test-groups/cxf-soap/cxf-soap-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientTest.java
index 88f7684ee4..d5f41a787b 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientTest.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-client/src/test/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientTest.java
@@ -29,20 +29,23 @@ import io.restassured.RestAssured;
 import org.eclipse.microprofile.config.ConfigProvider;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
 
 import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
 
 @QuarkusTest
 @QuarkusTestResource(CxfClientTestResource.class)
 class CxfSoapClientTest {
 
-    @Test
-    public void simpleSoapClient() {
+    @ParameterizedTest
+    @ValueSource(strings = { "simpleUriBean", "simpleUriAddress" })
+    public void simpleSoapClient(String endpointUri) {
         //first operation is "divide"
         RestAssured.given()
                 .queryParam("a", "9")
                 .queryParam("b", "3")
+                .queryParam("endpointUri", endpointUri)
                 .post("/cxf-soap/client/simple")
                 .then()
                 .statusCode(201)
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 200a84e42c..42a515ce8b 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
@@ -40,6 +40,10 @@ public class CxfSoapRoutes extends RouteBuilder {
         from("cxf:bean:soapServiceEndpoint")
                 .setBody().simple("Hello ${body} from CXF service");
 
+        from(String.format("cxf:///hello-uri-address?wsdlURL=wsdl/HelloService.wsdl&serviceClass=%s",
+                HelloPortType.class.getName()))
+                        .setBody().simple("Hello ${body} from CXF service");
+
         from("cxf:bean:codeFirstServiceEndpoint")
                 .setBody().constant("Hello CamelQuarkusCXF");
 
@@ -66,7 +70,7 @@ public class CxfSoapRoutes extends RouteBuilder {
     CxfEndpoint soapServiceEndpoint() {
         final CxfEndpoint result = new CxfEndpoint();
         result.setServiceClass(HelloPortType.class);
-        result.setAddress("/hello");
+        result.setAddress("/hello-uri-bean");
         result.setWsdlURL("wsdl/HelloService.wsdl");
         result.getFeatures().add(loggingFeature);
         return result;
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 90b91a0a10..b397ac2446 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
@@ -29,15 +29,18 @@ import org.eclipse.microprofile.config.Config;
 import org.eclipse.microprofile.config.ConfigProvider;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
 
 @QuarkusTest
 class CxfSoapServiceTest {
 
-    @Test
-    public void simpleSoapService() {
+    @ParameterizedTest
+    @ValueSource(strings = { "uri-bean", "uri-address" })
+    public void simpleSoapService(String uriEndpoint) {
         final HelloService service = new HelloService();
         final HelloPortType helloPort = service.getHelloPort();
-        String endpointURL = getServerUrl() + "/soapservice/hello";
+        String endpointURL = getServerUrl() + "/soapservice/hello-" + uriEndpoint;
         ((BindingProvider) helloPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);
         Assertions.assertEquals(helloPort.hello("World"), "Hello World from CXF service");
     }