Author: rsearls
Date: 2014-12-03 17:25:58 -0500 (Wed, 03 Dec 2014)
New Revision: 19121
Added:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/saaj/jbws3857/
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/saaj/jbws3857/MultipartContentTypeTestCase.java
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/saaj/jbws3857/SoapMultipartCheckerServlet.java
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/saaj/jbws3857/
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/saaj/jbws3857/META-INF/
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/saaj/jbws3857/META-INF/beans.xml
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/saaj/jbws3857/WEB-INF/
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/saaj/jbws3857/WEB-INF/jboss-web.xml
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/saaj/jbws3857/WEB-INF/web.xml
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/saaj/jbws3857/test.png
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/saaj/SOAPConnectionImpl.java
Log:
[JBWS-3857] integration of jbossws-cxf-4.3.x.patch posted in bz-1167348 and added test
case for patch.
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/saaj/SOAPConnectionImpl.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/saaj/SOAPConnectionImpl.java 2014-12-02
16:55:07 UTC (rev 19120)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/saaj/SOAPConnectionImpl.java 2014-12-03
22:25:58 UTC (rev 19121)
@@ -80,7 +80,11 @@
try
{
final Conduit c = ci.getConduit(info, BusFactory.getThreadDefaultBus(false));
//TODO verify bus
-
+
+ if (msgOut.saveRequired())
+ {
+ msgOut.saveChanges();
+ }
Map<String, List<String>> outHeaders = new HashMap<String,
List<String>>();
for (Iterator<?> it = msgOut.getMimeHeaders().getAllHeaders();
it.hasNext();)
Added:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/saaj/jbws3857/MultipartContentTypeTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/saaj/jbws3857/MultipartContentTypeTestCase.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/saaj/jbws3857/MultipartContentTypeTestCase.java 2014-12-03
22:25:58 UTC (rev 19121)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.saaj.jbws3857;
+
+import junit.framework.Test;
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestHelper;
+import org.jboss.wsf.test.JBossWSTestSetup;
+import org.junit.Assert;
+
+import javax.activation.DataHandler;
+import javax.activation.URLDataSource;
+import javax.xml.namespace.QName;
+import javax.xml.soap.*;
+import java.io.File;
+import java.net.URL;
+import java.util.LinkedList;
+import java.util.List;
+
+import static org.jboss.wsf.test.JBossWSTestHelper.getTestResourcesDir;
+
+/**
+ *
+ */
+public class MultipartContentTypeTestCase extends JBossWSTest
+{
+ private static final String PROJECT_NAME =
"reproducer-eap-wrong-multipart";
+ private static final String TEST_SERVLET_URL = "http://" + getServerHost() +
":8080/" + PROJECT_NAME + "/testServlet";
+ private static final String IN_IMG_NAME = "test.png";
+
+ public static JBossWSTestHelper.BaseDeployment<?>[] createDeployments() {
+ List<JBossWSTestHelper.BaseDeployment<?>> list = new
LinkedList<JBossWSTestHelper.BaseDeployment<?>>();
+ list.add(new JBossWSTestHelper.WarDeployment("jaxws-jbws3857.war") { {
+ archive
+ .addManifest()
+ .addClass(org.jboss.test.ws.saaj.jbws3857.SoapMultipartCheckerServlet.class)
+ .addAsWebInfResource(new File(getTestResourcesDir() +
"/saaj/jbws3857/META-INF/beans.xml"), "classes/META-INF/beans.xml")
+ .addAsWebInfResource(new File(getTestResourcesDir() +
"/saaj/jbws3857/test.png"), "classes/test.png")
+ .addAsWebInfResource(new File(getTestResourcesDir() +
"/saaj/jbws3857/WEB-INF/jboss-web.xml"), "jboss-web.xml")
+ .setWebXML(new File(JBossWSTestHelper.getTestResourcesDir() +
"/saaj/jbws3857/WEB-INF/web.xml"))
+ ;
+ }
+ });
+ return list.toArray(new JBossWSTestHelper.BaseDeployment<?>[list.size()]);
+ }
+
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(MultipartContentTypeTestCase.class,
JBossWSTestHelper.writeToFile(createDeployments()));
+ }
+
+ public void testSendMultipartSoapMessage() throws Exception {
+ final MessageFactory msgFactory =
MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
+ final SOAPMessage msg = msgFactory.createMessage();
+ final SOAPBodyElement bodyElement = msg.getSOAPBody().addBodyElement(
+ new QName("urn:ledegen:soap-attachment:1.0", "echoImage"));
+ bodyElement.addTextNode("cid:" + IN_IMG_NAME);
+
+ final AttachmentPart ap = msg.createAttachmentPart();
+ ap.setDataHandler(getResource("saaj/jbws3857/" + IN_IMG_NAME));
+ ap.setContentId(IN_IMG_NAME);
+ msg.addAttachmentPart(ap);
+
+ final SOAPConnectionFactory conFactory = SOAPConnectionFactory.newInstance();
+ final SOAPConnection connection = conFactory.createConnection();
+ final SOAPMessage response = connection.call(msg, new URL(TEST_SERVLET_URL));
+
+ final String contentTypeWeHaveSent = getBodyElementTextValue(response);
+ assertContentTypeStarts("multipart/related", contentTypeWeHaveSent);
+ }
+
+ private void assertContentTypeStarts(final String expectedStart, final String actual)
{
+ if (!actual.startsWith(expectedStart)) {
+ Assert.fail("We have send request with Content-Type " + actual +
", but expected start is " + expectedStart);
+ }
+ }
+
+ private String getBodyElementTextValue(final SOAPMessage msg) throws Exception {
+ final SOAPBodyElement bodyElement = (SOAPBodyElement)
msg.getSOAPBody().getChildElements().next();
+ final String result = bodyElement.getTextContent();
+ return result;
+ }
+
+ private DataHandler getResource(final String resource) throws Exception {
+ URL imageUrl = getResourceURL(resource);
+ return new DataHandler(new URLDataSource(imageUrl));
+ }
+
+}
Added:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/saaj/jbws3857/SoapMultipartCheckerServlet.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/saaj/jbws3857/SoapMultipartCheckerServlet.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/saaj/jbws3857/SoapMultipartCheckerServlet.java 2014-12-03
22:25:58 UTC (rev 19121)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.saaj.jbws3857;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.namespace.QName;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPBodyElement;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPMessage;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ *
+ */
+public class SoapMultipartCheckerServlet extends HttpServlet {
+
+ @Override
+ protected void service(final HttpServletRequest req, final HttpServletResponse resp)
throws ServletException, IOException {
+ final String requestedContentType = req.getHeader("Content-Type");
+ System.out.println("Requested content type : " + requestedContentType);
+
+ try {
+ replyRequestedContentTypeInResponse(requestedContentType, resp);
+ } catch (final Exception e) {
+ throw new ServletException(e.getMessage(), e);
+ }
+ }
+
+ private void replyRequestedContentTypeInResponse(final String requestedContentType,
final HttpServletResponse resp) throws Exception {
+ final MessageFactory msgFactory =
MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
+ final SOAPMessage msg = msgFactory.createMessage();
+ final SOAPBodyElement bodyElement = msg.getSOAPBody().addBodyElement(
+ new QName("urn:not-important:1.0",
"requestedContentType"));
+
+ bodyElement.addTextNode(requestedContentType);
+
+ resp.setStatus(HttpServletResponse.SC_OK);
+ resp.setHeader("Content-Type", "application/soap+xml;
charset=utf-8");
+ final OutputStream os = resp.getOutputStream();
+ msg.writeTo(os);
+ os.close();
+ }
+}
Added:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/saaj/jbws3857/META-INF/beans.xml
===================================================================
Added:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/saaj/jbws3857/WEB-INF/jboss-web.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/saaj/jbws3857/WEB-INF/jboss-web.xml
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/saaj/jbws3857/WEB-INF/jboss-web.xml 2014-12-03
22:25:58 UTC (rev 19121)
@@ -0,0 +1,3 @@
+<jboss-web>
+ <context-root>reproducer-eap-wrong-multipart</context-root>
+</jboss-web>
Added:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/saaj/jbws3857/WEB-INF/web.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/saaj/jbws3857/WEB-INF/web.xml
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/saaj/jbws3857/WEB-INF/web.xml 2014-12-03
22:25:58 UTC (rev 19121)
@@ -0,0 +1,13 @@
+<web-app>
+ <servlet>
+ <servlet-name>SoapMultipartCheckerServlet</servlet-name>
+ <servlet-class>
+ org.jboss.test.ws.saaj.jbws3857.SoapMultipartCheckerServlet
+ </servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>SoapMultipartCheckerServlet</servlet-name>
+ <url-pattern>/testServlet</url-pattern>
+ </servlet-mapping>
+</web-app>
\ No newline at end of file
Added:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/saaj/jbws3857/test.png
===================================================================
(Binary files differ)
Property changes on:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/resources/saaj/jbws3857/test.png
___________________________________________________________________
Added: svn:mime-type
+ image/png