You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by zh...@apache.org on 2023/04/14 00:20:29 UTC

[camel-quarkus] branch main updated: Cxf fixes (#4771)

This is an automated email from the ASF dual-hosted git repository.

zhfeng 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 ad4d909524 Cxf fixes (#4771)
ad4d909524 is described below

commit ad4d90952485cb893b64f8420c498bdcca0f8a49
Author: llowinge <ll...@redhat.com>
AuthorDate: Fri Apr 14 02:20:23 2023 +0200

    Cxf fixes (#4771)
    
    * Use plain CXF endpoint (without bean) for basic server scenarios
    
    * Add negative test to CXF WS Trust
---
 .../cxf/soap/server/it/CxfSoapRoutes.java          | 32 ++++------------------
 .../cxf/soap/it/ws/trust/CxfWsTrustTest.java       | 23 ++++++++++++----
 2 files changed, 23 insertions(+), 32 deletions(-)

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 3697a535aa..f2ff811907 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
@@ -101,11 +101,13 @@ public class CxfSoapRoutes extends RouteBuilder {
                     exchange.getIn().setBody(String.format(response, requestMsg + " from Camel route"));
                 });
 
-        from("cxf:bean:echoServiceResponseFromRoute")
-                .setBody(exchange -> exchange.getMessage().getBody(String.class) + " from Camel route");
+        from(String.format("cxf:echoServiceResponseFromRoute?serviceClass=%s&address=/echo-route",
+                EchoServiceImpl.class.getName()))
+                        .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}");
+        from(String.format("cxf:echoServiceResponseFromImpl?serviceClass=%s&address=/echo-impl",
+                EchoServiceImpl.class.getName()))// no body set here; the response comes from EchoServiceImpl
+                        .log("${body}");
 
     }
 
@@ -165,26 +167,4 @@ public class CxfSoapRoutes extends RouteBuilder {
         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-ws-trust/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/CxfWsTrustTest.java b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/CxfWsTrustTest.java
index 8be99196da..288b0fa4bb 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/CxfWsTrustTest.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/CxfWsTrustTest.java
@@ -32,6 +32,7 @@ import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.ws.security.SecurityConstants;
 import org.apache.cxf.ws.security.trust.STSClient;
+import org.apache.cxf.ws.security.trust.TrustException;
 import org.assertj.core.api.Assertions;
 import org.hamcrest.CoreMatchers;
 import org.hamcrest.Matchers;
@@ -94,12 +95,7 @@ public class CxfWsTrustTest {
         try {
             BusFactory.setThreadDefaultBus(bus);
 
-            final QName serviceName = new QName("https://quarkiverse.github.io/quarkiverse-docs/quarkus-cxf/test/ws-trust",
-                    "TrustHelloService");
-            final URL wsdlURL = new URL(io.quarkiverse.cxf.test.QuarkusCxfClientTestUtil.getServerUrl()
-                    + "/soapservice/jaxws-samples-wsse-policy-trust/TrustHelloService?wsdl");
-            Service service = Service.create(wsdlURL, serviceName);
-            TrustHelloService proxy = (TrustHelloService) service.getPort(TrustHelloService.class);
+            TrustHelloService proxy = trustHelloService();
 
             final QName stsServiceName = new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "SecurityTokenService");
             final QName stsPortName = new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "UT_Port");
@@ -115,6 +111,21 @@ public class CxfWsTrustTest {
 
     }
 
+    @Test
+    public void programmaticStsNotSet() throws Exception {
+        TrustHelloService proxy = trustHelloService();
+        Assertions.assertThatThrownBy(proxy::sayHello).hasCauseInstanceOf(TrustException.class);
+    }
+
+    TrustHelloService trustHelloService() throws Exception {
+        final QName serviceName = new QName("https://quarkiverse.github.io/quarkiverse-docs/quarkus-cxf/test/ws-trust",
+                "TrustHelloService");
+        final URL wsdlURL = new URL(io.quarkiverse.cxf.test.QuarkusCxfClientTestUtil.getServerUrl()
+                + "/soapservice/jaxws-samples-wsse-policy-trust/TrustHelloService?wsdl");
+        Service service = Service.create(wsdlURL, serviceName);
+        return (TrustHelloService) service.getPort(TrustHelloService.class);
+    }
+
     public static void setupWsseAndSTSClient(TrustHelloService proxy, Bus bus, String stsWsdlLocation, QName stsService,
             QName stsPort) {
         Map<String, Object> ctx = ((BindingProvider) proxy).getRequestContext();