ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1196309 - in /webservices/commons/trunk/modules/axiom/modules: axiom-api/src/test/java/org/apache/axiom/attachments/ axiom-api/src/test/java/org/apache/axiom/om/ axiom-api/src/test/java/org/apache/axiom/util/stax/xop/ axiom-tests/src/test/...
Date Tue, 01 Nov 2011 21:53:43 GMT
Author: veithen
Date: Tue Nov  1 21:53:43 2011
New Revision: 1196309

URL: http://svn.apache.org/viewvc?rev=1196309&view=rev
Log:
Some reorganization of the test constants to track which test uses which test file.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/MIMEResource.java
  (with props)
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/PartOnFileTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/TestConstants.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/xop/XOPDecodingStreamReaderTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/xop/XOPEncodingStreamReaderTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/envelope/TestBuildWithAttachments.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=1196309&r1=1196308&r2=1196309&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
Tue Nov  1 21:53:43 2011
@@ -60,8 +60,8 @@ public class AttachmentsTest extends Abs
     }
     
     public void testGetDataHandler() throws Exception {
-        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE);
-        Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
+        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE.getName());
+        Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE.getContentType());
 
         DataHandler dh = attachments
                 .getDataHandler("2.urn:uuid:A3ADBAEE51A1A87B2A11443668160994@apache.org");
@@ -74,8 +74,8 @@ public class AttachmentsTest extends Abs
     }
 
     public void testGetDataHandlerNonExistingMIMEPart() throws Exception {
-        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE);
-        Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
+        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE.getName());
+        Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE.getContentType());
 
         DataHandler dh = attachments.getDataHandler("ThisShouldReturnNull");
         assertNull(dh);
@@ -88,8 +88,8 @@ public class AttachmentsTest extends Abs
     }
 
     public void testGetAllContentIDs() throws Exception {
-        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE);
-        Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
+        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE.getName());
+        Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE.getContentType());
 
         String[] contentIDs = attachments.getAllContentIDs();
         assertEquals(3, contentIDs.length);
@@ -113,8 +113,8 @@ public class AttachmentsTest extends Abs
     }
     
     public void testGetContentIDSet() {
-        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE);
-        Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
+        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE.getName());
+        Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE.getContentType());
 
         Set idSet = attachments.getContentIDSet();
         assertTrue(idSet.contains("0.urn:uuid:A3ADBAEE51A1A87B2A11443668160702@apache.org"));
@@ -135,12 +135,12 @@ public class AttachmentsTest extends Abs
     }
     
     public void testGetContentLength() throws IOException {
-        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE);
-        Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
+        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE.getName());
+        Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE.getContentType());
         
         // Make sure the length is correct
         long length = attachments.getContentLength();
-        long fileSize = IOUtils.toByteArray(getTestResource(TestConstants.MTOM_MESSAGE)).length;
+        long fileSize = IOUtils.toByteArray(getTestResource(TestConstants.MTOM_MESSAGE.getName())).length;
         assertEquals("Return value of getContentLength()", fileSize, length);
     }
     
@@ -159,9 +159,9 @@ public class AttachmentsTest extends Abs
     private void testGetRootPartContentID(String contentTypeStartParam, String contentId)
             throws Exception {
         // It doesn't actually matter what the stream *is* it just needs to exist
-        String contentType = "multipart/related; boundary=\"" + TestConstants.MTOM_MESSAGE_BOUNDARY
+
+        String contentType = "multipart/related; boundary=\"" + TestConstants.MTOM_MESSAGE.getBoundary()
+
                 "\"; type=\"text/xml\"; start=\"" + contentTypeStartParam + "\"";
-        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE);
+        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE.getName());
         Attachments attachments = new Attachments(inStream, contentType);
         assertEquals("Did not obtain correct content ID", contentId,
                 attachments.getRootPartContentID());
@@ -203,9 +203,9 @@ public class AttachmentsTest extends Abs
      * is unable to determine the content type.
      */
     public void testGetRootPartContentTypeWithContentIDMismatch() {
-        String contentType = "multipart/related; boundary=\"" + TestConstants.MTOM_MESSAGE_BOUNDARY
+
+        String contentType = "multipart/related; boundary=\"" + TestConstants.MTOM_MESSAGE.getBoundary()
+
                 "\"; type=\"text/xml\"; start=\"<wrong-content-id@example.org>\"";
-        Attachments attachments = new Attachments(getTestResource(TestConstants.MTOM_MESSAGE),
contentType);
+        Attachments attachments = new Attachments(getTestResource(TestConstants.MTOM_MESSAGE.getName()),
contentType);
         try {
             attachments.getRootPartContentType();
             fail("Expected OMException");
@@ -217,8 +217,8 @@ public class AttachmentsTest extends Abs
     }
     
     public void testGetIncomingAttachmentStreams() throws Exception {
-        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE);
-        Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
+        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE.getName());
+        Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE.getContentType());
 
         // Get the inputstream container
         IncomingAttachmentStreams ias = attachments.getIncomingAttachmentStreams();
@@ -253,8 +253,8 @@ public class AttachmentsTest extends Abs
         IncomingAttachmentInputStream dataIs;
         InputStream expectedDataIs;
 
-        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE);
-        Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
+        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE.getName());
+        Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE.getContentType());
 
         // Since SOAP part operated independently of other streams, access it
         // directly, and then get to the streams. If this sequence throws an
@@ -286,8 +286,8 @@ public class AttachmentsTest extends Abs
         InputStream inStream;
         Attachments attachments;
     
-        inStream = getTestResource(TestConstants.MTOM_MESSAGE);
-        attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
+        inStream = getTestResource(TestConstants.MTOM_MESSAGE.getName());
+        attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE.getContentType());
     
         attachments.getDataHandler("2.urn:uuid:A3ADBAEE51A1A87B2A11443668160994@apache.org");
     
@@ -302,8 +302,8 @@ public class AttachmentsTest extends Abs
         inStream.close();
     
         // Try the other way around.
-        inStream = getTestResource(TestConstants.MTOM_MESSAGE);
-        attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
+        inStream = getTestResource(TestConstants.MTOM_MESSAGE.getName());
+        attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE.getContentType());
     
         attachments.getIncomingAttachmentStreams();
     
@@ -351,8 +351,8 @@ public class AttachmentsTest extends Abs
     }
 
     public void testRemoveDataHandlerAfterParsing() {
-        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE);
-        Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
+        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE.getName());
+        Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE.getContentType());
 
         Collection list = attachments.getContentIDSet();
         assertEquals(3, list.size());
@@ -375,8 +375,8 @@ public class AttachmentsTest extends Abs
      * not yet been processed.
      */
     public void testRemoveDataHandlerBeforeParsing() {
-        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE);
-        Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
+        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE.getName());
+        Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE.getContentType());
         attachments.removeDataHandler("1.urn:uuid:A3ADBAEE51A1A87B2A11443668160943@apache.org");
         Set idSet = attachments.getContentIDSet();
         assertEquals(2, idSet.size());
@@ -390,8 +390,8 @@ public class AttachmentsTest extends Abs
      * doesn't contain a MIME part with the specified content ID.
      */
     public void testRemoveDataHandlerNonExistingWithStream() {
-        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE);
-        Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
+        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE.getName());
+        Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE.getContentType());
         attachments.removeDataHandler("non-existing@apache.org");
         assertEquals(3, attachments.getContentIDSet().size());
     }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/PartOnFileTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/PartOnFileTest.java?rev=1196309&r1=1196308&r2=1196309&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/PartOnFileTest.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/PartOnFileTest.java
Tue Nov  1 21:53:43 2011
@@ -49,9 +49,9 @@ public class PartOnFileTest extends Abst
 
     public void testHeaderGetSet() throws Exception {
 
-        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE);
+        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE.getName());
         Attachments attachments =
-                new Attachments(inStream, TestConstants.MTOM_MESSAGE_CONTENT_TYPE, true,
temp.getPath(), "1");
+                new Attachments(inStream, TestConstants.MTOM_MESSAGE.getContentType(), true,
temp.getPath(), "1");
 
         DataHandler dh = attachments
                 .getDataHandler("1.urn:uuid:A3ADBAEE51A1A87B2A11443668160943@apache.org");

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java?rev=1196309&r1=1196308&r2=1196309&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/AbstractTestCase.java
Tue Nov  1 21:53:43 2011
@@ -32,6 +32,7 @@ import javax.activation.DataSource;
 import javax.activation.URLDataSource;
 import javax.xml.parsers.DocumentBuilderFactory;
 
+import org.apache.axiom.attachments.Attachments;
 import org.custommonkey.xmlunit.XMLTestCase;
 import org.w3c.dom.Document;
 import org.w3c.dom.DocumentType;

Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/MIMEResource.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/MIMEResource.java?rev=1196309&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/MIMEResource.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/MIMEResource.java
Tue Nov  1 21:53:43 2011
@@ -0,0 +1,63 @@
+/*
+ * 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.axiom.om;
+
+import javax.mail.internet.ContentType;
+import javax.mail.internet.ParseException;
+
+public class MIMEResource {
+    private final String name;
+    private final String contentType;
+    
+    public MIMEResource(String name, String contentType) {
+        this.name = name;
+        this.contentType = contentType;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getContentType() {
+        return contentType;
+    }
+    
+    private String getParameter(String name) {
+        try {
+            return new ContentType(contentType).getParameter(name);
+        } catch (ParseException ex) {
+            // MIMEResource objects are only defined as constants. Therefore we
+            // will never get here under normal conditions.
+            throw new Error(ex);
+        }
+    }
+    
+    public String getStart() {
+        String start = getParameter("start");
+        if (start.startsWith("<") && start.endsWith(">")) {
+            return start.substring(1, start.length()-1);
+        } else {
+            return start;
+        }
+    }
+    
+    public String getBoundary() {
+        return getParameter("boundary");
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/MIMEResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/TestConstants.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/TestConstants.java?rev=1196309&r1=1196308&r2=1196309&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/TestConstants.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/TestConstants.java
Tue Nov  1 21:53:43 2011
@@ -31,21 +31,21 @@ public class TestConstants {
     public static final String REALLY_BIG_MESSAGE = "soap/reallyReallyBigMessage.xml";
     public static final String EMPTY_BODY_MESSAGE = "soap/emtyBodymessage.xml";
 
-    public static final String MTOM_MESSAGE = "mtom/MTOMAttachmentStream.bin";
-    public static final String MTOM_MESSAGE_BOUNDARY = "MIMEBoundaryurn:uuid:A3ADBAEE51A1A87B2A11443668160701";
-    public static final String MTOM_MESSAGE_START = "0.urn:uuid:A3ADBAEE51A1A87B2A11443668160702@apache.org";
-    public static final String MTOM_MESSAGE_CONTENT_TYPE =
-                        "multipart/related; " +
-                        "boundary=\"" + MTOM_MESSAGE_BOUNDARY + "\"; " +
-                        "type=\"application/xop+xml\"; " +
-                        "start=\"<" + MTOM_MESSAGE_START +">\"; " +
-                        "start-info=\"application/soap+xml\"; " +
-                        "charset=UTF-8;" +
-                        "action=\"mtomSample\"";
+    public static final MIMEResource MTOM_MESSAGE = new MIMEResource("mtom/MTOMAttachmentStream.bin",
+            "multipart/related; " +
+            "boundary=\"MIMEBoundaryurn:uuid:A3ADBAEE51A1A87B2A11443668160701\"; " +
+            "type=\"application/xop+xml\"; " +
+            "start=\"<0.urn:uuid:A3ADBAEE51A1A87B2A11443668160702@apache.org>\"; "
+
+            "start-info=\"application/soap+xml\"; " +
+            "charset=UTF-8;" +
+            "action=\"mtomSample\"");
     public static final String MTOM_MESSAGE_INLINED = "mtom/MTOMAttachmentStream_inlined.xml";
     public static final String MTOM_MESSAGE_IMAGE1 = "mtom/img/test.jpg";
     public static final String MTOM_MESSAGE_IMAGE2 = "mtom/img/test2.jpg";
     
+    public static final MIMEResource MTOM_MESSAGE_2 = new MIMEResource("mtom/MTOMBuilderTestIn.txt",
+            "multipart/Related; charset=\"UTF-8\"; type=\"application/xop+xml\"; " +
+            "boundary=\"----=_AxIs2_Def_boundary_=42214532\"; start=\"SOAPPart\"");
     
     private TestConstants() {
     }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/xop/XOPDecodingStreamReaderTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/xop/XOPDecodingStreamReaderTest.java?rev=1196309&r1=1196308&r2=1196309&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/xop/XOPDecodingStreamReaderTest.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/xop/XOPDecodingStreamReaderTest.java
Tue Nov  1 21:53:43 2011
@@ -34,8 +34,8 @@ import org.apache.axiom.util.base64.Base
 
 public class XOPDecodingStreamReaderTest extends AbstractTestCase {
     private XMLStreamReader getXOPDecodingStreamReader() throws Exception {
-        Attachments attachments = new Attachments(getTestResource(TestConstants.MTOM_MESSAGE),
-                TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
+        Attachments attachments = new Attachments(getTestResource(TestConstants.MTOM_MESSAGE.getName()),
+                TestConstants.MTOM_MESSAGE.getContentType());
         return new XOPDecodingStreamReader(
                 StAXUtils.createXMLStreamReader(attachments.getRootPartInputStream()),
                 new OMAttachmentAccessorMimePartProvider(attachments));

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/xop/XOPEncodingStreamReaderTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/xop/XOPEncodingStreamReaderTest.java?rev=1196309&r1=1196308&r2=1196309&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/xop/XOPEncodingStreamReaderTest.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/xop/XOPEncodingStreamReaderTest.java
Tue Nov  1 21:53:43 2011
@@ -42,8 +42,8 @@ public class XOPEncodingStreamReaderTest
         Attachments[] attachments = new Attachments[2];
         XMLStreamReader[] soapPartReader = new XMLStreamReader[2];
         for (int i=0; i<2; i++) {
-            attachments[i] = new Attachments(getTestResource(TestConstants.MTOM_MESSAGE),
-                    TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
+            attachments[i] = new Attachments(getTestResource(TestConstants.MTOM_MESSAGE.getName()),
+                    TestConstants.MTOM_MESSAGE.getContentType());
             soapPartReader[i] = StAXUtils.createXMLStreamReader(attachments[i].getRootPartInputStream());
         }
         XMLStreamReader actual = new XOPEncodingStreamReader(new XOPDecodingStreamReader(soapPartReader[1],
new OMAttachmentAccessorMimePartProvider(attachments[1])), contentIDGenerator, OptimizationPolicy.DEFAULT);

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java?rev=1196309&r1=1196308&r2=1196309&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java
Tue Nov  1 21:53:43 2011
@@ -20,6 +20,7 @@
 package org.apache.axiom.attachments;
 
 import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.om.MIMEResource;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.OMXMLBuilderFactory;
@@ -40,18 +41,17 @@ public class AttachmentsTest extends Abs
         super(testName);
     }
 
-    String img1FileName = "mtom/img/test.jpg";
-    String img2FileName = "mtom/img/test2.jpg";
     String inSWAFileName = "soap/soap11/SWAAttachmentStream.txt";
     
     String contentTypeString =
         "multipart/related; boundary=\"MIMEBoundaryurn:uuid:A3ADBAEE51A1A87B2A11443668160701\";
type=\"application/xop+xml\"; start=\"<0.urn:uuid:A3ADBAEE51A1A87B2A11443668160702@apache.org>\";
start-info=\"application/soap+xml\"; charset=UTF-8;action=\"mtomSample\"";
 
     public void testWritingBinaryAttachments() throws Exception {
+        MIMEResource testMessage = TestConstants.MTOM_MESSAGE;
 
         // Read in message: SOAPPart and 2 image attachments
-        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE);
-        Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
+        InputStream inStream = getTestResource(testMessage.getName());
+        Attachments attachments = new Attachments(inStream, testMessage.getContentType());
         
         attachments.getRootPartInputStream();
 
@@ -59,8 +59,8 @@ public class AttachmentsTest extends Abs
         
         OMOutputFormat oof = new OMOutputFormat();
         oof.setDoOptimize(true);
-        oof.setMimeBoundary(TestConstants.MTOM_MESSAGE_BOUNDARY);
-        oof.setRootContentId(TestConstants.MTOM_MESSAGE_START);
+        oof.setMimeBoundary(testMessage.getBoundary());
+        oof.setRootContentId(testMessage.getStart());
         
         // Write out the message
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -98,7 +98,7 @@ public class AttachmentsTest extends Abs
         
         // Now read the data back in
         InputStream is = new ByteArrayInputStream(outBase64.getBytes());
-        Attachments attachments2 = new Attachments(is, TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
+        Attachments attachments2 = new Attachments(is, testMessage.getContentType());
         
         // Now write it back out with binary...
         baos = new ByteArrayOutputStream();

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java?rev=1196309&r1=1196308&r2=1196309&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java
Tue Nov  1 21:53:43 2011
@@ -28,6 +28,7 @@ import org.apache.axiom.om.OMOutputForma
 import org.apache.axiom.om.OMText;
 import org.apache.axiom.om.OMXMLBuilderFactory;
 import org.apache.axiom.om.OMXMLStreamReader;
+import org.apache.axiom.om.TestConstants;
 import org.apache.axiom.om.impl.builder.StAXBuilder;
 import org.apache.axiom.soap.SOAPModelBuilder;
 import org.apache.axiom.util.stax.XMLStreamReaderUtils;
@@ -62,11 +63,8 @@ public class MTOMStAXSOAPModelBuilderTes
     }
 
     private Attachments createAttachmentsForTestMTOMMessage() throws Exception {
-        String contentTypeString =
-                "multipart/Related; charset=\"UTF-8\"; type=\"application/xop+xml\"; boundary=\"----=_AxIs2_Def_boundary_=42214532\";
start=\"SOAPPart\"";
-        String inFileName = "mtom/MTOMBuilderTestIn.txt";
-        InputStream inStream = getTestResource(inFileName);
-        return new Attachments(inStream, contentTypeString);
+        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE_2.getName());
+        return new Attachments(inStream, TestConstants.MTOM_MESSAGE_2.getContentType());
     }
 
     private OMElement createTestMTOMMessage() throws Exception {

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/envelope/TestBuildWithAttachments.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/envelope/TestBuildWithAttachments.java?rev=1196309&r1=1196308&r2=1196309&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/envelope/TestBuildWithAttachments.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/envelope/TestBuildWithAttachments.java
Tue Nov  1 21:53:43 2011
@@ -40,8 +40,8 @@ public class TestBuildWithAttachments ex
     }
 
     protected void runTest() throws Throwable {
-        InputStream in = AbstractTestCase.getTestResource(TestConstants.MTOM_MESSAGE);
-        Attachments attachments = new Attachments(in, TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
+        InputStream in = AbstractTestCase.getTestResource(TestConstants.MTOM_MESSAGE.getName());
+        Attachments attachments = new Attachments(in, TestConstants.MTOM_MESSAGE.getContentType());
         SOAPEnvelope envelope = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, attachments).getSOAPEnvelope();
         envelope.buildWithAttachments();
         in.close();



Mime
View raw message