You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gh...@apache.org on 2006/04/10 18:45:31 UTC
svn commit: r392984 - in
/incubator/harmony/enhanced/classlib/trunk/modules/archive/src:
main/java/java/util/zip/ test/java/org/apache/harmony/tests/java/util/zip/
Author: gharley
Date: Mon Apr 10 09:45:29 2006
New Revision: 392984
URL: http://svn.apache.org/viewcvs?rev=392984&view=rev
Log:
HARMONY 158 : Two JSE 5 methods are not implemented in java.util.zip.Deflator
Added:
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/tests/java/util/zip/DeflaterTest.java (with props)
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/tests/java/util/zip/AllTests.java
incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/tests/java/util/zip/InflaterTest.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java?rev=392984&r1=392983&r2=392984&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Deflater.java Mon Apr 10 09:45:29 2006
@@ -1,4 +1,4 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -373,22 +373,28 @@
}
/**
- * return a long int instead of int
- * @see getTotalIn
- * @return bytes exactly read by deflater
- */
- public synchronized long getBytesRead() {
- // Throw NPE here
- if (streamHandle == -1)
- throw new NullPointerException();
- return getTotalInImpl(streamHandle);
- }
+ * Returns a long int of total number of bytes read by the Deflater. This
+ * method performs the same as getTotalIn except it returns a long value
+ * instead of an integer
+ *
+ * @see getTotalIn
+ * @return bytes exactly read by deflater
+ */
+ public synchronized long getBytesRead() {
+ // Throw NPE here
+ if (streamHandle == -1)
+ throw new NullPointerException();
+ return getTotalInImpl(streamHandle);
+ }
- /**
- * return a long int instead of int
- * @see getTotalOut
- * @return bytes exactly write by deflater
- */
+ /**
+ * Returns a long int of total number of bytes of read by the Deflater. This
+ * method performs the same as getTotalOut except it returns a long value
+ * instead of an integer
+ *
+ * @see getTotalOut
+ * @return bytes exactly write by deflater
+ */
public synchronized long getBytesWritten() {
// Throw NPE here
if (streamHandle == -1)
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java?rev=392984&r1=392983&r2=392984&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/Inflater.java Mon Apr 10 09:45:29 2006
@@ -1,4 +1,4 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -301,6 +301,8 @@
/**
* Returns a long int of total number of bytes of input read by the
* Inflater.
+ * This method performs the same as getTotalIn except it returns a
+ * long value instead of an integer
*
* @see getTotalIn
* @return Total bytes read
@@ -315,6 +317,8 @@
/**
* Returns a long int of total number of bytes of input output by the
* Inflater.
+ * This method performs the same as getTotalOut except it returns a
+ * long value instead of an integer
*
* @see getTotalOut
* @return Total bytes output
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/tests/java/util/zip/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/tests/java/util/zip/AllTests.java?rev=392984&r1=392983&r2=392984&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/tests/java/util/zip/AllTests.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/tests/java/util/zip/AllTests.java Mon Apr 10 09:45:29 2006
@@ -29,6 +29,7 @@
"Test for org.apache.harmony.tests.java.util.zip");
//$JUnit-BEGIN$
suite.addTestSuite(InflaterTest.class);
+ suite.addTestSuite(DeflaterTest.class);
suite.addTestSuite(ZipInputStreamTest.class);
suite.addTestSuite(ZipOutputStreamTest.class);
//$JUnit-END$
Added: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/tests/java/util/zip/DeflaterTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/tests/java/util/zip/DeflaterTest.java?rev=392984&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/tests/java/util/zip/DeflaterTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/tests/java/util/zip/DeflaterTest.java Mon Apr 10 09:45:29 2006
@@ -0,0 +1,77 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.tests.java.util.zip;
+
+import java.io.UnsupportedEncodingException;
+import java.util.zip.DataFormatException;
+import java.util.zip.Deflater;
+
+import junit.framework.TestCase;
+
+public class DeflaterTest extends TestCase {
+
+ /**
+ * @throws DataFormatException
+ * @throws UnsupportedEncodingException
+ * @tests java.util.zip.Deflater#getBytesRead()
+ */
+ public void test_getBytesRead() throws DataFormatException,
+ UnsupportedEncodingException {
+ // Regression test for HARMONY-158
+ Deflater def = new Deflater();
+ assertEquals(0, def.getTotalIn());
+ assertEquals(0, def.getTotalOut());
+ assertEquals(0, def.getBytesRead());
+ // Encode a String into bytes
+ String inputString = "blahblahblah??";
+ byte[] input = inputString.getBytes("UTF-8");
+
+ // Compress the bytes
+ byte[] output = new byte[100];
+ def.setInput(input);
+ def.finish();
+ int compressedDataLength = def.deflate(output);
+ assertEquals(14, def.getTotalIn());
+ assertEquals(compressedDataLength, def.getTotalOut());
+ assertEquals(14, def.getBytesRead());
+ }
+
+ /**
+ * @throws DataFormatException
+ * @throws UnsupportedEncodingException
+ * @tests java.util.zip.Deflater#getBytesRead()
+ */
+ public void test_getBytesWritten() throws DataFormatException,
+ UnsupportedEncodingException {
+ // Regression test for HARMONY-158
+ Deflater def = new Deflater();
+ assertEquals(0, def.getTotalIn());
+ assertEquals(0, def.getTotalOut());
+ assertEquals(0, def.getBytesWritten());
+ // Encode a String into bytes
+ String inputString = "blahblahblah??";
+ byte[] input = inputString.getBytes("UTF-8");
+
+ // Compress the bytes
+ byte[] output = new byte[100];
+ def.setInput(input);
+ def.finish();
+ int compressedDataLength = def.deflate(output);
+ assertEquals(14, def.getTotalIn());
+ assertEquals(compressedDataLength, def.getTotalOut());
+ assertEquals(compressedDataLength, def.getBytesWritten());
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/tests/java/util/zip/DeflaterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/tests/java/util/zip/InflaterTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/tests/java/util/zip/InflaterTest.java?rev=392984&r1=392983&r2=392984&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/tests/java/util/zip/InflaterTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/tests/java/util/zip/InflaterTest.java Mon Apr 10 09:45:29 2006
@@ -15,6 +15,9 @@
package org.apache.harmony.tests.java.util.zip;
+import java.io.UnsupportedEncodingException;
+import java.util.zip.DataFormatException;
+import java.util.zip.Deflater;
import java.util.zip.Inflater;
import junit.framework.TestCase;
@@ -33,4 +36,57 @@
assertEquals(0,inf.getBytesRead());
assertEquals(0,inf.getBytesWritten());
}
+
+ /**
+ * @tests java.util.zip.Deflater#getBytesRead()
+ */
+ public void test_getBytesRead() throws DataFormatException,
+ UnsupportedEncodingException {
+ // Regression test for HARMONY-158
+ Deflater def = new Deflater();
+ Inflater inf = new Inflater();
+ assertEquals(0, def.getTotalIn());
+ assertEquals(0, def.getTotalOut());
+ assertEquals(0, def.getBytesRead());
+ // Encode a String into bytes
+ String inputString = "blahblahblah??";
+ byte[] input = inputString.getBytes("UTF-8");
+
+ // Compress the bytes
+ byte[] output = new byte[100];
+ def.setInput(input);
+ def.finish();
+ def.deflate(output);
+ inf.setInput(output);
+ int compressedDataLength =inf.inflate(input);
+ assertEquals(16, inf.getTotalIn());
+ assertEquals(compressedDataLength, inf.getTotalOut());
+ assertEquals(16, inf.getBytesRead());
+ }
+
+ /**
+ * @tests java.util.zip.Deflater#getBytesRead()
+ */
+ public void test_getBytesWritten() throws DataFormatException, UnsupportedEncodingException {
+ // Regression test for HARMONY-158
+ Deflater def = new Deflater();
+ Inflater inf = new Inflater();
+ assertEquals(0, def.getTotalIn());
+ assertEquals(0, def.getTotalOut());
+ assertEquals(0, def.getBytesWritten());
+ // Encode a String into bytes
+ String inputString = "blahblahblah??";
+ byte[] input = inputString.getBytes("UTF-8");
+
+ // Compress the bytes
+ byte[] output = new byte[100];
+ def.setInput(input);
+ def.finish();
+ def.deflate(output);
+ inf.setInput(output);
+ int compressedDataLength =inf.inflate(input);
+ assertEquals(16, inf.getTotalIn());
+ assertEquals(compressedDataLength, inf.getTotalOut());
+ assertEquals(14, inf.getBytesWritten());
+ }
}