commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r760394 - /commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/IOMethodsTest.java
Date Tue, 31 Mar 2009 10:55:55 GMT
Author: sebb
Date: Tue Mar 31 10:55:48 2009
New Revision: 760394

URL: http://svn.apache.org/viewvc?rev=760394&view=rev
Log:
Allow for unknown size
Fix bug - use actual size read rather than buffer size when comparing data

Modified:
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/IOMethodsTest.java

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/IOMethodsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/IOMethodsTest.java?rev=760394&r1=760393&r2=760394&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/IOMethodsTest.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/IOMethodsTest.java
Tue Mar 31 10:55:48 2009
@@ -123,9 +123,12 @@
         ArchiveInputStream ais1 = factory.createArchiveInputStream(archiverName, is1);
         final ArchiveEntry nextEntry = ais1.getNextEntry();
         assertNotNull(nextEntry);
-        final long size = nextEntry.getSize();
-        assertTrue("Size > 0: "+size, size > 0);
-        byte [] buff = new byte[(int)size];
+        
+        byte [] buff = new byte[10]; // small so multiple reads are needed;
+        long size = nextEntry.getSize();
+        if (size != ArchiveEntry.SIZE_UNKNOWN) {
+            assertTrue("Size should be > 0, found: "+size, size > 0);
+        }
         
         InputStream is2 = new FileInputStream(file);
         ArchiveInputStream ais2 = factory.createArchiveInputStream(archiverName, is2);
@@ -145,13 +148,14 @@
         }
         ais1.close();
 
-        while(ais2.read(buff)>0){
-            out2.write(buff);
+        int bytes;
+        while((bytes = ais2.read(buff)) > 0){
+            out2.write(buff, 0, bytes);
         }
         ais2.close();
         
-        while(ais3.read(buff, 0 , buff.length)>0){
-            out3.write(buff);
+        while((bytes=ais3.read(buff, 0 , buff.length)) > 0){
+            out3.write(buff, 0, bytes);
         }
         ais3.close();
 



Mime
View raw message