Index: classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java =================================================================== --- classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java (revision 982874) +++ classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java (working copy) @@ -239,6 +239,9 @@ a2.putValue("One", "1"); a2.putValue("TWO", "2"); assertEquals(a1, a2); + assertEquals(a1, a1); + a2=null; + assertFalse(a1.equals(a2)); } /** Index: classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java =================================================================== --- classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java (revision 982874) +++ classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java (working copy) @@ -19,6 +19,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; +import java.util.jar.JarException; import java.util.jar.Manifest; import junit.framework.TestCase; @@ -35,4 +36,26 @@ // correct } } + + /** + * @tests java.util.jar.JarException#JarException(java.lang.String) + */ + public void test_ConstructorLjava_lang_String1() throws Exception { + try { + throw new JarException("Jar Exception"); + } catch (JarException e) { + assertEquals("Jar Exception", e.getMessage()); + } + } + + /** + * @tests java.util.jar.JarException#JarException() + */ + public void test_Constructor_void() throws Exception { + try { + throw new JarException(); + } catch (JarException e) { + // Correct + } + } } Index: classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java =================================================================== --- classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java (revision 982874) +++ classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java (working copy) @@ -287,6 +287,8 @@ // java.util.jar.JarFile.getManifest() Support_Resources.copyFile(resources, null, JAR1); JarFile jarFile = new JarFile(new File(resources, JAR1)); + InputStream is = jarFile.getInputStream(jarFile.getEntry(JAR1_ENTRY1)); + assertTrue(is.available() > 0); assertNotNull("Error--Manifest not returned", jarFile.getManifest()); jarFile.close(); Index: classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java =================================================================== --- classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java (revision 982874) +++ classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java (working copy) @@ -120,6 +120,13 @@ } catch (IOException ee) { // expected } + + try { + new JarOutputStream(fos, null); + fail("NullPointerException expected"); + } catch (NullPointerException ee) { + // expected + } } public void test_JarOutputStreamLjava_io_OutputStream() throws IOException { Index: classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java =================================================================== --- classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java (revision 982874) +++ classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java (working copy) @@ -44,6 +44,8 @@ private final String MANIFEST_NAME = "manifest/hyts_MANIFEST.MF"; private static final String MANIFEST_CONTENTS = "Manifest-Version: 1.0\nBundle-Name: ClientSupport\nBundle-Description: Provides SessionService, AuthenticationService. Extends RegistryService.\nBundle-Activator: com.ibm.ive.eccomm.client.support.ClientSupportActivator\nImport-Package: com.ibm.ive.eccomm.client.services.log,\n com.ibm.ive.eccomm.client.services.registry,\n com.ibm.ive.eccomm.service.registry; specification-version=1.0.0,\n com.ibm.ive.eccomm.service.session; specification-version=1.0.0,\n com.ibm.ive.eccomm.service.framework; specification-version=1.2.0,\n org.osgi.framework; specification-version=1.0.0,\n org.osgi.service.log; specification-version=1.0.0,\n com.ibm.ive.eccomm.flash; specification-version=1.2.0,\n com.ibm.ive.eccomm.client.xml,\n com.ibm.ive.eccomm.client.http.common,\n com.ibm.ive.eccomm.client.http.client\nImport-Service: org.osgi.service.log.LogReaderService\n org.osgi.service.log.LogService,\n com.ibm.ive.eccomm.service.registry.RegistryService\nExport-Package: com.ibm.ive.eccomm.client.services.authentication; specification-version=1.0.0,\n com.ibm.ive.eccomm.service.authentication; specification-version=1.0.0,\n com.ibm.ive.eccomm.common; specification-version=1.0.0,\n com.ibm.ive.eccomm.client.services.registry.store; specification-version=1.0.0\nExport-Service: com.ibm.ive.eccomm.service.authentication.AuthenticationService,\n com.ibm.ive.eccomm.service.session.SessionService\nBundle-Vendor: IBM\nBundle-Version: 1.2.0\n"; + + private static final String MANIFEST_CONTENTS_1 = "Manifest-Version: 2.0\nBundle-Name: ClientSupport\nBundle-Description: Provides SessionService, AuthenticationService. Extends RegistryService.\nBundle-Activator: com.ibm.ive.eccomm.client.support.ClientSupportActivator\nImport-Package: com.ibm.ive.eccomm.client.services.log,\n com.ibm.ive.eccomm.client.services.registry,\n com.ibm.ive.eccomm.service.registry; specification-version=2.0.0,\n com.ibm.ive.eccomm.service.session; specification-version=2.0.0,\n com.ibm.ive.eccomm.service.framework; specification-version=2.1.0,\n org.osgi.framework; specification-version=2.0.0,\n org.osgi.service.log; specification-version=2.0.0,\n com.ibm.ive.eccomm.flash; specification-version=2.2.0,\n com.ibm.ive.eccomm.client.xml,\n com.ibm.ive.eccomm.client.http.common,\n com.ibm.ive.eccomm.client.http.client\nImport-Service: org.osgi.service.log.LogReaderService\n org.osgi.service.log.LogService,\n com.ibm.ive.eccomm.service.registry.RegistryService\nExport-Package: com.ibm.ive.eccomm.client.services.authentication; specification-version=1.0.0,\n com.ibm.ive.eccomm.service.authentication; specification-version=1.0.0,\n com.ibm.ive.eccomm.common; specification-version=1.0.0,\n com.ibm.ive.eccomm.client.services.registry.store; specification-version=1.0.0\nExport-Service: com.ibm.ive.eccomm.service.authentication.AuthenticationService,\n com.ibm.ive.eccomm.service.session.SessionService\nBundle-Vendor: IBM\nBundle-Version: 1.2.0\n"; private File resources; @@ -182,6 +184,14 @@ MANIFEST_CONTENTS.getBytes("ISO-8859-1"))); assertEquals(firstManifest, secondManifest); + + Manifest thirdManifest = new Manifest(new ByteArrayInputStream( + MANIFEST_CONTENTS_1.getBytes("ISO-8859-1"))); + assertNotSame(firstManifest, thirdManifest); + + firstManifest=null; + assertFalse(secondManifest.equals(firstManifest)); + assertFalse(secondManifest.equals(new String("abc"))); //non Manifest Object } /** Index: classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedInputStreamTest.java =================================================================== --- classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedInputStreamTest.java (revision 982874) +++ classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedInputStreamTest.java (working copy) @@ -104,6 +104,7 @@ // System.out.print(checkIn.getChecksum().getValue()); assertEquals("checkSum value is not correct", 2235765342L, checkIn.getChecksum() .getValue()); + assertEquals(0, checkIn.skip(0)); checkInput.close(); } Index: classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterInputStreamTest.java =================================================================== --- classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterInputStreamTest.java (revision 982874) +++ classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterInputStreamTest.java (working copy) @@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.util.zip.DataFormatException; import java.util.zip.Deflater; import java.util.zip.DeflaterInputStream; @@ -305,6 +306,17 @@ } /** + * @tests DataFormatException#DataFormatException() + */ + public void testDataFormatException() { + try { + throw new DataFormatException(); + } catch (DataFormatException e) { + // expected + } + } + + /** * @tests DeflaterInputStream#DeflaterInputStream(InputStream,Deflater) */ public void testDeflaterInputStreamInputStreamDeflater() { Index: classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterTest.java =================================================================== --- classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterTest.java (revision 982874) +++ classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterTest.java (working copy) @@ -676,6 +676,17 @@ defl.end(); } + try{ + Deflater defl = new Deflater(); + defl.setLevel(2); + outPutBuf = new byte[500]; + defl.setInput(byteArray); + defl.setLevel(3); + fail("IllegalStateException expected"); + }catch(IllegalStateException ise){ + //expected + } + // testing boundaries try { Deflater boundDefl = new Deflater(); @@ -745,6 +756,16 @@ mdefl.end(); } + try{ + byte outPutBuf[] = new byte[500]; + MyDeflater mdefl = new MyDeflater(); + mdefl.setStrategy(mdefl.getDefStrategy()); + mdefl.setInput(byteArray); + mdefl.setStrategy(mdefl.getHuffman()); + fail("IllegalStateException expected"); + }catch(IllegalStateException ise){ + //expected + } // Attempting to setStrategy to an invalid value try { Deflater defl = new Deflater(); @@ -886,6 +907,18 @@ fail("IllegalArgumentException not thrown when setting level to a number > 9."); } catch (IllegalArgumentException e) { } + + try { + Deflater boundDefl = new Deflater(-2, true); + fail("IllegalArgumentException not thrown when passing level to a number < 0."); + } catch (IllegalArgumentException e) { + } + + try { + Deflater boundDefl = new Deflater(10, true); + fail("IllegalArgumentException not thrown when passing level to a number > 9."); + } catch (IllegalArgumentException e) { + } } /** @@ -1007,6 +1040,22 @@ } catch (NullPointerException e) { } + // Methods where we expect NullPointerException to be thrown + try { + defl.getBytesRead(); + fail("defl.reset() can still be used after " + desc + + " is called in test_" + desc); + } catch (NullPointerException e) { + } + + // Methods where we expect NullPointerException to be thrown + try { + defl.getBytesWritten(); + fail("defl.getBytesWritten() can still be used after " + desc + + " is called in test_" + desc); + } catch (NullPointerException e) { + } + // Methods that should be allowed to be called after end() is called defl.needsInput(); defl.setStrategy(1); Index: classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java =================================================================== --- classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java (revision 982874) +++ classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java (working copy) @@ -112,6 +112,36 @@ } /** + * @tests java.util.zip.InflaterInputStream#InflaterInputStream(java.io.InputStream, + * java.util.zip.Inflater, int) + */ + public void test_ConstructorLjava_io_InputStreamLjava_util_zip_InflaterI_1() throws IOException { + InputStream infile = Support_Resources.getStream("hyts_constru(ODI).txt"); + Inflater inflate = new Inflater(); + InflaterInputStream inflatIP = null; + try{ + inflatIP = new InflaterInputStream(infile, null, 1); + fail("NullPointerException expected"); + }catch(NullPointerException NPE){ + //expected + } + + try{ + inflatIP = new InflaterInputStream(null, inflate, 1); + fail("NullPointerException expected"); + }catch(NullPointerException NPE){ + //expected + } + + try{ + inflatIP = new InflaterInputStream(infile, inflate, -1); + fail("IllegalArgumentException expected"); + }catch(IllegalArgumentException NPE){ + //expected + } + } + + /** * @tests java.util.zip.InflaterInputStream#mark(int) */ public void test_markI() { @@ -160,6 +190,41 @@ } } + /** + * @tests java.util.zip.InflaterInputStream#read(byte [], int, int) + */ + public void test_read_LBII() throws IOException { + int result = 0; + InputStream infile = Support_Resources.getStream("hyts_constru(OD).txt"); + Inflater inflate = new Inflater(); + InflaterInputStream inflatIP = new InflaterInputStream(infile, inflate); + + byte[] b = new byte[3]; + try{ + result = inflatIP.read(null, 0, 1); + fail("NullPointerException expected"); + }catch(NullPointerException npe){ + //expected + } + + assertEquals(0, inflatIP.read(b, 0, 0)); + + try{ + result = inflatIP.read(b, 5, 2); //offset higher + fail("IndexOutOfBoundsException expected"); + }catch(IndexOutOfBoundsException iobe){ + //expected + } + + try { + inflatIP.close(); + result = inflatIP.read(b, 0, 1); //read after close + fail("IOException expected"); + }catch(IOException ioe){ + //expected + } + } + public void testAvailableNonEmptySource() throws Exception { // this byte[] is a deflation of these bytes: { 1, 3, 4, 6 } byte[] deflated = { 72, -119, 99, 100, 102, 97, 3, 0, 0, 31, 0, 15, 0 }; Index: classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java =================================================================== --- classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java (revision 982874) +++ classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java (working copy) @@ -49,11 +49,16 @@ private ZipFile zfile; /** + * @throws IOException * @tests java.util.zip.ZipFile#ZipFile(java.io.File) */ - public void test_ConstructorLjava_io_File() { + public void test_ConstructorLjava_io_File() throws IOException { // Test for method java.util.zip.ZipFile(java.io.File) - assertTrue("Used to test", true); + zfile.close(); // about to reopen the same temp file + File file = new File(tempFileName); + ZipFile zip = new ZipFile(file); + assertTrue("Zip should exist", file.exists()); + zip.close(); } /** @@ -66,6 +71,14 @@ | ZipFile.OPEN_READ); zip.close(); assertTrue("Zip should not exist", !file.exists()); + + try{ + file = new File(tempFileName); + zip = new ZipFile(file, 3); //passing unkown argument + fail("Should throw IllegalArgumentException"); + }catch(IllegalArgumentException iae ){ + //expected + } } /**