Author: veithen
Date: Thu May 21 21:55:37 2009
New Revision: 777278

URL: http://svn.apache.org/viewvc?rev=777278&view=rev
Log:
Eliminated some duplicate constants.

Modified:
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/IncomingAttachmentTest.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-tests/src/test/java/org/apache/axiom/attachments/AttachmentsTest.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/PartOnFileTest.java

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/IncomingAttachmentTest.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/IncomingAttachmentTest.java?rev=777278&r1=777277&r2=777278&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/IncomingAttachmentTest.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/IncomingAttachmentTest.java
 Thu May 21 21:55:37 2009
@@ -20,6 +20,7 @@
 package org.apache.axiom.attachments;
 
 import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.om.TestConstants;
 
 import java.io.File;
 import java.io.InputStream;
@@ -28,14 +29,11 @@
 /** Test the PartOnFile class */
 
 public class IncomingAttachmentTest extends AbstractTestCase {
-    String inMimeFileName = "mtom/MTOMAttachmentStream.bin";
-    String contentTypeString =
-            "multipart/related; 
boundary=\"MIMEBoundaryurn:uuid:A3ADBAEE51A1A87B2A11443668160701\"; 
type=\"application/xop+xml\"; 
start=\"<0.urn:uuid:[email protected]>\"; 
start-info=\"application/soap+xml\"; charset=UTF-8;action=\"mtomSample\"";
     File temp;
 
     public void testIncomingAttachmentInputStreamFunctions() throws Exception {
-        InputStream inStream = getTestResource(inMimeFileName);
-        Attachments attachments = new Attachments(inStream, contentTypeString);
+        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE);
+        Attachments attachments = new Attachments(inStream, 
TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
 
         // Get the inputstream container
         IncomingAttachmentStreams ias = 
attachments.getIncomingAttachmentStreams();

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=777278&r1=777277&r2=777278&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
 Thu May 21 21:55:37 2009
@@ -35,6 +35,19 @@
     public static final String BAD_ENVELOPE_MISSING = 
"badsoap/envelopeMissing.xml";
     public static final String BAD_HEADER_BODY_WRONG_ORDER = 
"badsoap/haederBodyWrongOrder.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:[email protected]";
+    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\"";
+    
+    
     private TestConstants() {
     }
 

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=777278&r1=777277&r2=777278&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
 Thu May 21 21:55:37 2009
@@ -23,6 +23,7 @@
 import org.apache.axiom.om.AbstractTestCase;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.om.TestConstants;
 import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
 import org.apache.axiom.om.impl.builder.XOPAwareStAXOMBuilder;
 
@@ -41,21 +42,9 @@
         super(testName);
     }
 
-    String inMimeFileName = "mtom/MTOMAttachmentStream.bin";
     String img1FileName = "mtom/img/test.jpg";
     String img2FileName = "mtom/img/test2.jpg";
 
-    String boundary = "MIMEBoundaryurn:uuid:A3ADBAEE51A1A87B2A11443668160701";
-    String start= "0.urn:uuid:[email protected]";
-    String contentTypeString =
-                        "multipart/related; " +
-                        "boundary=\"" + boundary + "\"; " +
-                        "type=\"application/xop+xml\"; " +
-                        "start=\"<" + start +">\"; " +
-                        "start-info=\"application/soap+xml\"; " +
-                        "charset=UTF-8;" +
-                        "action=\"mtomSample\"";
-
     public void testMIMEHelper() {
     }
 
@@ -66,8 +55,8 @@
         InputStream inStream;
         Attachments attachments;
 
-        inStream = getTestResource(inMimeFileName);
-        attachments = new Attachments(inStream, contentTypeString);
+        inStream = getTestResource(TestConstants.MTOM_MESSAGE);
+        attachments = new Attachments(inStream, 
TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
 
         
attachments.getDataHandler("2.urn:uuid:[email protected]");
 
@@ -82,8 +71,8 @@
         inStream.close();
 
         // Try the other way around.
-        inStream = getTestResource(inMimeFileName);
-        attachments = new Attachments(inStream, contentTypeString);
+        inStream = getTestResource(TestConstants.MTOM_MESSAGE);
+        attachments = new Attachments(inStream, 
TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
 
         attachments.getIncomingAttachmentStreams();
 
@@ -135,8 +124,8 @@
         IncomingAttachmentInputStream dataIs;
         InputStream expectedDataIs;
 
-        InputStream inStream = getTestResource(inMimeFileName);
-        Attachments attachments = new Attachments(inStream, contentTypeString);
+        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE);
+        Attachments attachments = new Attachments(inStream, 
TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
 
         // Since SOAP part operated independently of other streams, access it
         // directly, and then get to the streams. If this sequence throws an
@@ -167,8 +156,8 @@
     public void testWritingBinaryAttachments() throws Exception {
 
         // Read in message: SOAPPart and 2 image attachments
-        InputStream inStream = getTestResource(inMimeFileName);
-        Attachments attachments = new Attachments(inStream, contentTypeString);
+        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE);
+        Attachments attachments = new Attachments(inStream, 
TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
         
         attachments.getSOAPPartInputStream();
 
@@ -176,8 +165,8 @@
         
         OMOutputFormat oof = new OMOutputFormat();
         oof.setDoOptimize(true);
-        oof.setMimeBoundary(boundary);
-        oof.setRootContentId(start);
+        oof.setMimeBoundary(TestConstants.MTOM_MESSAGE_BOUNDARY);
+        oof.setRootContentId(TestConstants.MTOM_MESSAGE_START);
         
         // Write out the message
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -213,7 +202,7 @@
         
         // Now read the data back in
         InputStream is = new ByteArrayInputStream(outBase64.getBytes());
-        Attachments attachments2 = new Attachments(is, contentTypeString);
+        Attachments attachments2 = new Attachments(is, 
TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
         
         // Now write it back out with binary...
         baos = new ByteArrayOutputStream();
@@ -262,8 +251,8 @@
 
     public void testGetDataHandler() throws Exception {
 
-        InputStream inStream = getTestResource(inMimeFileName);
-        Attachments attachments = new Attachments(inStream, contentTypeString);
+        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE);
+        Attachments attachments = new Attachments(inStream, 
TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
 
         DataHandler dh = attachments
                 
.getDataHandler("2.urn:uuid:[email protected]");
@@ -277,8 +266,8 @@
 
     public void testNonExistingMIMEPart() throws Exception {
 
-        InputStream inStream = getTestResource(inMimeFileName);
-        Attachments attachments = new Attachments(inStream, contentTypeString);
+        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE);
+        Attachments attachments = new Attachments(inStream, 
TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
 
         DataHandler dh = attachments.getDataHandler("ThisShouldReturnNull");
         assertNull(dh);
@@ -286,8 +275,8 @@
 
     public void testGetAllContentIDs() throws Exception {
 
-        InputStream inStream = getTestResource(inMimeFileName);
-        Attachments attachments = new Attachments(inStream, contentTypeString);
+        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE);
+        Attachments attachments = new Attachments(inStream, 
TestConstants.MTOM_MESSAGE_CONTENT_TYPE);
 
         String[] contentIDs = attachments.getAllContentIDs();
         assertEquals(contentIDs.length, 3);
@@ -302,7 +291,7 @@
         
         // Make sure the length is correct
         long length = attachments.getContentLength();
-        long fileSize = 
IOUtils.getStreamAsByteArray(getTestResource(inMimeFileName)).length;
+        long fileSize = 
IOUtils.getStreamAsByteArray(getTestResource(TestConstants.MTOM_MESSAGE)).length;
         assertTrue("Expected MessageContent Length of " + fileSize + " but 
received " + length,
                    length == fileSize);
     }
@@ -335,9 +324,9 @@
     private void testGetSOAPPartContentID(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=\"" + boundary +
+        String contentType = "multipart/related; boundary=\"" + 
TestConstants.MTOM_MESSAGE_BOUNDARY +
                 "\"; type=\"text/xml\"; start=\"" + contentTypeStartParam + 
"\"";
-        InputStream inStream = getTestResource(inMimeFileName);
+        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE);
         Attachments attachments = new Attachments(inStream, contentType);
         assertEquals("Did not obtain correct content ID", contentId,
                 attachments.getSOAPPartContentID());

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/PartOnFileTest.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/PartOnFileTest.java?rev=777278&r1=777277&r2=777278&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/PartOnFileTest.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/PartOnFileTest.java
 Thu May 21 21:55:37 2009
@@ -20,6 +20,7 @@
 package org.apache.axiom.attachments;
 
 import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.om.TestConstants;
 
 import javax.activation.DataHandler;
 import javax.activation.FileDataSource;
@@ -35,10 +36,6 @@
         super(testName);
     }
 
-    String inMimeFileName = "mtom/MTOMAttachmentStream.bin";
-    String contentTypeString =
-            "multipart/related; 
boundary=\"MIMEBoundaryurn:uuid:A3ADBAEE51A1A87B2A11443668160701\"; 
type=\"application/xop+xml\"; 
start=\"<0.urn:uuid:[email protected]>\"; 
start-info=\"application/soap+xml\"; charset=UTF-8;action=\"mtomSample\"";
-
     File temp;
 
     public void setUp() throws Exception {
@@ -51,9 +48,9 @@
 
     public void testHeaderGetSet() throws Exception {
 
-        InputStream inStream = getTestResource(inMimeFileName);
+        InputStream inStream = getTestResource(TestConstants.MTOM_MESSAGE);
         Attachments attachments =
-                new Attachments(inStream, contentTypeString, true, 
temp.getPath(), "1");
+                new Attachments(inStream, 
TestConstants.MTOM_MESSAGE_CONTENT_TYPE, true, temp.getPath(), "1");
 
         DataHandler p = attachments
                 
.getDataHandler("1.urn:uuid:[email protected]");


Reply via email to