cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r776218 - in /cxf/trunk: 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 07:23:05 GMT
Author: ningjiang
Date: Tue May 19 07:23:04 2009
New Revision: 776218

URL: http://svn.apache.org/viewvc?rev=776218&view=rev
Log:
CXF-2207 Applied patch with thanks to LiuCong

Added:
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSMTOMImpl.java   (with props)
    cxf/trunk/testutils/src/main/resources/wsdl/jms_test_mtom.wsdl   (with props)
Modified:
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/Messages.properties
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/Server.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopWithJMSTest.java

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java?rev=776218&r1=776217&r2=776218&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
Tue May 19 07:23:04 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/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/Messages.properties?rev=776218&r1=776217&r2=776218&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/Messages.properties
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/Messages.properties
Tue May 19 07:23:04 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/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java?rev=776218&r1=776217&r2=776218&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java Tue
May 19 07:23:04 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);
+    }
 }

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSMTOMImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSMTOMImpl.java?rev=776218&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSMTOMImpl.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSMTOMImpl.java Tue May 19
07:23:04 2009
@@ -0,0 +1,45 @@
+/**
+ * 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.jms;
+
+import java.io.IOException;
+
+import javax.activation.DataHandler;
+import javax.jws.WebService;
+import javax.xml.ws.Holder;
+
+import org.apache.cxf.jms_mtom.JMSMTOMPortType;
+
+@WebService(serviceName = "JMSMTOMService", 
+            portName = "JMSMTOMPortType", 
+            endpointInterface = "org.apache.cxf.jms_mtom.JMSMTOMPortType", 
+            targetNamespace = "http://cxf.apache.org/jms_mtom", 
+            wsdlLocation = "testutils/jms_test_mtom.wsdl")
+public class JMSMTOMImpl implements JMSMTOMPortType {
+
+    public void testDataHandler(Holder<String> name, Holder<DataHandler> attachinfo)
{
+        System.out.println(name.value);
+        try {
+            System.out.println(attachinfo.value.getInputStream().available());
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        System.out.println("TestDataHandler End");
+    }
+}

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSMTOMImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/JMSMTOMImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/Server.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/Server.java?rev=776218&r1=776217&r2=776218&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/Server.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jms/Server.java Tue May 19 07:23:04
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/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopWithJMSTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopWithJMSTest.java?rev=776218&r1=776217&r2=776218&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopWithJMSTest.java
(original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopWithJMSTest.java
Tue May 19 07:23:04 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);
         }
     }
 

Added: 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=776218&view=auto
==============================================================================
--- cxf/trunk/testutils/src/main/resources/wsdl/jms_test_mtom.wsdl (added)
+++ cxf/trunk/testutils/src/main/resources/wsdl/jms_test_mtom.wsdl Tue May 19 07:23:04 2009
@@ -0,0 +1,82 @@
+<?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.
+	-->
+<wsdl:definitions name="JMSMTOMService"
+	targetNamespace="http://cxf.apache.org/jms_mtom" xmlns="http://schemas.xmlsoap.org/wsdl/"
+	xmlns:jms="http://cxf.apache.org/transports/jms" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+	xmlns:tns="http://cxf.apache.org/jms_mtom" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
+	xmlns:x1="http://cxf.apache.org/jms_mtom/types">
+	<wsdl:types>
+		<schema targetNamespace="http://cxf.apache.org/jms_mtom/types"
+			xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+			<complexType name="DataHandlerType">
+				<sequence>
+					<element name="name" type="xsd:string" />
+					<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" />
+		</schema>
+	</wsdl:types>
+
+	<wsdl:message name="testDataHandlerIn">
+		<wsdl:part name="data" element="x1:testDataHandler" />
+	</wsdl:message>
+
+	<wsdl:message name="testDataHandlerOut">
+		<wsdl:part name="data" element="x1:testDataHandlerResponse" />
+	</wsdl:message>
+
+	<wsdl:portType name="JMSMTOMPortType">
+		<wsdl:operation name="testDataHandler">
+			<wsdl:input message="tns:testDataHandlerIn" />
+			<wsdl:output message="tns:testDataHandlerOut" />
+		</wsdl:operation>
+	</wsdl:portType>
+
+	<wsdl:binding name="JMSMTOMPortBinding" type="tns:JMSMTOMPortType">
+		<soap:binding style="document"
+			transport="http://cxf.apache.org/transports/jms" />
+		<wsdl:operation name="testDataHandler">
+			<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">
+		<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>
+			<jms:client messageType="byte"/>
+		</wsdl:port>
+	</wsdl:service>
+</wsdl:definitions>

Propchange: cxf/trunk/testutils/src/main/resources/wsdl/jms_test_mtom.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/testutils/src/main/resources/wsdl/jms_test_mtom.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/testutils/src/main/resources/wsdl/jms_test_mtom.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message