You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ve...@apache.org on 2009/01/01 17:16:35 UTC

svn commit: r730561 - in /webservices/commons/trunk/modules/axiom/modules: axiom-api/src/test/java/org/apache/axiom/attachments/impl/ axiom-tests/src/test/java/org/apache/axiom/attachments/impl/

Author: veithen
Date: Thu Jan  1 08:16:34 2009
New Revision: 730561

URL: http://svn.apache.org/viewvc?rev=730561&view=rev
Log:
Moved BufferUtilsTest to axiom-api.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/impl/
      - copied from r730558, webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/impl/
Removed:
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/attachments/impl/
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/impl/BufferUtilsTest.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/impl/BufferUtilsTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/impl/BufferUtilsTest.java?rev=730561&r1=730558&r2=730561&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/impl/BufferUtilsTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/attachments/impl/BufferUtilsTest.java Thu Jan  1 08:16:34 2009
@@ -22,19 +22,21 @@
 import javax.activation.FileDataSource;
 import javax.mail.util.ByteArrayDataSource;
 
-import org.apache.axiom.om.AbstractTestCase;
-
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.RandomAccessFile;
+
+import junit.framework.TestCase;
 
 /**
  * Simple test for the BufferUtils copying code
  */
-public class BufferUtilsTest extends AbstractTestCase {
+public class BufferUtilsTest extends TestCase {
 
     byte[] bytes;
     static final int MAX = 1024 * 1024;
@@ -78,17 +80,27 @@
         }    
     }
     
-    public void testDataSourceBackedDataHandlerExceedLimit(){
-        File imgFile = getTestResourceFile("mtom/img/test2.jpg");
-        FileDataSource fds = new FileDataSource(imgFile);
-        DataHandler dh = new DataHandler(fds);
-        int unsupported= BufferUtils.doesDataHandlerExceedLimit(dh, 0);
-        assertEquals(unsupported, -1);
-        int doesExceed = BufferUtils.doesDataHandlerExceedLimit(dh, 1000);
-        assertEquals(doesExceed, 1);
-        int doesNotExceed = BufferUtils.doesDataHandlerExceedLimit(dh, 100000);
-        assertEquals(doesNotExceed, 0);
-        
+    public void testDataSourceBackedDataHandlerExceedLimit() throws IOException {
+        File file =  File.createTempFile("bufferUtils", "tst");
+        file.deleteOnExit();
+        try {
+            RandomAccessFile raf = new RandomAccessFile(file, "rw");
+            try {
+                raf.setLength(5000);
+            } finally {
+                raf.close();
+            }
+            FileDataSource fds = new FileDataSource(file);
+            DataHandler dh = new DataHandler(fds);
+            int unsupported= BufferUtils.doesDataHandlerExceedLimit(dh, 0);
+            assertEquals(unsupported, -1);
+            int doesExceed = BufferUtils.doesDataHandlerExceedLimit(dh, 1000);
+            assertEquals(doesExceed, 1);
+            int doesNotExceed = BufferUtils.doesDataHandlerExceedLimit(dh, 100000);
+            assertEquals(doesNotExceed, 0);
+        } finally {
+            file.delete();
+        }    
     }
     
     public void testObjectBackedDataHandlerExceedLimit(){