Author: veithen
Date: Sun Aug 21 11:37:46 2011
New Revision: 1159965

URL: http://svn.apache.org/viewvc?rev=1159965&view=rev
Log:
Added a regression test for AXIOM-383.

Added:
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/mtom/zero-length-attachment.bin
Modified:
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java?rev=1159965&r1=1159964&r2=1159965&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java
 Sun Aug 21 11:37:46 2011
@@ -454,6 +454,30 @@ public class AttachmentsTest extends Abs
     public void testReadBase64EncodedAttachmentWithPartOnFile() throws 
Exception {
         testReadBase64EncodedAttachment(true);
     }
+
+    /**
+     * Tests that {@link Attachments} can successfully read an attachment with 
zero length. This is
+     * a regression test for
+     * <a href="https://issues.apache.org/jira/browse/AXIOM-383";>AXIOM-383</a>.
+     * 
+     * @throws Exception
+     */
+    public void testZeroLengthAttachment() throws Exception {
+        InputStream in = getTestResource("mtom/zero-length-attachment.bin");
+        try {
+            Attachments attachments = new Attachments(in,
+                    "multipart/related; " +
+                    
"boundary=MIMEBoundaryurn_uuid_0549F3F826EC3041861188639371825; " +
+                    "type=\"application/xop+xml\"; " +
+                    
"start=\"0.urn:uuid:[email protected]\"; " +
+                    "start-info=\"application/soap+xml\"; 
action=\"urn:test\"");
+            DataHandler dh = 
attachments.getDataHandler("1.urn:uuid:[email protected]");
+            InputStream content = dh.getInputStream();
+            assertEquals(-1, content.read());
+        } finally {
+            in.close();
+        }
+    }
     
     public void testPurgeDataSource() throws Exception {
         InputStream in = getTestResource("mtom/msg-soap-wls81.txt");

Added: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/mtom/zero-length-attachment.bin
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/mtom/zero-length-attachment.bin?rev=1159965&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/mtom/zero-length-attachment.bin
 (added)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/mtom/zero-length-attachment.bin
 Sun Aug 21 11:37:46 2011
@@ -0,0 +1,21 @@
+--MIMEBoundaryurn_uuid_0549F3F826EC3041861188639371825
+Content-Type: application/xop+xml; charset=UTF-8; type="application/soap+xml"
+Content-Transfer-Encoding: binary
+Content-ID: <0.urn:uuid:[email protected]>
+
+<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope";>
+    <soapenv:Body>
+        <ns3:test xmlns:ns3="urn:test">
+            <data>
+                <xop:Include 
href="cid:1.urn:uuid:[email protected]" 
xmlns:xop="http://www.w3.org/2004/08/xop/include"; />
+            </data>
+        </ns3:test>
+   </soapenv:Body>
+</soapenv:Envelope>
+--MIMEBoundaryurn_uuid_0549F3F826EC3041861188639371825
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <1.urn:uuid:[email protected]>
+
+
+--MIMEBoundaryurn_uuid_0549F3F826EC3041861188639371825--


Reply via email to