cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r612972 - in /incubator/cxf/trunk: systests/src/test/java/org/apache/cxf/systest/mtom/ testutils/src/main/java/org/apache/cxf/mtom_xop/ testutils/src/main/resources/wsdl/
Date Thu, 17 Jan 2008 20:45:36 GMT
Author: bimargulies
Date: Thu Jan 17 12:45:34 2008
New Revision: 612972

URL: http://svn.apache.org/viewvc?rev=612972&view=rev
Log:
Add a failing MTOM test case.

Modified:
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/TestAttachmentOutInterceptor.java
    incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/mtom_xop/TestMtomImpl.java
    incubator/cxf/trunk/testutils/src/main/resources/wsdl/mtom_xop.wsdl

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java?rev=612972&r1=612971&r2=612972&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java
Thu Jan 17 12:45:34 2008
@@ -39,6 +39,7 @@
 import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
 import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
 import org.apache.cxf.mime.TestMtom;
+import org.apache.cxf.mime.types.XopStringType;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
 import org.apache.cxf.service.model.EndpointInfo;
@@ -53,51 +54,36 @@
     public static final QName MTOM_PORT = new QName("http://cxf.apache.org/mime", "TestMtomPort");
     public static final QName MTOM_SERVICE = new QName("http://cxf.apache.org/mime", "TestMtomService");
 
-
     @BeforeClass
     public static void startServers() throws Exception {
         TestUtilities.setKeepAliveSystemProperty(false);
         assertTrue("server did not launch correctly", launchServer(Server.class));
     }
-    
+
     @AfterClass
     public static void cleanup() {
         TestUtilities.recoverKeepAliveSystemProperty();
     }
 
     /*
-    @Test
-    @Ignore
-    public void testMtomSWA() throws Exception {
-        TestMtom mtomPort = createPort(MTOM_SERVICE, MTOM_PORT, TestMtom.class);
-        try {
-            InputStream pre = this.getClass().getResourceAsStream("/wsdl/mtom_xop.wsdl");
-            long fileSize = 0;
-            for (int i = pre.read(); i != -1; i = pre.read()) {
-                fileSize++;
-            }
+     * @Test @Ignore public void testMtomSWA() throws Exception { TestMtom
+     * mtomPort = createPort(MTOM_SERVICE, MTOM_PORT, TestMtom.class); try {
+     * InputStream pre =
+     * this.getClass().getResourceAsStream("/wsdl/mtom_xop.wsdl"); long fileSize =
+     * 0; for (int i = pre.read(); i != -1; i = pre.read()) { fileSize++; }
+     * ByteArrayDataSource bads = new
+     * ByteArrayDataSource(this.getClass().getResourceAsStream(
+     * "/wsdl/mtom_xop.wsdl"), "application/octet-stream"); DataHandler dh = new
+     * DataHandler(bads); DataHandler dhResp = mtomPort.testSWA(dh); DataSource
+     * ds = dhResp.getDataSource(); InputStream in = ds.getInputStream(); long
+     * count = 0; for (int i = in.read(); i != -1; i = in.read()) { count++; }
+     * assertEquals("attachemnt length different", fileSize, count); } catch
+     * (UndeclaredThrowableException ex) { throw (Exception) ex.getCause(); } }
+     */
 
-            ByteArrayDataSource bads = new ByteArrayDataSource(this.getClass().getResourceAsStream(
-                    "/wsdl/mtom_xop.wsdl"), "application/octet-stream");
-            DataHandler dh = new DataHandler(bads);
-            DataHandler dhResp = mtomPort.testSWA(dh);
-            DataSource ds = dhResp.getDataSource();
-            InputStream in = ds.getInputStream();
-
-            long count = 0;
-            for (int i = in.read(); i != -1; i = in.read()) {
-                count++;
-            }
-            assertEquals("attachemnt length different", fileSize, count);
-        } catch (UndeclaredThrowableException ex) {
-            throw (Exception) ex.getCause();
-        }
-    }
-    */
-    
     @Test
     public void testMtomXop() throws Exception {
-        TestMtom mtomPort = createPort(MTOM_SERVICE, MTOM_PORT, TestMtom.class, true);
+        TestMtom mtomPort = createPort(MTOM_SERVICE, MTOM_PORT, TestMtom.class, true, true);
         try {
             InputStream pre = this.getClass().getResourceAsStream("/wsdl/mtom_xop.wsdl");
             long fileSize = 0;
@@ -105,24 +91,40 @@
                 fileSize++;
             }
             Holder<DataHandler> param = new Holder<DataHandler>();
-            byte[] data = new byte[(int) fileSize];
+            byte[] data = new byte[(int)fileSize];
             this.getClass().getResourceAsStream("/wsdl/mtom_xop.wsdl").read(data);
-            
+
             param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
             Holder<String> name = new Holder<String>("call detail");
             mtomPort.testXop(name, param);
             assertEquals("name unchanged", "return detail + call detail", name.value);
             assertNotNull(param.value);
         } catch (UndeclaredThrowableException ex) {
-            throw (Exception) ex.getCause();
+            throw (Exception)ex.getCause();
+        }
+    }
+
+    @org.junit.Ignore
+    @Test
+    public void testMtoMString() throws Exception {
+        TestMtom mtomPort = createPort(MTOM_SERVICE, MTOM_PORT, TestMtom.class, true, false);
+        InputStream pre = this.getClass().getResourceAsStream("/wsdl/mtom_xop.wsdl");
+        long fileSize = 0;
+        for (int i = pre.read(); i != -1; i = pre.read()) {
+            fileSize++;
         }
+        byte[] data = new byte[(int)fileSize];
+        this.getClass().getResourceAsStream("/wsdl/mtom_xop.wsdl").read(data);
+        String stringValue = new String(data, "utf-8");
+        XopStringType xsv = new XopStringType();
+        xsv.setAttachinfo(stringValue);
+        xsv.setName("eman");
+        XopStringType r = mtomPort.testXopString(xsv);
+        assertNotNull(r);
     }
 
-    private static <T> T createPort(QName serviceName, 
-                                    QName portName, 
-                                    Class<T> serviceEndpointInterface,
-                                    boolean enableMTOM)
-        throws Exception {
+    private static <T> T createPort(QName serviceName, QName portName, Class<T>
serviceEndpointInterface,
+                                    boolean enableMTOM, boolean installInterceptors) throws
Exception {
         Bus bus = BusFactory.getDefaultBus();
         ReflectionServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
         serviceFactory.setBus(bus);
@@ -134,14 +136,17 @@
         JaxWsEndpointImpl jaxwsEndpoint = new JaxWsEndpointImpl(bus, service, ei);
         SOAPBinding jaxWsSoapBinding = new SOAPBindingImpl(ei.getBinding());
         jaxWsSoapBinding.setMTOMEnabled(enableMTOM);
-        
-        jaxwsEndpoint.getBinding().getInInterceptors().add(new TestMultipartMessageInterceptor());
-        jaxwsEndpoint.getBinding().getOutInterceptors().add(new TestAttachmentOutInterceptor());
-        
+
+        if (installInterceptors) {
+            jaxwsEndpoint.getBinding().getInInterceptors().add(new TestMultipartMessageInterceptor());
+            jaxwsEndpoint.getBinding().getOutInterceptors().add(new TestAttachmentOutInterceptor());
+        }
+
         Client client = new ClientImpl(bus, jaxwsEndpoint);
         InvocationHandler ih = new JaxWsClientProxy(client, jaxwsEndpoint.getJaxwsBinding());
-        Object obj = Proxy.newProxyInstance(serviceEndpointInterface.getClassLoader(), new
Class[] {
-            serviceEndpointInterface, BindingProvider.class }, ih);
+        Object obj = Proxy
+            .newProxyInstance(serviceEndpointInterface.getClassLoader(),
+                              new Class[] {serviceEndpointInterface, BindingProvider.class},
ih);
         return serviceEndpointInterface.cast(obj);
     }
 }

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/TestAttachmentOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/TestAttachmentOutInterceptor.java?rev=612972&r1=612971&r2=612972&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/TestAttachmentOutInterceptor.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/TestAttachmentOutInterceptor.java
Thu Jan 17 12:45:34 2008
@@ -35,7 +35,7 @@
     }
 
     public void handleMessage(Message message) throws Fault {
-        Assert.assertEquals("check attachment count", message.getAttachments().size(), 1);
+        Assert.assertEquals("check attachment count", 1, message.getAttachments().size());
         Attachment att = message.getAttachments().iterator().next();
         Assert.assertNotNull("Attachment is null", att);
         Assert.assertNotNull("Attachment content-type is null", att.getDataHandler().getDataSource()

Modified: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/mtom_xop/TestMtomImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/mtom_xop/TestMtomImpl.java?rev=612972&r1=612971&r2=612972&view=diff
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/mtom_xop/TestMtomImpl.java
(original)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/mtom_xop/TestMtomImpl.java
Thu Jan 17 12:45:34 2008
@@ -24,6 +24,7 @@
 import javax.xml.ws.Holder;
 
 import org.apache.cxf.mime.TestMtom;
+import org.apache.cxf.mime.types.XopStringType;
 
 @WebService(serviceName = "TestMtomService", 
         portName = "TestMtomPort", 
@@ -34,8 +35,13 @@
 public class TestMtomImpl implements TestMtom {
 
     public void testXop(Holder<String> name, Holder<DataHandler> attachinfo)
{
-        // TODO Auto-generated method stub
         name.value = "return detail + " + name.value;
+    }
+
+    public XopStringType testXopString(XopStringType data) {
+        XopStringType d2 = new XopStringType();
+        d2.setAttachinfo("This is the cereal shot from guns" + data.getAttachinfo());
+        return d2;
     }
 
 }

Modified: incubator/cxf/trunk/testutils/src/main/resources/wsdl/mtom_xop.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/mtom_xop.wsdl?rev=612972&r1=612971&r2=612972&view=diff
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/resources/wsdl/mtom_xop.wsdl (original)
+++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/mtom_xop.wsdl Thu Jan 17 12:45:34
2008
@@ -33,13 +33,20 @@
                     <element name="attachinfo" type="xsd:base64Binary" xmime:expectedContentTypes="application/octet-stream"/>
                 </sequence>
             </complexType>
+            <complexType name="XopStringType">
+                <sequence>
+                    <element name="name" type="xsd:string" />
+                    <element name="attachinfo" type="xsd:base64Binary" xmime:expectedContentTypes="text/plain"/>
+                </sequence>
+            </complexType>
             <element name="testXop" type="types:XopType" />
             <element name="testXopResponse" type="types:XopType" />
+            <element name="testXopStringArgument" type="types:XopStringType"/>
+            <element name="testXopStringResponse" type="types:XopStringType"/>
         </schema>
 
     </wsdl:types>
 
-
     <wsdl:message name="testXopIn">
         <wsdl:part name="data" element="types:testXop" />
     </wsdl:message>
@@ -48,6 +55,13 @@
         <wsdl:part name="data" element="types:testXopResponse" />
     </wsdl:message>
 
+    <wsdl:message name="testXopStringIn">
+        <wsdl:part name="data" element="types:testXopStringArgument" />
+    </wsdl:message>
+
+    <wsdl:message name="testXopStringOut">
+        <wsdl:part name="data" element="types:testXopStringResponse" />
+    </wsdl:message>
 
     <wsdl:portType name="TestMtom">
 
@@ -56,12 +70,27 @@
             <wsdl:output message="tns:testXopOut" />
         </wsdl:operation>
 
+        <wsdl:operation name="testXopString">
+            <wsdl:input message="tns:testXopStringIn" />
+            <wsdl:output message="tns:testXopStringOut" />
+        </wsdl:operation>
+
     </wsdl:portType>
 
     <wsdl:binding name="TestMtomBinding" type="tns:TestMtom">
         <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"
/>
 
         <wsdl:operation name="testXop">
+            <soap:operation soapAction="" />
+            <wsdl:input>
+                <soap:body use="literal" />
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal" />
+            </wsdl:output>
+        </wsdl:operation>
+
+        <wsdl:operation name="testXopString">
             <soap:operation soapAction="" />
             <wsdl:input>
                 <soap:body use="literal" />



Mime
View raw message