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

ffang pushed a commit to branch 4.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/4.1.x-fixes by this push:
     new 56f1705256 [CXF-9196]Introduce a property to configure http-undertow 
transport m… (#2861)
56f1705256 is described below

commit 56f1705256660b5d9aa7af3d9b31cc44d710a45c
Author: Freeman(Yue) Fang <[email protected]>
AuthorDate: Thu Feb 5 09:27:47 2026 -0500

    [CXF-9196]Introduce a property to configure http-undertow transport m… 
(#2861)
    
    * [CXF-9196]Introduce a property to configure http-undertow transport 
maximum attachment size
    
    * [CXF-9196]reuse AttachmentDeserializer.ATTACHMENT_MAX_SIZE
    
    (cherry picked from commit 68472a4bc7509ec018a987a60740658e30240cdb)
---
 .../http_undertow/UndertowHTTPServerEngine.java    |  27 ++++
 systests/transport-undertow/pom.xml                |   5 +
 .../multipart/ClientServerSwaTest.java             | 166 +++++++++++++++++++++
 .../systest/http_undertow/multipart/Server.java    |  63 ++++++++
 .../multipart/SwANoMimeServiceImpl.java            | 121 +++++++++++++++
 .../http_undertow/multipart/SwAServiceImpl.java    | 149 ++++++++++++++++++
 .../http_undertow/multipart/resources/attach.gif   | Bin 0 -> 416 bytes
 .../http_undertow/multipart/resources/attach.html  |  31 ++++
 .../http_undertow/multipart/resources/attach.jpeg1 | Bin 0 -> 2967 bytes
 .../http_undertow/multipart/resources/attach.jpeg2 | Bin 0 -> 2967 bytes
 .../http_undertow/multipart/resources/attach.text  |  18 +++
 .../http_undertow/multipart/resources/attach.xml   |  20 +++
 12 files changed, 600 insertions(+)

diff --git 
a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/UndertowHTTPServerEngine.java
 
b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/UndertowHTTPServerEngine.java
index 83eea18873..9e5ad7e492 100644
--- 
a/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/UndertowHTTPServerEngine.java
+++ 
b/rt/transports/http-undertow/src/main/java/org/apache/cxf/transport/http_undertow/UndertowHTTPServerEngine.java
@@ -36,6 +36,7 @@ import javax.net.ssl.X509KeyManager;
 import jakarta.servlet.ServletContext;
 import jakarta.servlet.ServletException;
 import org.apache.cxf.Bus;
+import org.apache.cxf.attachment.AttachmentDeserializer;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PropertyUtils;
@@ -80,6 +81,7 @@ public class UndertowHTTPServerEngine implements 
ServerEngine, HttpServerEngineS
     public static final String ENABLE_RECORD_REQUEST_START_TIME_PROP = 
         "org.apache.cxf.transports.http_undertow.EnableRecordRequestStartTime";
 
+    
     private static final Logger LOG = 
LogUtils.getL7dLogger(UndertowHTTPServerEngine.class);
 
     /**
@@ -228,6 +230,7 @@ public class UndertowHTTPServerEngine implements 
ServerEngine, HttpServerEngineS
     private Undertow createServer(URL url, UndertowHTTPHandler 
undertowHTTPHandler) throws Exception {
         Undertow.Builder result = Undertow.builder();
         result.setServerOption(UndertowOptions.IDLE_TIMEOUT, getMaxIdleTime());
+        result.setServerOption(UndertowOptions.MAX_ENTITY_SIZE, 
getMaxEntitySize(undertowHTTPHandler.getBus()));
         if (this.isHttp2Enabled(undertowHTTPHandler.getBus())) {
             result.setServerOption(UndertowOptions.ENABLE_HTTP2, Boolean.TRUE);
         }
@@ -601,7 +604,31 @@ public class UndertowHTTPServerEngine implements 
ServerEngine, HttpServerEngineS
         this.maxIdleTime = maxIdleTime;
     }
 
+    private long getMaxEntitySize(Bus bus) {
+        Object prop = null;
+        if (bus != null) {
+            prop = bus.getProperty(AttachmentDeserializer.ATTACHMENT_MAX_SIZE);
+        }
+        if (prop == null) {
+            prop = 
SystemPropertyAction.getPropertyOrNull(AttachmentDeserializer.ATTACHMENT_MAX_SIZE);
+        }
+        //default value is 2MB from Undertow
+        return convertToLong(prop, 2097152);
+    }
 
+    private long convertToLong(Object prop, long defaultValue) {
+        if (prop instanceof Number) {
+            return ((Number) prop).longValue();
+        }
+        if (prop instanceof String) {
+            try {
+                return Long.parseLong((String) prop);
+            } catch (NumberFormatException e) {
+                return defaultValue;
+            }
+        }
+        return defaultValue;
+    }
     /**
      * set the Undertow server's handlers
      * @param h
diff --git a/systests/transport-undertow/pom.xml 
b/systests/transport-undertow/pom.xml
index dcf346f83d..fd0558ff4a 100644
--- a/systests/transport-undertow/pom.xml
+++ b/systests/transport-undertow/pom.xml
@@ -244,5 +244,10 @@
             <artifactId>cxf-rt-transports-http-hc5</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>com.sun.xml.messaging.saaj</groupId>
+            <artifactId>saaj-impl</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 </project>
diff --git 
a/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/ClientServerSwaTest.java
 
b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/ClientServerSwaTest.java
new file mode 100644
index 0000000000..ab5c7af190
--- /dev/null
+++ 
b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/ClientServerSwaTest.java
@@ -0,0 +1,166 @@
+/**
+ * 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.cxf.systest.http_undertow.multipart;
+
+import java.io.StringWriter;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import jakarta.activation.DataHandler;
+import jakarta.mail.util.ByteArrayDataSource;
+import jakarta.xml.soap.AttachmentPart;
+import jakarta.xml.soap.MessageFactory;
+import jakarta.xml.soap.SOAPBody;
+import jakarta.xml.soap.SOAPMessage;
+import jakarta.xml.ws.Dispatch;
+import jakarta.xml.ws.Service;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.swa.SwAService;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.testutil.common.TestUtil;
+import org.springframework.util.Assert;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(value = Parameterized.class)
+public class ClientServerSwaTest extends AbstractBusClientServerTestBase {
+    static String serverPort = TestUtil.getPortNumber(Server.class);
+    static String serverPortInvalid = TestUtil.getPortNumber(Server.class, 1);
+    
+    static class TestParam {
+        private final String port;
+        private final String exMessage;
+        TestParam(String port, String ex) {
+            this.port = port;
+            this.exMessage = ex;          
+        }
+        String getPort() {
+            return port;
+        }
+        String getExceptionMessage() {
+            return exMessage;
+        }     
+    }
+    
+    final TestParam test;
+    public ClientServerSwaTest(TestParam test) {
+        this.test = test;
+    }
+
+    @Parameterized.Parameters
+    public static Collection<TestParam> data() {
+        List<TestParam> parameters = new ArrayList<>();
+        parameters.add(new TestParam(serverPort, null));
+        parameters.add(new TestParam(serverPortInvalid, 
"java.net.ConnectException"));
+        parameters.add(new TestParam(serverPort + "/INVALID", "404: Not 
Found"));
+        return parameters;
+    }
+    
+    @BeforeClass
+    public static void startServers() throws Exception {
+        assertTrue("server did not launch correctly", 
launchServer(Server.class, true));
+    }
+
+    private String getFullStackTrace(Exception ex) {
+        StringWriter sw = new StringWriter();
+        ex.printStackTrace(new java.io.PrintWriter(sw));
+        return sw.toString();
+    }
+    
+    
+    @Test
+    public void testSwaTypesWithDispatchAPI() throws Exception {
+        URL url1 = this.getClass().getResource("resources/attach.text");
+        URL url2 = this.getClass().getResource("resources/attach.html");
+        URL url3 = this.getClass().getResource("resources/attach.xml");
+        URL url4 = this.getClass().getResource("resources/attach.jpeg1");
+        URL url5 = this.getClass().getResource("resources/attach.jpeg2");
+
+
+        int copyCount = 10000;
+        byte[] bytes = IOUtils.readBytesFromStream(url1.openStream());
+        byte[] bigBytes = new byte[bytes.length * copyCount];
+        for (int x = 0; x < copyCount; x++) {
+            System.arraycopy(bytes, 0, bigBytes, x * bytes.length, 
bytes.length);
+        }
+
+        DataHandler dh1 = new DataHandler(new ByteArrayDataSource(bigBytes, 
"text/plain"));
+        DataHandler dh2 = new DataHandler(url2);
+        DataHandler dh3 = new DataHandler(url3);
+        DataHandler dh4 = new DataHandler(url4);
+        DataHandler dh5 = new DataHandler(url5);
+
+        SwAService service = new SwAService();
+
+        Dispatch<SOAPMessage> disp = service
+            .createDispatch(SwAService.SwAServiceHttpPort,
+                            SOAPMessage.class,
+                            Service.Mode.MESSAGE);
+        setAddress(disp, "http://localhost:"; + test.getPort() + "/swa");
+
+
+        SOAPMessage msg = MessageFactory.newInstance().createMessage();
+        SOAPBody body = msg.getSOAPPart().getEnvelope().getBody();
+        body.addBodyElement(new QName("http://cxf.apache.org/swa/types";,
+                                      "VoidRequest"));
+
+        AttachmentPart att = msg.createAttachmentPart(dh1);
+        
att.setContentId("<[email protected]>");
+        msg.addAttachmentPart(att);
+
+        att = msg.createAttachmentPart(dh2);
+        
att.setContentId("<[email protected]>");
+        msg.addAttachmentPart(att);
+
+        att = msg.createAttachmentPart(dh3);
+        
att.setContentId("<[email protected]>");
+        msg.addAttachmentPart(att);
+
+        att = msg.createAttachmentPart(dh4);
+        
att.setContentId("<[email protected]>");
+        msg.addAttachmentPart(att);
+
+        att = msg.createAttachmentPart(dh5);
+        
att.setContentId("<[email protected]>");
+        msg.addAttachmentPart(att);
+
+        //Test for CXF-
+        try {
+            msg = disp.invoke(msg);
+            assertEquals(5, msg.countAttachments());
+        } catch  (Exception ex) {
+            if (test.getExceptionMessage() != null) {
+                Assert.hasText(getFullStackTrace(ex), 
test.getExceptionMessage());
+                return;
+            }
+            throw ex;
+        }            
+
+    }
+}
diff --git 
a/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/Server.java
 
b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/Server.java
new file mode 100644
index 0000000000..4dfa45c0bd
--- /dev/null
+++ 
b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/Server.java
@@ -0,0 +1,63 @@
+/**
+ * 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.cxf.systest.http_undertow.multipart;
+
+import jakarta.xml.ws.Endpoint;
+import org.apache.cxf.attachment.AttachmentDeserializer;
+import org.apache.cxf.jaxws.EndpointImpl;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.testutil.common.TestUtil;
+
+public class Server extends AbstractBusTestServerBase {
+
+    protected void run() {
+        String port = TestUtil.getPortNumber(Server.class);
+
+        Object implementor = new SwAServiceImpl();
+        String address = "http://localhost:"; + port + "/swa";
+        EndpointImpl ep;
+        try {
+            System.setProperty(AttachmentDeserializer.ATTACHMENT_MAX_SIZE, 
"-1");
+            ep = (EndpointImpl) Endpoint.create(new SwANoMimeServiceImpl());
+            ep.setWsdlLocation("classpath:wsdl/swa-mime-nomime.wsdl");
+            ep.publish(address + "-nomime");
+
+
+            ep = (EndpointImpl) Endpoint.create(implementor);
+            ep.setWsdlLocation("classpath:wsdl/swa-mime.wsdl");
+            ep.publish(address);
+        } catch (Exception e) {
+            e.printStackTrace();
+            Thread.currentThread().interrupt();
+        }
+    }
+
+    public static void main(String[] args) {
+        try {
+            Server s = new Server();
+            s.start();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(-1);
+        } finally {
+            System.out.println("done!");
+        }
+    }
+}
diff --git 
a/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/SwANoMimeServiceImpl.java
 
b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/SwANoMimeServiceImpl.java
new file mode 100644
index 0000000000..751925340e
--- /dev/null
+++ 
b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/SwANoMimeServiceImpl.java
@@ -0,0 +1,121 @@
+/**
+ * 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.cxf.systest.http_undertow.multipart;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+
+import jakarta.activation.DataHandler;
+import jakarta.jws.WebService;
+import jakarta.mail.util.ByteArrayDataSource;
+import jakarta.xml.ws.Holder;
+import jakarta.xml.ws.WebServiceException;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.swa_nomime.SwAServiceInterface;
+import org.apache.cxf.swa_nomime.types.DataStruct;
+import org.apache.cxf.swa_nomime.types.OutputResponseAll;
+import org.apache.cxf.swa_nomime.types.VoidRequest;
+
+
+@WebService(endpointInterface = 
"org.apache.cxf.swa_nomime.SwAServiceInterface",
+            serviceName = "SwAService",
+            targetNamespace = "http://cxf.apache.org/swa-nomime";,
+            portName = "SwAServiceHttpPort")
+public class SwANoMimeServiceImpl implements SwAServiceInterface {
+
+    public OutputResponseAll echoAllAttachmentTypes(VoidRequest request, 
Holder<String> attach1,
+                                                    Holder<String> attach2, 
Holder<String> attach3,
+                                                    Holder<byte[]> attach4, 
Holder<byte[]> attach5) {
+        try {
+            OutputResponseAll theResponse = new OutputResponseAll();
+            theResponse.setResult("ok");
+            theResponse.setReason("ok");
+            if (attach1 == null || attach1.value == null) {
+                System.err.println("attach1.value is null (unexpected)");
+                theResponse.setReason("attach1.value is null (unexpected)");
+                theResponse.setResult("not ok");
+            }
+            if (attach2 == null || attach2.value == null) {
+                System.err.println("attach2.value is null (unexpected)");
+                if ("ok".equals(theResponse.getReason())) {
+                    theResponse.setReason("attach2.value is null 
(unexpected)");
+                } else {
+                    theResponse.setReason(theResponse.getReason() + 
"\nattach2.value is null (unexpected)");
+                }
+                theResponse.setResult("not ok");
+            }
+            if (attach3 == null || attach3.value == null) {
+                System.err.println("attach3.value is null (unexpected)");
+                if ("ok".equals(theResponse.getReason())) {
+                    theResponse.setReason("attach3.value is null 
(unexpected)");
+                } else {
+                    theResponse.setReason(theResponse.getReason() + 
"\nattach3.value is null (unexpected)");
+                }
+                theResponse.setResult("not ok");
+            }
+            if (attach4 == null || attach4.value == null) {
+                System.err.println("attach4.value is null (unexpected)");
+                if ("ok".equals(theResponse.getReason())) {
+                    theResponse.setReason("attach4.value is null 
(unexpected)");
+                } else {
+                    theResponse.setReason(theResponse.getReason() + 
"\nattach4.value is null (unexpected)");
+                }
+                theResponse.setResult("not ok");
+            }
+            if (attach5 == null || attach5.value == null) {
+                System.err.println("attach5.value is null (unexpected)");
+                if ("ok".equals(theResponse.getReason())) {
+                    theResponse.setReason("attach5.value is null 
(unexpected)");
+                } else {
+                    theResponse.setReason(theResponse.getReason() + 
"\nattach5.value is null (unexpected)");
+                }
+                theResponse.setResult("not ok");
+            }
+            return theResponse;
+        } catch (Exception e) {
+            throw new WebServiceException(e.getMessage());
+        }
+    }
+
+    public void echoData(Holder<String> text, Holder<byte[]> data) {
+        data.value = ("test" + new String(data.value, 0, 
6)).getBytes(StandardCharsets.UTF_8);
+    }
+
+    public void echoDataRef(Holder<DataStruct> data) {
+        try {
+            InputStream bis = null;
+            bis = data.value.getDataRef().getDataSource().getInputStream();
+            byte[] b = new byte[6];
+            bis.read(b, 0, 6);
+            String string = IOUtils.newStringFromBytes(b);
+
+            ByteArrayDataSource source =
+                new ByteArrayDataSource(("test" + string).getBytes(), 
"application/octet-stream");
+            data.value.setDataRef(new DataHandler(source));
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void echoDataWithHeader(Holder<String> text, Holder<byte[]> data, 
Holder<String> headerText) {
+        data.value = ("test" + new String(data.value, 0, 
6)).getBytes(StandardCharsets.UTF_8);
+    }
+
+}
diff --git 
a/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/SwAServiceImpl.java
 
b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/SwAServiceImpl.java
new file mode 100644
index 0000000000..30d215c72d
--- /dev/null
+++ 
b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/SwAServiceImpl.java
@@ -0,0 +1,149 @@
+/**
+ * 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.cxf.systest.http_undertow.multipart;
+
+import java.awt.Image;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.xml.transform.Source;
+
+import jakarta.activation.DataHandler;
+import jakarta.jws.WebService;
+import jakarta.mail.util.ByteArrayDataSource;
+import jakarta.xml.ws.Holder;
+import jakarta.xml.ws.WebServiceException;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.swa.SwAServiceInterface;
+import org.apache.cxf.swa.types.DataStruct;
+import org.apache.cxf.swa.types.OutputResponseAll;
+import org.apache.cxf.swa.types.VoidRequest;
+
+
+@WebService(endpointInterface = "org.apache.cxf.swa.SwAServiceInterface",
+            serviceName = "SwAService",
+            targetNamespace = "http://cxf.apache.org/swa";,
+            portName = "SwAServiceHttpPort")
+public class SwAServiceImpl implements SwAServiceInterface {
+
+    public void echoDataRef(Holder<DataStruct> data) {
+        try {
+            InputStream bis = null;
+            bis = data.value.getDataRef().getDataSource().getInputStream();
+            byte[] b = new byte[6];
+            bis.read(b, 0, 6);
+            String string = IOUtils.newStringFromBytes(b);
+
+            ByteArrayDataSource source =
+                new ByteArrayDataSource(("test" + string).getBytes(), 
"application/octet-stream");
+            data.value.setDataRef(new DataHandler(source));
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void echoData(Holder<String> text, Holder<DataHandler> data) {
+
+        try {
+            InputStream bis = null;
+            bis = data.value.getDataSource().getInputStream();
+            byte[] b = new byte[6];
+            bis.read(b, 0, 6);
+            String string = IOUtils.newStringFromBytes(b);
+
+            ByteArrayDataSource source =
+                new ByteArrayDataSource(("test" + string).getBytes(), 
"application/octet-stream");
+            data.value = new DataHandler(source);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void echoDataWithHeader(Holder<String> text,
+                                   Holder<DataHandler> data,
+                                   Holder<String> headerText) {
+        try {
+            InputStream bis = null;
+            bis = data.value.getDataSource().getInputStream();
+            byte[] b = new byte[6];
+            bis.read(b, 0, 6);
+            String string = IOUtils.newStringFromBytes(b);
+
+            ByteArrayDataSource source =
+                new ByteArrayDataSource(("test" + string).getBytes(), 
"application/octet-stream");
+            data.value = new DataHandler(source);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public OutputResponseAll echoAllAttachmentTypes(VoidRequest request, 
Holder<DataHandler> attach1,
+                                                    Holder<DataHandler> 
attach2, Holder<Source> attach3,
+                                                    Holder<Image> attach4, 
Holder<Image> attach5) {
+        try {
+            OutputResponseAll theResponse = new OutputResponseAll();
+            theResponse.setResult("ok");
+            theResponse.setReason("ok");
+            if (attach1 == null || attach1.value == null) {
+                System.err.println("attach1.value is null (unexpected)");
+                theResponse.setReason("attach1.value is null (unexpected)");
+                theResponse.setResult("not ok");
+            }
+            if (attach2 == null || attach2.value == null) {
+                System.err.println("attach2.value is null (unexpected)");
+                if ("ok".equals(theResponse.getReason())) {
+                    theResponse.setReason("attach2.value is null 
(unexpected)");
+                } else {
+                    theResponse.setReason(theResponse.getReason() + 
"\nattach2.value is null (unexpected)");
+                }
+                theResponse.setResult("not ok");
+            }
+            if (attach3 == null || attach3.value == null) {
+                System.err.println("attach3.value is null (unexpected)");
+                if ("ok".equals(theResponse.getReason())) {
+                    theResponse.setReason("attach3.value is null 
(unexpected)");
+                } else {
+                    theResponse.setReason(theResponse.getReason() + 
"\nattach3.value is null (unexpected)");
+                }
+                theResponse.setResult("not ok");
+            }
+            if (attach4 == null || attach4.value == null) {
+                System.err.println("attach4.value is null (unexpected)");
+                if ("ok".equals(theResponse.getReason())) {
+                    theResponse.setReason("attach4.value is null 
(unexpected)");
+                } else {
+                    theResponse.setReason(theResponse.getReason() + 
"\nattach4.value is null (unexpected)");
+                }
+                theResponse.setResult("not ok");
+            }
+            if (attach5 == null || attach5.value == null) {
+                System.err.println("attach5.value is null (unexpected)");
+                if ("ok".equals(theResponse.getReason())) {
+                    theResponse.setReason("attach5.value is null 
(unexpected)");
+                } else {
+                    theResponse.setReason(theResponse.getReason() + 
"\nattach5.value is null (unexpected)");
+                }
+                theResponse.setResult("not ok");
+            }
+            return theResponse;
+        } catch (Exception e) {
+            throw new WebServiceException(e.getMessage());
+        }
+    }
+}
diff --git 
a/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/resources/attach.gif
 
b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/resources/attach.gif
new file mode 100644
index 0000000000..4e06f674f1
Binary files /dev/null and 
b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/resources/attach.gif
 differ
diff --git 
a/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/resources/attach.html
 
b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/resources/attach.html
new file mode 100644
index 0000000000..157e8d1fb5
--- /dev/null
+++ 
b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/resources/attach.html
@@ -0,0 +1,31 @@
+<!--
+ * 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.
+ *-->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<head>
+<title>This is a title</title>
+</head>
+<body bgcolor="#ffffff">
+<center><h1>This is a starting point</h1></center><hr>
+<h2>This is a header</h2>
+<p>This is a paragraph</p>
+<ul>
+<li><p>This is a bullet</p></li>
+</ul>
+</body>
+</html>
diff --git 
a/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/resources/attach.jpeg1
 
b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/resources/attach.jpeg1
new file mode 100644
index 0000000000..d5722555bb
Binary files /dev/null and 
b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/resources/attach.jpeg1
 differ
diff --git 
a/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/resources/attach.jpeg2
 
b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/resources/attach.jpeg2
new file mode 100644
index 0000000000..d5722555bb
Binary files /dev/null and 
b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/resources/attach.jpeg2
 differ
diff --git 
a/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/resources/attach.text
 
b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/resources/attach.text
new file mode 100644
index 0000000000..709170e128
--- /dev/null
+++ 
b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/resources/attach.text
@@ -0,0 +1,18 @@
+/**
+ * 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.
+ */
diff --git 
a/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/resources/attach.xml
 
b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/resources/attach.xml
new file mode 100644
index 0000000000..ea60bc9c67
--- /dev/null
+++ 
b/systests/transport-undertow/src/test/java/org/apache/cxf/systest/http_undertow/multipart/resources/attach.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<test/>

Reply via email to