harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r989780 - in /harmony/enhanced/java/trunk/classlib/modules/archive/src: main/java/java/util/zip/Deflater.java test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterTest.java
Date Thu, 26 Aug 2010 15:49:52 GMT
Author: odeakin
Date: Thu Aug 26 15:49:52 2010
New Revision: 989780

URL: http://svn.apache.org/viewvc?rev=989780&view=rev
Log:
Apply patch for HARMONY-6623 ([classlib][archive]Deflater.setlevel/setStrategy throws IllegalStateException
if inputBuffer is not null)

Modified:
    harmony/enhanced/java/trunk/classlib/modules/archive/src/main/java/java/util/zip/Deflater.java
    harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterTest.java

Modified: harmony/enhanced/java/trunk/classlib/modules/archive/src/main/java/java/util/zip/Deflater.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/archive/src/main/java/java/util/zip/Deflater.java?rev=989780&r1=989779&r2=989780&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/archive/src/main/java/java/util/zip/Deflater.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/archive/src/main/java/java/util/zip/Deflater.java
Thu Aug 26 15:49:52 2010
@@ -451,9 +451,6 @@ public class Deflater {
         if (level < DEFAULT_COMPRESSION || level > BEST_COMPRESSION) {
             throw new IllegalArgumentException();
         }
-        if (inputBuffer != null) {
-            throw new IllegalStateException();
-        }
         compressLevel = level;
     }
 
@@ -472,9 +469,6 @@ public class Deflater {
         if (strategy < DEFAULT_STRATEGY || strategy > HUFFMAN_ONLY) {
             throw new IllegalArgumentException();
         }
-        if (inputBuffer != null) {
-            throw new IllegalStateException();
-        }
         this.strategy = strategy;
     }
 

Modified: harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterTest.java?rev=989780&r1=989779&r2=989780&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterTest.java
Thu Aug 26 15:49:52 2010
@@ -676,6 +676,22 @@ public class DeflaterTest extends TestCa
 			defl.end();
 		}
 
+        //test setLevel - Call after inputArray 
+        Deflater defl = new Deflater();
+        defl.setLevel(2);
+        outPutBuf = new byte[500];
+        defl.setInput(byteArray);
+        defl.setLevel(3);
+        while (!defl.needsInput()) {
+            defl.deflate(outPutBuf);
+        }
+        defl.finish();
+        while (!defl.finished()) {
+            defl.deflate(outPutBuf);
+        }
+        totalOut = defl.getTotalOut();
+        defl.end();
+
 		// testing boundaries
 		try {
 			Deflater boundDefl = new Deflater();
@@ -745,6 +761,21 @@ public class DeflaterTest extends TestCa
 			mdefl.end();
 		}
 
+		//Call setStrategy after setInput call
+        byte outPutBuf[] = new byte[500];
+        MyDeflater mdefl = new MyDeflater();
+        mdefl.setStrategy(mdefl.getDefStrategy());
+        mdefl.setInput(byteArray);
+        mdefl.setStrategy(mdefl.getHuffman());
+        while (!mdefl.needsInput()) {
+            mdefl.deflate(outPutBuf);
+        }
+        mdefl.finish();
+        while (!mdefl.finished()) {
+            mdefl.deflate(outPutBuf);
+        }
+        mdefl.end();
+
 		// Attempting to setStrategy to an invalid value
 		try {
 			Deflater defl = new Deflater();



Mime
View raw message