cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r1380176 - in /cxf/trunk: rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/ systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/ testutils/src/main/resources/wsdl/
Date Mon, 03 Sep 2012 09:03:05 GMT
Author: ffang
Date: Mon Sep  3 09:03:04 2012
New Revision: 1380176

URL: http://svn.apache.org/viewvc?rev=1380176&view=rev
Log:
[CXF-4494]JMSDestination need set binary mode if server send MTOM message back

Modified:
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
    cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
    cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSMTOMImpl.java
    cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/Server.java
    cxf/trunk/testutils/src/main/resources/wsdl/jms_test_mtom.wsdl

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java?rev=1380176&r1=1380175&r2=1380176&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
Mon Sep  3 09:03:04 2012
@@ -54,6 +54,7 @@ import org.apache.cxf.interceptor.OneWay
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.message.MessageUtils;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.AbstractConduit;
 import org.apache.cxf.transport.AbstractMultiplexDestination;
@@ -301,7 +302,9 @@ public class JMSDestination extends Abst
             final javax.jms.Message request = (javax.jms.Message)inMessage
                 .get(JMSConstants.JMS_REQUEST_MESSAGE);
             final String msgType;
-            if (request instanceof TextMessage) {
+            if (isMtomEnabled(outMessage)) {
+                msgType = JMSConstants.BINARY_MESSAGE_TYPE;
+            } else if (request instanceof TextMessage) {
                 msgType = JMSConstants.TEXT_MESSAGE_TYPE;
             } else if (request instanceof BytesMessage) {
                 msgType = JMSConstants.BYTE_MESSAGE_TYPE;
@@ -409,7 +412,7 @@ public class JMSDestination extends Abst
             Exchange exchange = inMessage.getExchange();
             exchange.setOutMessage(message);
             
-            if (jmsMessage instanceof TextMessage) {
+            if ((jmsMessage instanceof TextMessage) && !isMtomEnabled(message)) {
                 message.setContent(Writer.class, new StringWriter() {
                     @Override
                     public void close() throws IOException {
@@ -422,10 +425,15 @@ public class JMSDestination extends Abst
                 message.setContent(OutputStream.class, new JMSOutputStream(sender, exchange,
false));
             }
         }
-
+        
         protected Logger getLogger() {
             return LOG;
         }
     }
 
+    private boolean isMtomEnabled(final Message message) {
+        return MessageUtils.isTrue(message.getContextualProperty(
+                                                       org.apache.cxf.message.Message.MTOM_ENABLED));
+    }
+
 }

Modified: cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java?rev=1380176&r1=1380175&r2=1380176&view=diff
==============================================================================
--- cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
(original)
+++ cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
Mon Sep  3 09:03:04 2012
@@ -73,6 +73,7 @@ import org.apache.cxf.jms_greeter.JMSGre
 import org.apache.cxf.jms_greeter.JMSGreeterService2;
 import org.apache.cxf.jms_mtom.JMSMTOMPortType;
 import org.apache.cxf.jms_mtom.JMSMTOMService;
+import org.apache.cxf.jms_mtom.JMSOutMTOMService;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
@@ -1095,6 +1096,28 @@ public class JMSClientServerTest extends
         assertEquals("The response file is not same with the sent file.", size, bytes.length);
     }
     
+    
+    @Test
+    public void testOutMTOM() throws Exception {
+        QName serviceName = new QName("http://cxf.apache.org/jms_mtom", "JMSMTOMService");
+        QName portName = new QName("http://cxf.apache.org/jms_mtom", "MTOMPort");
+
+        URL wsdl = getWSDLURL("/wsdl/jms_test_mtom.wsdl");
+        assertNotNull(wsdl);
+
+        JMSOutMTOMService service = new JMSOutMTOMService(wsdl, serviceName);
+        assertNotNull(service);
+
+        JMSMTOMPortType mtom = service.getPort(portName, JMSMTOMPortType.class);
+        URL fileURL = this.getClass().getResource("/org/apache/cxf/systest/jms/JMSClientServerTest.class");
+        DataHandler handler1 = new DataHandler(fileURL);
+        int size = handler1.getInputStream().available();
+        DataHandler ret = mtom.testOutMtom();
+        
+        byte bytes[] = IOUtils.readBytesFromStream(ret.getInputStream());
+        assertEquals("The response file is not same with the original file.", size, bytes.length);
+    }
+    
     @Test
     public void testSpecJMS() throws Exception {
         QName serviceName = getServiceName(new QName("http://cxf.apache.org/jms_greeter",

Modified: cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSMTOMImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSMTOMImpl.java?rev=1380176&r1=1380175&r2=1380176&view=diff
==============================================================================
--- cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSMTOMImpl.java
(original)
+++ cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSMTOMImpl.java
Mon Sep  3 09:03:04 2012
@@ -18,10 +18,13 @@
  */
 package org.apache.cxf.systest.jms;
 
+import java.net.URL;
+
 import javax.activation.DataHandler;
 import javax.jws.WebService;
 import javax.xml.ws.Holder;
 
+
 import org.apache.cxf.jms_mtom.JMSMTOMPortType;
 
 @WebService(serviceName = "JMSMTOMService", 
@@ -42,4 +45,10 @@ public class JMSMTOMImpl implements JMSM
         System.out.println("TestDataHandler End");
         */
     }
+
+   
+    public DataHandler testOutMtom() {
+        URL fileURL = this.getClass().getResource("/org/apache/cxf/systest/jms/JMSClientServerTest.class");
+        return new DataHandler(fileURL);
+    }
 }

Modified: cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/Server.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/Server.java?rev=1380176&r1=1380175&r2=1380176&view=diff
==============================================================================
--- cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/Server.java
(original)
+++ cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/Server.java
Mon Sep  3 09:03:04 2012
@@ -24,6 +24,8 @@ import javax.xml.ws.soap.SOAPBinding;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
 import org.apache.cxf.jaxws.EndpointImpl;
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
@@ -83,7 +85,9 @@ public class Server extends AbstractBusT
         Endpoint.publish("", i8);
         EndpointImpl ep = (EndpointImpl)Endpoint.publish("http://cxf.apache.org/transports/jms",
mtom);
         Binding binding = ep.getBinding();        
-        ((SOAPBinding)binding).setMTOMEnabled(true);  
+        ((SOAPBinding)binding).setMTOMEnabled(true); 
+        ep.getInInterceptors().add(new LoggingInInterceptor());
+        ep.getOutInterceptors().add(new LoggingOutInterceptor());
         
         Object spec1 = new GreeterSpecImpl();
         String address1 = "jms:jndi:dynamicQueues/test.cxf.jmstransport.queue2"

Modified: cxf/trunk/testutils/src/main/resources/wsdl/jms_test_mtom.wsdl
URL: http://svn.apache.org/viewvc/cxf/trunk/testutils/src/main/resources/wsdl/jms_test_mtom.wsdl?rev=1380176&r1=1380175&r2=1380176&view=diff
==============================================================================
--- cxf/trunk/testutils/src/main/resources/wsdl/jms_test_mtom.wsdl (original)
+++ cxf/trunk/testutils/src/main/resources/wsdl/jms_test_mtom.wsdl Mon Sep  3 09:03:04 2012
@@ -31,8 +31,19 @@
 						xmime:expectedContentTypes="application/octet-stream" />
 				</sequence>
 			</complexType>
+                        <complexType name="DataHandlerOnlyType">
+                                <sequence>
+                                        <element name="attachinfo" type="xsd:base64Binary"
+                                                xmime:expectedContentTypes="application/octet-stream"
/>
+                                </sequence>
+                        </complexType>
+
 			<element name="testDataHandler" type="x1:DataHandlerType" />
 			<element name="testDataHandlerResponse" type="x1:DataHandlerType" />
+                        <element name="testOutMtom">
+                            <complexType/>
+                        </element>
+                        <element name="testOutMtomResponse" type="x1:DataHandlerOnlyType"
/>
 		</schema>
 	</wsdl:types>
 
@@ -44,11 +55,24 @@
 		<wsdl:part name="data" element="x1:testDataHandlerResponse" />
 	</wsdl:message>
 
+        <wsdl:message name="testOutMtomRequest">
+                <wsdl:part name="in" element="x1:testOutMtom" />
+        </wsdl:message>
+
+        <wsdl:message name="testOutMtomResponse">
+                <wsdl:part name="out" element="x1:testOutMtomResponse" />
+        </wsdl:message>
+
+
 	<wsdl:portType name="JMSMTOMPortType">
 		<wsdl:operation name="testDataHandler">
 			<wsdl:input message="tns:testDataHandlerIn" />
 			<wsdl:output message="tns:testDataHandlerOut" />
 		</wsdl:operation>
+                <wsdl:operation name="testOutMtom">
+                        <wsdl:input message="tns:testOutMtomRequest" />
+                        <wsdl:output message="tns:testOutMtomResponse" />
+                </wsdl:operation>
 	</wsdl:portType>
 
 	<wsdl:binding name="JMSMTOMPortBinding" type="tns:JMSMTOMPortType">
@@ -63,6 +87,15 @@
 				<soap:body use="literal" />
 			</wsdl:output>
 		</wsdl:operation>
+                <wsdl:operation name="testOutMtom">
+                        <soap:operation soapAction="" />
+                        <wsdl:input>
+                                <soap:body use="literal" />
+                        </wsdl:input>
+                        <wsdl:output>
+                                <soap:body use="literal" />
+                        </wsdl:output>
+                </wsdl:operation>
 	</wsdl:binding>
 
 	<wsdl:service name="JMSMTOMService">
@@ -79,4 +112,18 @@
 			<jms:client messageType="byte"/>
 		</wsdl:port>
 	</wsdl:service>
+        <wsdl:service name="JMSOutMTOMService">
+                <wsdl:port binding="tns:JMSMTOMPortBinding" name="MTOMPort">
+                        <jms:address destinationStyle="queue"
+                                jndiConnectionFactoryName="ConnectionFactory"
+                                jndiDestinationName="dynamicQueues/test.cxf.jmstransport.queue">
+
+                                <jms:JMSNamingProperty name="java.naming.factory.initial"
+                                        value="org.apache.activemq.jndi.ActiveMQInitialContextFactory"
/>
+                                <jms:JMSNamingProperty name="java.naming.provider.url"
+                                        value="tcp://localhost:61500" />
+                        </jms:address>
+                </wsdl:port>
+        </wsdl:service>
+
 </wsdl:definitions>



Mime
View raw message