cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r776235 - in /cxf/branches/2.1.x-fixes: ./ rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/ systests/src/test/java/org/apache/cxf/systest/jms/ systests/src/test/java/org/apache/cxf/systest/mtom/ testutils/src/main/resources/wsdl/
Date Tue, 19 May 2009 08:31:28 GMT
Author: ningjiang
Date: Tue May 19 08:31:27 2009
New Revision: 776235

URL: http://svn.apache.org/viewvc?rev=776235&view=rev
Log:
Merged revisions 776218 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r776218 | ningjiang | 2009-05-19 15:23:04 +0800 (Tue, 19 May 2009) | 1 line
  
  CXF-2207 Applied patch with thanks to LiuCong
........

Added:
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jms/JMSMTOMImpl.java
      - copied unchanged from r776218, cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSMTOMImpl.java
    cxf/branches/2.1.x-fixes/testutils/src/main/resources/wsdl/jms_test_mtom.wsdl
      - copied unchanged from r776218, cxf/trunk/testutils/src/main/resources/wsdl/jms_test_mtom.wsdl
Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
    cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/Messages.properties
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jms/Server.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopWithJMSTest.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue May 19 08:31:27 2009
@@ -1 +1 @@
-/cxf/trunk:743446,753380,753397,753421,754585,755365,757499,757859,757899,757935,757951,758195,758303,758308,758378,758690,758910,759890,759961,759963-759964,759966,760029,760073,760150,760171,760178,760198,760212,760456,760468,760582,760938,761094,761113,761120,761317,761759,761789,762393,762518,762567,763200,763272,763495,763854,763931,763942,763953,764033-764034,764581,764599-764606,764887,765357,766013,766058,766100-766101,766763,766770,766860,766962-766963,767159,767191,767927,771416,772143,772402,772658,772714,773009-773010,773027,773049,773146,773581,773691,773693,774446-774496,774558,774760,774851,774979,775423,776024-776025
+/cxf/trunk:743446,753380,753397,753421,754585,755365,757499,757859,757899,757935,757951,758195,758303,758308,758378,758690,758910,759890,759961,759963-759964,759966,760029,760073,760150,760171,760178,760198,760212,760456,760468,760582,760938,761094,761113,761120,761317,761759,761789,762393,762518,762567,763200,763272,763495,763854,763931,763942,763953,764033-764034,764581,764599-764606,764887,765357,766013,766058,766100-766101,766763,766770,766860,766962-766963,767159,767191,767927,771416,772143,772402,772658,772714,773009-773010,773027,773049,773146,773581,773691,773693,774446-774496,774558,774760,774851,774979,775423,776024-776025,776218

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

Modified: cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java?rev=776235&r1=776234&r2=776235&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
Tue May 19 08:31:27 2009
@@ -40,9 +40,11 @@
 import org.apache.cxf.buslifecycle.BusLifeCycleListener;
 import org.apache.cxf.buslifecycle.BusLifeCycleManager;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.configuration.ConfigurationException;
 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.ws.addressing.EndpointReferenceType;
@@ -111,6 +113,15 @@
             throw new RuntimeException("Exchange to be sent has no outMessage");
         }
 
+        boolean isTextPayload = JMSConstants.TEXT_MESSAGE_TYPE.equals(jmsConfig.getMessageType());
+        if (isTextPayload && MessageUtils.isTrue(outMessage.getContextualProperty(
+            org.apache.cxf.message.Message.MTOM_ENABLED)) 
+            && outMessage.getAttachments() != null && outMessage.getAttachments().size()
> 0) {
+            org.apache.cxf.common.i18n.Message msg = 
+                new org.apache.cxf.common.i18n.Message("INVALID_MESSAGE_TYPE", LOG);
+            throw new ConfigurationException(msg);
+        }
+        
         JMSMessageHeadersType headers = (JMSMessageHeadersType)outMessage
             .get(JMSConstants.JMS_CLIENT_REQUEST_HEADERS);
 

Modified: cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/Messages.properties?rev=776235&r1=776234&r2=776235&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/Messages.properties
(original)
+++ cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/Messages.properties
Tue May 19 08:31:27 2009
@@ -23,4 +23,5 @@
 INSUFFICIENT_CONFIGURATION_DESTINATION = Insufficient configuration for Destination. Did
you configure a <jms:destination name=\"{0}\"> and set the jndiConnectionFactoryName
?
 JMSCONFIGFEATURE_ONLY_JMS = You can only use JMSConfigFeature with the jms transport
 JMSCONFIG_REQUIRED = You have to set the property jmsConfig
-INVALID_ENCODING_MSG = Invalid character set {0} in the message.
\ No newline at end of file
+INVALID_ENCODING_MSG = Invalid character set {0} in the message.
+INVALID_MESSAGE_TYPE = Invalid configuration for message type, if the MTOM enabled, the message
type should be binary.

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java?rev=776235&r1=776234&r2=776235&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
(original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
Tue May 19 08:31:27 2009
@@ -28,8 +28,12 @@
 import java.util.Map;
 import java.util.UUID;
 
+import javax.activation.DataHandler;
 import javax.xml.namespace.QName;
+import javax.xml.ws.Binding;
 import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Holder;
+import javax.xml.ws.soap.SOAPBinding;
 
 
 import org.apache.cxf.hello_world_jms.BadRecordLitFault;
@@ -45,6 +49,8 @@
 import org.apache.cxf.hello_world_jms.HelloWorldServiceRuntimeCorrelationIDDynamicPrefix;
 import org.apache.cxf.hello_world_jms.HelloWorldServiceRuntimeCorrelationIDStaticPrefix;
 import org.apache.cxf.hello_world_jms.NoSuchCodeLitFault;
+import org.apache.cxf.jms_mtom.JMSMTOMPortType;
+import org.apache.cxf.jms_mtom.JMSMTOMService;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.transport.jms.JMSConstants;
 import org.apache.cxf.transport.jms.JMSMessageHeadersType;
@@ -689,8 +695,7 @@
             BindingProvider  bp = null;
             
             if (handler instanceof BindingProvider) {
-                bp = (BindingProvider)handler;
-                //System.out.println(bp.toString());
+                bp = (BindingProvider)handler;                
                 Map<String, Object> requestContext = bp.getRequestContext();
                 JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
                 requestHeader.setJMSCorrelationID("JMS_SAMPLE_CORRELATION_ID");
@@ -737,4 +742,28 @@
         }
     }
     
+    @Test
+    public void testMTOM() 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 = getClass().getResource("/wsdl/jms_test_mtom.wsdl");
+        assertNotNull(wsdl);
+
+        JMSMTOMService service = new JMSMTOMService(wsdl, serviceName);
+        assertNotNull(service);
+
+        JMSMTOMPortType mtom = service.getPort(portName, JMSMTOMPortType.class);
+        Binding binding = ((BindingProvider)mtom).getBinding();
+        ((SOAPBinding)binding).setMTOMEnabled(true);
+
+        Holder<String> name = new Holder<String>("Sam");
+        URL fileURL = this.getClass().getResource("/org/apache/cxf/systest/jms/JMSClientServerTest.class");
+        Holder<DataHandler> handler1 = new Holder<DataHandler>();
+        handler1.value = new DataHandler(fileURL);
+        int size = handler1.value.getInputStream().available();
+        mtom.testDataHandler(name, handler1);
+        int size2 = handler1.value.getInputStream().available();
+        assertTrue("The response file is not same with the sent file.", size == size2);
+    }
 }

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jms/Server.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jms/Server.java?rev=776235&r1=776234&r2=776235&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jms/Server.java
(original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jms/Server.java
Tue May 19 08:31:27 2009
@@ -18,8 +18,11 @@
  */
 package org.apache.cxf.systest.jms;
 
+import javax.xml.ws.Binding;
 import javax.xml.ws.Endpoint;
+import javax.xml.ws.soap.SOAPBinding;
 
+import org.apache.cxf.jaxws.EndpointImpl;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
 
 public class Server extends AbstractBusTestServerBase {
@@ -39,7 +42,7 @@
         Object i4 = new GreeterImplTwoWayJMSRuntimeCorrelationIDDynamicPrefix();
         Object i5 = new GreeterImplTwoWayJMSRuntimeCorrelationIDStaticPrefixEng();
         Object i6 = new GreeterImplTwoWayJMSRuntimeCorrelationIDStaticPrefixSales();
-        
+        Object mtom = new JMSMTOMImpl();
         
         Endpoint.publish(null, impleDoc);
         String address = "http://localhost:9000/SoapContext/SoapPort";
@@ -55,6 +58,9 @@
         Endpoint.publish("", i4);
         Endpoint.publish("", i5);
         Endpoint.publish("", i6);
+        EndpointImpl ep = (EndpointImpl)Endpoint.publish("http://cxf.apache.org/transports/jms",
mtom);
+        Binding binding = ep.getBinding();        
+        ((SOAPBinding)binding).setMTOMEnabled(true);  
     }
 
 

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopWithJMSTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopWithJMSTest.java?rev=776235&r1=776234&r2=776235&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopWithJMSTest.java
(original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopWithJMSTest.java
Tue May 19 08:31:27 2009
@@ -21,7 +21,6 @@
 import java.io.InputStream;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Proxy;
-import java.lang.reflect.UndeclaredThrowableException;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -31,6 +30,7 @@
 import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Holder;
 import javax.xml.ws.soap.SOAPBinding;
+import javax.xml.ws.soap.SOAPFaultException;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
@@ -100,12 +100,14 @@
             param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
             Holder<String> name = new Holder<String>("call detail");
             mtomPort.testXop(name, param);
+            fail("Expect the exception here !");
             assertEquals("name unchanged", "return detail + call detail", name.value);
             assertNotNull(param.value);
             param.value.getInputStream().close();
             
-        } catch (UndeclaredThrowableException ex) {
-            throw (Exception) ex.getCause();
+        } catch (SOAPFaultException ex) {
+            assertTrue("Expect the configuration exception here",
+                       ex.getCause() instanceof org.apache.cxf.configuration.ConfigurationException);
         }
     }
 



Mime
View raw message