axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r732539 - in /webservices/axis2/trunk/java/modules/saaj: test-resources/SwAmessage.bin test-resources/message.bin test/org/apache/axis2/saaj/MessageFactoryTest.java test/org/apache/axis2/saaj/SAAJTestUtil.java
Date Wed, 07 Jan 2009 22:22:32 GMT
Author: veithen
Date: Wed Jan  7 14:22:31 2009
New Revision: 732539

URL: http://svn.apache.org/viewvc?rev=732539&view=rev
Log:
Added unit tests for AXIS2-4189 (commented out since the issue is not solved yet).

Added:
    webservices/axis2/trunk/java/modules/saaj/test-resources/SwAmessage.bin
    webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SAAJTestUtil.java
  (with props)
Modified:
    webservices/axis2/trunk/java/modules/saaj/test-resources/message.bin
    webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/MessageFactoryTest.java

Added: webservices/axis2/trunk/java/modules/saaj/test-resources/SwAmessage.bin
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/test-resources/SwAmessage.bin?rev=732539&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test-resources/SwAmessage.bin (added)
+++ webservices/axis2/trunk/java/modules/saaj/test-resources/SwAmessage.bin Wed Jan  7 14:22:31
2009
@@ -0,0 +1,13 @@
+--MIMEBoundaryurn_uuid_E3F7CE4554928DA89B1231365678616
+Content-Type: text/xml; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+Content-ID: <0.urn:uuid:E3F7CE4554928DA89B1231365678617@apache.org>
+
+<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><m0:uploadFileUsingSwA
xmlns:m0="http://services.samples"><m0:request><m0:imageId>urn:uuid:E3F7CE4554928DA89B1231365678347</m0:imageId></m0:request></m0:uploadFileUsingSwA></soapenv:Body></soapenv:Envelope>
+--MIMEBoundaryurn_uuid_E3F7CE4554928DA89B1231365678616
+Content-Type: text/plain
+Content-Transfer-Encoding: binary
+Content-ID: <urn:uuid:E3F7CE4554928DA89B1231365678347>
+
+test text
+--MIMEBoundaryurn_uuid_E3F7CE4554928DA89B1231365678616--

Modified: webservices/axis2/trunk/java/modules/saaj/test-resources/message.bin
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/test-resources/message.bin?rev=732539&r1=732538&r2=732539&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test-resources/message.bin (original)
+++ webservices/axis2/trunk/java/modules/saaj/test-resources/message.bin Wed Jan  7 14:22:31
2009
@@ -1,14 +1,14 @@
---MIMEBoundaryurn:uuid:F02ECC18873CFB73E211412748909307
-content-type: application/xop+xml; charset=UTF-8; type="text/xml";
-content-transfer-encoding: binary
-content-id: <0.urn:uuid:F02ECC18873CFB73E211412748909308@apache.org>
-
-<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header><ns-prefix:Header1
xmlns:ns-prefix="ns-uri" xmlns:mustUnderstand="1" soapenv:mustUnderstand="1">This is Header1</ns-prefix:Header1><ns-prefix:Header2
xmlns:ns-prefix="ns-uri" xmlns:mustUnderstand="0" soapenv:mustUnderstand="0">This is Header2</ns-prefix:Header2><ns-prefix:Header3
xmlns:ns-prefix="ns-uri" xmlns:mustUnderstand="1" soapenv:mustUnderstand="1">This is Header3</ns-prefix:Header3><ns-prefix:Header4
xmlns:ns-prefix="ns-uri" xmlns:mustUnderstand="0" soapenv:mustUnderstand="0">This is Header4</ns-prefix:Header4></soapenv:Header><soapenv:Body><ns-prefix:Body1
xmlns:ns-prefix="ns-uri"><ns-prefix:Child1>This is Child1</ns-prefix:Child1><ns-prefix:Child2>This
is Child2</ns-prefix:Child2></ns-prefix:Body1><swa:echo xmlns:swa="http://fakeNamespace.org"><internal
xmlns=""><text xmlns=""><xop:Include href="cid:1.urn:uuid:F02ECC18873CFB73E2114127489
 09349@apache.org" xmlns:xop="http://www.w3.org/2004/08/xop/include" /></text></internal></swa:echo></soapenv:Body></soapenv:Envelope>
---MIMEBoundaryurn:uuid:F02ECC18873CFB73E211412748909307
-content-type: text/xml
-content-transfer-encoding: binary
-content-id: <1.urn:uuid:F02ECC18873CFB73E211412748909349@apache.org>
-
-TATA
-
---MIMEBoundaryurn:uuid:F02ECC18873CFB73E211412748909307--
+--MIMEBoundaryurn:uuid:F02ECC18873CFB73E211412748909307
+content-type: application/xop+xml; charset=UTF-8; type="text/xml";
+content-transfer-encoding: binary
+content-id: <0.urn:uuid:F02ECC18873CFB73E211412748909308@apache.org>
+
+<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header><ns-prefix:Header1
xmlns:ns-prefix="ns-uri" xmlns:mustUnderstand="1" soapenv:mustUnderstand="1">This is Header1</ns-prefix:Header1><ns-prefix:Header2
xmlns:ns-prefix="ns-uri" xmlns:mustUnderstand="0" soapenv:mustUnderstand="0">This is Header2</ns-prefix:Header2><ns-prefix:Header3
xmlns:ns-prefix="ns-uri" xmlns:mustUnderstand="1" soapenv:mustUnderstand="1">This is Header3</ns-prefix:Header3><ns-prefix:Header4
xmlns:ns-prefix="ns-uri" xmlns:mustUnderstand="0" soapenv:mustUnderstand="0">This is Header4</ns-prefix:Header4></soapenv:Header><soapenv:Body><ns-prefix:Body1
xmlns:ns-prefix="ns-uri"><ns-prefix:Child1>This is Child1</ns-prefix:Child1><ns-prefix:Child2>This
is Child2</ns-prefix:Child2></ns-prefix:Body1><swa:echo xmlns:swa="http://fakeNamespace.org"><internal
xmlns=""><text xmlns=""><xop:Include href="cid:1.urn:uuid:F02ECC18873CFB73E2114127489
 09349@apache.org" xmlns:xop="http://www.w3.org/2004/08/xop/include" /></text></internal></swa:echo></soapenv:Body></soapenv:Envelope>
+--MIMEBoundaryurn:uuid:F02ECC18873CFB73E211412748909307
+content-type: text/xml
+content-transfer-encoding: binary
+content-id: <1.urn:uuid:F02ECC18873CFB73E211412748909349@apache.org>
+
+TATA
+
+--MIMEBoundaryurn:uuid:F02ECC18873CFB73E211412748909307--

Modified: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/MessageFactoryTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/MessageFactoryTest.java?rev=732539&r1=732538&r2=732539&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/MessageFactoryTest.java
(original)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/MessageFactoryTest.java
Wed Jan  7 14:22:31 2009
@@ -21,11 +21,17 @@
 
 import org.custommonkey.xmlunit.XMLTestCase;
 
+import javax.xml.soap.AttachmentPart;
 import javax.xml.soap.MessageFactory;
 import javax.xml.soap.MimeHeaders;
 import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Iterator;
 
 /**
  * 
@@ -127,4 +133,60 @@
             fail("Exception: " + e);
         }
     }
+
+    // Unit tests for (unresolved) issue AXIS2-4189
+/*    
+    public void testParseMTOMMessage() throws Exception {
+        SAAJTestUtil.execute(new SAAJTestUtil.Test() {
+            public void execute(MessageFactory mf) throws Exception {
+                MimeHeaders headers = new MimeHeaders();
+                headers.addHeader("Content-Type",
+                        "multipart/related; " +
+                        "boundary=\"MIMEBoundaryurn:uuid:F02ECC18873CFB73E211412748909307\";
" +
+                        "type=\"application/xop+xml\"; " +
+                        "start=\"<0.urn:uuid:F02ECC18873CFB73E211412748909308@apache.org>\";
" +
+                        "start-info=\"text/xml\"; " +
+                        "charset=UTF-8;" +
+                        "action=\"mtomSample\"");
+                InputStream in = new FileInputStream(System.getProperty("basedir", ".")
+                        + "/test-resources/message.bin");
+                SOAPMessage message = mf.createMessage(headers, in);
+                SOAPPart soapPart = message.getSOAPPart();
+                assertEquals("<0.urn:uuid:F02ECC18873CFB73E211412748909308@apache.org>",
+                        soapPart.getContentId());
+                Iterator attachments = message.getAttachments();
+                assertTrue(attachments.hasNext());
+                AttachmentPart ap = (AttachmentPart)attachments.next();
+                assertEquals("<1.urn:uuid:F02ECC18873CFB73E211412748909349@apache.org>",
+                        ap.getContentId());
+                assertFalse(attachments.hasNext());
+            }
+        });
+    }
+
+    public void testParseSwAMessage() throws Exception {
+        SAAJTestUtil.execute(new SAAJTestUtil.Test() {
+            public void execute(MessageFactory mf) throws Exception {
+                MimeHeaders headers = new MimeHeaders();
+                headers.addHeader("Content-Type",
+                        "multipart/related; " +
+                        "boundary=MIMEBoundaryurn_uuid_E3F7CE4554928DA89B1231365678616; "
+
+                        "type=\"text/xml\"; " +
+                        "start=\"<0.urn:uuid:E3F7CE4554928DA89B1231365678617@apache.org>\"");
+                InputStream in = new FileInputStream(System.getProperty("basedir", ".")
+                        + "/test-resources/SwAmessage.bin");
+                SOAPMessage message = mf.createMessage(headers, in);
+                SOAPPart soapPart = message.getSOAPPart();
+                assertEquals("<0.urn:uuid:E3F7CE4554928DA89B1231365678617@apache.org>",
+                        soapPart.getContentId());
+                Iterator attachments = message.getAttachments();
+                assertTrue(attachments.hasNext());
+                AttachmentPart ap = (AttachmentPart)attachments.next();
+                assertEquals("<urn:uuid:E3F7CE4554928DA89B1231365678347>",
+                        ap.getContentId());
+                assertFalse(attachments.hasNext());
+            }
+        });
+    }
+*/
 }

Added: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SAAJTestUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SAAJTestUtil.java?rev=732539&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SAAJTestUtil.java
(added)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SAAJTestUtil.java
Wed Jan  7 14:22:31 2009
@@ -0,0 +1,49 @@
+/*
+ * 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.axis2.saaj;
+
+import javax.xml.soap.MessageFactory;
+
+import junit.framework.Assert;
+
+/**
+ * Utility to execute SAAJ tests.
+ * It executes test cases twice: once against Sun's SAAJ implementation
+ * and once against Axis2's. This allows us to cross-check the validity
+ * of these tests, i.e. to check whether we are testing the right thing.
+ */
+public class SAAJTestUtil {
+    public interface Test {
+        void execute(MessageFactory mf) throws Exception;
+    }
+    
+    private SAAJTestUtil() {}
+    
+    public static void execute(Test test) throws Exception {
+        try {
+            test.execute(new com.sun.xml.messaging.saaj.soap.MessageFactoryImpl());
+        } catch (Throwable ex) {
+            ex.printStackTrace();
+            Assert.fail("Invalid test case; execution failed with SAAJ reference implementation:
"
+                    + ex.getMessage());
+        }
+        test.execute(new org.apache.axis2.saaj.MessageFactoryImpl());
+    }
+}

Propchange: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SAAJTestUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message