cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r1380449 - in /cxf/branches/2.4.x-fixes: ./ 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 Tue, 04 Sep 2012 04:55:13 GMT
Author: ffang
Date: Tue Sep  4 04:55:12 2012
New Revision: 1380449

URL: http://svn.apache.org/viewvc?rev=1380449&view=rev
Log:
Merged revisions 1380446 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.5.x-fixes

........
  r1380446 | ffang | 2012-09-04 12:45:01 +0800 (二, 04  9 2012) | 1 line
  
   [CXF-4494]JMSDestination need set binary mode if server send MTOM message back
........

Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
    cxf/branches/2.4.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
    cxf/branches/2.4.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSMTOMImpl.java
    cxf/branches/2.4.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/Server.java
    cxf/branches/2.4.x-fixes/testutils/src/main/resources/wsdl/jms_test_mtom.wsdl

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/branches/2.5.x-fixes:r1380446

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.4.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java?rev=1380449&r1=1380448&r2=1380449&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
Tue Sep  4 04:55:12 2012
@@ -49,6 +49,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;
@@ -291,7 +292,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;
@@ -388,7 +391,8 @@ public class JMSDestination extends Abst
             Exchange exchange = inMessage.getExchange();
             exchange.setOutMessage(message);
             message.setContent(OutputStream.class, new JMSOutputStream(sender, exchange,
-                                                                       jmsMessage instanceof
TextMessage));
+                                                                       (jmsMessage instanceof
TextMessage) 
+                                                                           && !isMtomEnabled(message)));
         }
 
         protected Logger getLogger() {
@@ -396,4 +400,8 @@ public class JMSDestination extends Abst
         }
     }
 
+    private boolean isMtomEnabled(final Message message) {
+        return MessageUtils.isTrue(message.getContextualProperty(
+                                                       org.apache.cxf.message.Message.MTOM_ENABLED));
+    }
 }

Modified: cxf/branches/2.4.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java?rev=1380449&r1=1380448&r2=1380449&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
(original)
+++ cxf/branches/2.4.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
Tue Sep  4 04:55:12 2012
@@ -71,6 +71,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;
@@ -1089,6 +1090,27 @@ public class JMSClientServerTest extends
         byte bytes[] = IOUtils.readBytesFromStream(handler1.value.getInputStream());
         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 {

Modified: cxf/branches/2.4.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSMTOMImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSMTOMImpl.java?rev=1380449&r1=1380448&r2=1380449&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSMTOMImpl.java
(original)
+++ cxf/branches/2.4.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSMTOMImpl.java
Tue Sep  4 04:55:12 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/branches/2.4.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/Server.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/Server.java?rev=1380449&r1=1380448&r2=1380449&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/Server.java
(original)
+++ cxf/branches/2.4.x-fixes/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/Server.java
Tue Sep  4 04:55:12 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/branches/2.4.x-fixes/testutils/src/main/resources/wsdl/jms_test_mtom.wsdl
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/testutils/src/main/resources/wsdl/jms_test_mtom.wsdl?rev=1380449&r1=1380448&r2=1380449&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/testutils/src/main/resources/wsdl/jms_test_mtom.wsdl (original)
+++ cxf/branches/2.4.x-fixes/testutils/src/main/resources/wsdl/jms_test_mtom.wsdl Tue Sep
 4 04:55:12 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