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

JiriOndrusek pushed a commit to branch camel-main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit 65bbb67bc37ab6151c88439d27a43f3caf75f387
Author: jiriOndrusek-agent <[email protected]>
AuthorDate: Tue Nov 24 15:44:09 2026 +0000

    Fixed cxf-soap, mllp test modules
    
    - cxf-soap: CAMEL-27373 added WsSecurityUsernameTokenConfigurer, which needs
      the optional cxf-rt-ws-security. Substitute its wss4j code paths in native
      mode when it is absent.
    - mllp: CAMEL-27366 producer encodes by MSH-18, so a message is no longer
      garbled. Assert a character the MSH-18 charset cannot encode instead.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 extensions/cxf-soap/runtime/pom.xml                |  5 ++
 ...curityUsernameTokenConfigurerSubstitutions.java | 67 ++++++++++++++++++++++
 .../camel/quarkus/component/mllp/it/MllpTest.java  | 14 +++--
 3 files changed, 80 insertions(+), 6 deletions(-)

diff --git a/extensions/cxf-soap/runtime/pom.xml 
b/extensions/cxf-soap/runtime/pom.xml
index 21013ee16da..4920521b467 100644
--- a/extensions/cxf-soap/runtime/pom.xml
+++ b/extensions/cxf-soap/runtime/pom.xml
@@ -52,6 +52,11 @@
             <groupId>io.quarkiverse.cxf</groupId>
             <artifactId>quarkus-cxf</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.graalvm.sdk</groupId>
+            <artifactId>nativeimage</artifactId>
+            <scope>provided</scope>
+        </dependency>
     </dependencies>
 
     <build>
diff --git 
a/extensions/cxf-soap/runtime/src/main/java/org/apache/camel/quarkus/component/cxf/soap/graal/WsSecurityUsernameTokenConfigurerSubstitutions.java
 
b/extensions/cxf-soap/runtime/src/main/java/org/apache/camel/quarkus/component/cxf/soap/graal/WsSecurityUsernameTokenConfigurerSubstitutions.java
new file mode 100644
index 00000000000..07a929a3bf1
--- /dev/null
+++ 
b/extensions/cxf-soap/runtime/src/main/java/org/apache/camel/quarkus/component/cxf/soap/graal/WsSecurityUsernameTokenConfigurerSubstitutions.java
@@ -0,0 +1,67 @@
+/*
+ * 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.graal;
+
+import java.util.function.BooleanSupplier;
+
+import javax.security.auth.callback.Callback;
+
+import com.oracle.svm.core.annotate.Substitute;
+import com.oracle.svm.core.annotate.TargetClass;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Server;
+
+/**
+ * {@code WsSecurityUsernameTokenConfigurer} needs the optional {@code 
cxf-rt-ws-security} dependency. Without it the
+ * class cannot be linked in native mode.
+ */
+@TargetClass(className = 
"org.apache.camel.component.cxf.jaxws.WsSecurityUsernameTokenConfigurer", 
onlyWith = 
WsSecurityUsernameTokenConfigurerSubstitutions.WsSecurityIsAbsent.class)
+final class WsSecurityUsernameTokenConfigurerSubstitutions {
+
+    @Substitute
+    public void configureClient(Client client) {
+        throw new IllegalStateException(WsSecurityIsAbsent.MESSAGE);
+    }
+
+    @Substitute
+    public void configureServer(Server server) {
+        throw new IllegalStateException(WsSecurityIsAbsent.MESSAGE);
+    }
+
+    static final class WsSecurityIsAbsent implements BooleanSupplier {
+        static final String MESSAGE = "The WS-Security UsernameToken options 
of the CXF endpoint require the io.quarkiverse.cxf:quarkus-cxf-rt-ws-security 
dependency";
+
+        @Override
+        public boolean getAsBoolean() {
+            try {
+                
Thread.currentThread().getContextClassLoader().loadClass("org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor");
+                return false;
+            } catch (ClassNotFoundException e) {
+                return true;
+            }
+        }
+    }
+}
+
+@TargetClass(className = 
"org.apache.camel.component.cxf.jaxws.WsSecurityUsernameTokenConfigurer$PasswordCallbackHandler",
 onlyWith = 
WsSecurityUsernameTokenConfigurerSubstitutions.WsSecurityIsAbsent.class)
+final class PasswordCallbackHandlerSubstitutions {
+
+    @Substitute
+    public void handle(Callback[] callbacks) {
+        throw new 
IllegalStateException(WsSecurityUsernameTokenConfigurerSubstitutions.WsSecurityIsAbsent.MESSAGE);
+    }
+}
diff --git 
a/integration-tests/mllp/src/test/java/org/apache/camel/quarkus/component/mllp/it/MllpTest.java
 
b/integration-tests/mllp/src/test/java/org/apache/camel/quarkus/component/mllp/it/MllpTest.java
index 339786ecbe3..806dc0d48f5 100644
--- 
a/integration-tests/mllp/src/test/java/org/apache/camel/quarkus/component/mllp/it/MllpTest.java
+++ 
b/integration-tests/mllp/src/test/java/org/apache/camel/quarkus/component/mllp/it/MllpTest.java
@@ -57,24 +57,26 @@ class MllpTest {
 
     @Test
     public void testCharsetFromMsh18() {
-        // Set up the message with a charset and some characters that it 
cannot deal with
-        String messageWithCharset = HL7_MESSAGE.replace("NE||", 
"NE||ISO-8859-1").replace("INHOUSE", "ÏNHOUSE");
+        // Set up the message with a charset and a character that it cannot 
encode
+        String messageWithCharset = HL7_MESSAGE.replace("NE||", 
"NE||ISO-8859-1").replace("INHOUSE", "ŁNHOUSE");
 
-        // Expect garbled INHOUSE text because the chosen charset cannot 
support special characters
+        // Expect a replaced character because the message is encoded in the 
MSH-18 charset
         RestAssured.given()
+                .contentType("text/plain; charset=UTF-8")
                 .body(messageWithCharset)
                 .post("/mllp/charset/msh18")
                 .then()
-                .body(containsString("Ã\u008FNHOUSE"))
+                .body(containsString("?NHOUSE"))
                 .statusCode(200);
 
         // Try again with UTF-8
-        messageWithCharset = HL7_MESSAGE.replace("NE||", 
"NE||UTF-8").replace("INHOUSE", "ÏNHOUSE");
+        messageWithCharset = HL7_MESSAGE.replace("NE||", 
"NE||UTF-8").replace("INHOUSE", "ŁNHOUSE");
         RestAssured.given()
+                .contentType("text/plain; charset=UTF-8")
                 .body(messageWithCharset)
                 .post("/mllp/charset/msh18")
                 .then()
-                .body(containsString("ÏNHOUSE"))
+                .body(containsString("ŁNHOUSE"))
                 .statusCode(200);
     }
 }

Reply via email to