axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r761068 - in /webservices/axis2/trunk/java/modules/saaj: ./ test/org/apache/axis2/saaj/ test/org/apache/axis2/saaj/integration/
Date Wed, 01 Apr 2009 21:35:46 GMT
Author: veithen
Date: Wed Apr  1 21:35:45 2009
New Revision: 761068

URL: http://svn.apache.org/viewvc?rev=761068&view=rev
Log:
SAAJ tests: load test files from classpath (instead of test-resources or target\test-resources).
Also solves AXIS2-4295.

Added:
    webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/TestUtils.java  
(contents, props changed)
      - copied, changed from r761027, webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/TestConstants.java
Removed:
    webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/TestConstants.java
Modified:
    webservices/axis2/trunk/java/modules/saaj/pom.xml
    webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/AttachmentSerializationTest.java
    webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/AttachmentTest.java
    webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/MessageFactoryTest.java
    webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPBodyTest.java
    webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPMessageTest.java
    webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPPartTest.java
    webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/integration/IntegrationTest.java

Modified: webservices/axis2/trunk/java/modules/saaj/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/pom.xml?rev=761068&r1=761067&r2=761068&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/pom.xml (original)
+++ webservices/axis2/trunk/java/modules/saaj/pom.xml Wed Apr  1 21:35:45 2009
@@ -122,18 +122,7 @@
                 <targetPath>../test-resources/saaj-repo</targetPath>
             </testResource>
             <testResource>
-                <targetPath>../test-resources</targetPath>
                 <directory>test-resources</directory>
-                <includes>
-                    <include>**/*.*</include>
-                </includes>
-            </testResource>
-            <testResource>
-                <targetPath></targetPath>
-                <directory>test-resources</directory>
-                <includes>
-                    <include>**/*.properties</include>
-                </includes>
             </testResource>
         </testResources>
         <plugins>

Modified: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/AttachmentSerializationTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/AttachmentSerializationTest.java?rev=761068&r1=761067&r2=761068&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/AttachmentSerializationTest.java
(original)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/AttachmentSerializationTest.java
Wed Apr  1 21:35:45 2009
@@ -22,7 +22,6 @@
 import junit.framework.Assert;
 
 import javax.activation.DataHandler;
-import javax.activation.FileDataSource;
 import javax.xml.soap.AttachmentPart;
 import javax.xml.soap.MessageFactory;
 import javax.xml.soap.MimeHeaders;
@@ -92,10 +91,7 @@
         msg.addAttachmentPart(ap);
 
         // Second attachment
-        String jpgfilename = System.getProperty("basedir", ".") + "/" + "test-resources/axis2.jpg";
-        File myfile = new File(jpgfilename);
-        FileDataSource fds = new FileDataSource(myfile);
-        DataHandler dh = new DataHandler(fds);
+        DataHandler dh = new DataHandler(TestUtils.getTestFileAsDataSource("axis2.jpg"));
         AttachmentPart ap2 = msg.createAttachmentPart(dh);
         ap2.setContentType("image/jpg");
         msg.addAttachmentPart(ap2);

Modified: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/AttachmentTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/AttachmentTest.java?rev=761068&r1=761067&r2=761068&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/AttachmentTest.java
(original)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/AttachmentTest.java
Wed Apr  1 21:35:45 2009
@@ -44,8 +44,6 @@
 import java.awt.*;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -154,8 +152,7 @@
     @Validated @Test
     public void testClearContent() throws Exception {
         try {
-            InputStream in1 = new FileInputStream(new File(System.getProperty("basedir",
".") +
-                    "/test-resources" + File.separator + "attach.xml"));
+            InputStream in1 = TestUtils.getTestFile("attach.xml");
 
             MessageFactory factory = MessageFactory.newInstance();
             SOAPMessage message = factory.createMessage();
@@ -235,8 +232,7 @@
             MessageFactory factory = MessageFactory.newInstance();
             SOAPMessage msg = factory.createMessage();
             AttachmentPart ap = msg.createAttachmentPart();
-            Image image = ImageIO.read(new File(System.getProperty("basedir", ".") +
-                    "/test-resources" + File.separator + "attach.gif"));
+            Image image = ImageIO.read(TestUtils.getTestFileURL("attach.gif"));
             ap = msg.createAttachmentPart(image, "image/gif");
 
             //Getting Content should return an Image object

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=761068&r1=761067&r2=761068&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 Apr  1 21:35:45 2009
@@ -34,7 +34,6 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.FileInputStream;
 import java.io.InputStream;
 import java.util.Iterator;
 
@@ -146,8 +145,8 @@
     @Validated @Test
     public void testParseMTOMMessage() throws Exception {
         MimeHeaders headers = new MimeHeaders();
-        headers.addHeader("Content-Type", TestConstants.MTOM_TEST_MESSAGE_CONTENT_TYPE);
-        InputStream in = new FileInputStream(TestConstants.MTOM_TEST_MESSAGE_FILE);
+        headers.addHeader("Content-Type", TestUtils.MTOM_TEST_MESSAGE_CONTENT_TYPE);
+        InputStream in = TestUtils.getTestFile(TestUtils.MTOM_TEST_MESSAGE_FILE);
         SOAPMessage message = mf.createMessage(headers, in);
         SOAPPart soapPart = message.getSOAPPart();
         assertEquals("<0.urn:uuid:F02ECC18873CFB73E211412748909308@apache.org>",
@@ -180,8 +179,7 @@
                 "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");
+        InputStream in = TestUtils.getTestFile("SwAmessage.bin");
         SOAPMessage message = mf.createMessage(headers, in);
         SOAPPart soapPart = message.getSOAPPart();
         assertEquals("<0.urn:uuid:E3F7CE4554928DA89B1231365678617@apache.org>",

Modified: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPBodyTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPBodyTest.java?rev=761068&r1=761067&r2=761068&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPBodyTest.java
(original)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPBodyTest.java
Wed Apr  1 21:35:45 2009
@@ -42,7 +42,6 @@
 import javax.xml.soap.SOAPMessage;
 import javax.xml.soap.SOAPPart;
 import javax.xml.soap.Text;
-import java.io.File;
 import java.util.Iterator;
 
 @RunWith(SAAJTestRunner.class)
@@ -119,8 +118,7 @@
             factory.setNamespaceAware(true);
 
             DocumentBuilder builder = factory.newDocumentBuilder();
-            document = builder.parse(new File(System.getProperty("basedir", ".") + "/" +
-                    "test-resources" + File.separator + "soap-body.xml"));
+            document = builder.parse(TestUtils.getTestFileURI("soap-body.xml"));
             MessageFactory fact = MessageFactory.newInstance();
             SOAPMessage message = fact.createMessage();
 

Modified: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPMessageTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPMessageTest.java?rev=761068&r1=761067&r2=761068&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPMessageTest.java
(original)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPMessageTest.java
Wed Apr  1 21:35:45 2009
@@ -142,18 +142,15 @@
             SOAPFault sf = body.addFault();
 
 
-            InputStream in1 = new FileInputStream(new File(System.getProperty("basedir",
".") +
-                    "/target/test-resources" + File.separator + "attach.xml"));
+            InputStream in1 = TestUtils.getTestFile("attach.xml");
             ap1 = msg.createAttachmentPart(in1, "text/xml");
             msg.addAttachmentPart(ap1);
 
-            InputStream in2 = new FileInputStream(new File(System.getProperty("basedir",
".") +
-                    "/target/test-resources" + File.separator + "axis2.xml"));
+            InputStream in2 = TestUtils.getTestFile("axis2.xml");
             ap2 = msg.createAttachmentPart(in2, "text/xml");
             msg.addAttachmentPart(ap2);
 
-            InputStream in3 = new FileInputStream(new File(System.getProperty("basedir",
".") +
-                    "/target/test-resources" + File.separator + "axis2.xml"));
+            InputStream in3 = TestUtils.getTestFile("axis2.xml");
             ap3 = msg.createAttachmentPart(in3, "text/plain");
             msg.addAttachmentPart(ap3);
 
@@ -203,9 +200,7 @@
 
             AttachmentPart ap;
 
-            InputStream inputStream = new FileInputStream(new File(System
-                    .getProperty("basedir", ".") + "/test-resources" + File.separator +
-                    "attach.xml"));
+            InputStream inputStream = TestUtils.getTestFile("attach.xml");
             ap = msg.createAttachmentPart(inputStream, "text/xml");
             DataHandler dh =
                     new DataHandler(new SAAJDataSource(inputStream, 1000, "text/xml", true));

Modified: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPPartTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPPartTest.java?rev=761068&r1=761067&r2=761068&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPPartTest.java
(original)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPPartTest.java
Wed Apr  1 21:35:45 2009
@@ -62,8 +62,7 @@
         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
         dbf.setNamespaceAware(true);
         DocumentBuilder builder = dbf.newDocumentBuilder();
-        Document document = builder.parse(new File(System.getProperty("basedir", ".") +
-                "/test-resources" + File.separator + "soap-part.xml"));
+        Document document = builder.parse(TestUtils.getTestFileURI("soap-part.xml"));
         DOMSource domSource = new DOMSource(document);
 
         SOAPMessage message = MessageFactory.newInstance().createMessage();

Copied: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/TestUtils.java
(from r761027, webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/TestConstants.java)
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/TestUtils.java?p2=webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/TestUtils.java&p1=webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/TestConstants.java&r1=761027&r2=761068&rev=761068&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/TestConstants.java
(original)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/TestUtils.java Wed
Apr  1 21:35:45 2009
@@ -19,9 +19,14 @@
 
 package org.apache.axis2.saaj;
 
-public class TestConstants {
-    public static final String MTOM_TEST_MESSAGE_FILE =
-            System.getProperty("basedir", ".") + "/test-resources/message.bin";
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.activation.DataSource;
+import javax.activation.URLDataSource;
+
+public class TestUtils {
+    public static final String MTOM_TEST_MESSAGE_FILE = "message.bin";
     public static final String MTOM_TEST_MESSAGE_CONTENT_TYPE =
             "multipart/related; " +
             "boundary=\"MIMEBoundaryurn:uuid:F02ECC18873CFB73E211412748909307\"; " +
@@ -31,5 +36,21 @@
             "charset=UTF-8;" +
             "action=\"mtomSample\"";
     
-    private TestConstants() {}
+    private TestUtils() {}
+    
+    public static InputStream getTestFile(String name) {
+        return TestUtils.class.getClassLoader().getResourceAsStream(name);
+    }
+    
+    public static DataSource getTestFileAsDataSource(String name) {
+        return new URLDataSource(TestUtils.class.getClassLoader().getResource(name));
+    }
+    
+    public static URL getTestFileURL(String name) {
+        return TestUtils.class.getClassLoader().getResource(name);
+    }
+    
+    public static String getTestFileURI(String name) {
+        return TestUtils.class.getClassLoader().getResource(name).toExternalForm();
+    }
 }

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

Propchange: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/TestUtils.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed Apr  1 21:35:45 2009
@@ -0,0 +1 @@
+/webservices/axis2/branches/java/1_5/modules/saaj/test/org/apache/axis2/saaj/TestConstants.java:745088,749052,749058,751161,751271,760467

Modified: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/integration/IntegrationTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/integration/IntegrationTest.java?rev=761068&r1=761067&r2=761068&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/integration/IntegrationTest.java
(original)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/integration/IntegrationTest.java
Wed Apr  1 21:35:45 2009
@@ -28,7 +28,7 @@
 import org.apache.axis2.engine.MessageReceiver;
 import org.apache.axis2.receivers.AbstractInOutMessageReceiver;
 import org.apache.axis2.saaj.SAAJTestRunner;
-import org.apache.axis2.saaj.TestConstants;
+import org.apache.axis2.saaj.TestUtils;
 import org.apache.axis2.saaj.Validated;
 import org.apache.axis2.util.Utils;
 import org.junit.After;
@@ -41,7 +41,6 @@
 import org.w3c.dom.Node;
 
 import javax.activation.DataHandler;
-import javax.activation.FileDataSource;
 import javax.xml.namespace.QName;
 import javax.xml.soap.AttachmentPart;
 import javax.xml.soap.MessageFactory;
@@ -61,7 +60,6 @@
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -200,10 +198,7 @@
         request.addAttachmentPart(textAttach);
 
         //Attach a java.awt.Image object to the SOAP request
-        String jpgfilename = System.getProperty("basedir", ".") + "/" + "test-resources/axis2.jpg";
-        File myfile = new File(jpgfilename);
-        FileDataSource fds = new FileDataSource(myfile);
-        DataHandler imageDH = new DataHandler(fds);
+        DataHandler imageDH = new DataHandler(TestUtils.getTestFileAsDataSource("axis2.jpg"));
         AttachmentPart jpegAttach = request.createAttachmentPart(imageDH);
         jpegAttach.addMimeHeader("Content-Transfer-Encoding", "binary");
         jpegAttach.setContentId("submitSampleImage@apache.org");
@@ -316,9 +311,8 @@
     	MimeHeaders mimeHeaders = new MimeHeaders();
         mimeHeaders.addHeader("Content-Type", "text/xml; charset=iso-8859-1");
         
-        FileInputStream fileInputStream = new FileInputStream(System.getProperty("basedir",
".") +
-                "/test-resources" + File.separator + "soap-part-iso-8859-1.xml");
-        SOAPMessage requestMessage = MessageFactory.newInstance().createMessage(mimeHeaders,fileInputStream);
+        InputStream inputStream = TestUtils.getTestFile("soap-part-iso-8859-1.xml");
+        SOAPMessage requestMessage = MessageFactory.newInstance().createMessage(mimeHeaders,
inputStream);
         
 
         SOAPConnection sCon = SOAPConnectionFactory.newInstance().createConnection();
@@ -356,8 +350,8 @@
         MessageFactory mf = MessageFactory.newInstance();
         
         MimeHeaders headers = new MimeHeaders();
-        headers.addHeader("Content-Type", TestConstants.MTOM_TEST_MESSAGE_CONTENT_TYPE);
-        InputStream in = new FileInputStream(TestConstants.MTOM_TEST_MESSAGE_FILE);
+        headers.addHeader("Content-Type", TestUtils.MTOM_TEST_MESSAGE_CONTENT_TYPE);
+        InputStream in = TestUtils.getTestFile(TestUtils.MTOM_TEST_MESSAGE_FILE);
         SOAPMessage request = mf.createMessage(headers, in);
         SOAPEnvelope envelope = request.getSOAPPart().getEnvelope();
         



Mime
View raw message