harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r984577 - in /harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util: jar/ zip/
Date Wed, 11 Aug 2010 20:50:24 GMT
Author: hindessm
Date: Wed Aug 11 20:50:24 2010
New Revision: 984577

URL: http://svn.apache.org/viewvc?rev=984577&view=rev
Log:
Apply modified version of java5 patch from "[#HARMONY-6608]
[classlib][archive]Unit tests to improve the coverage of archive module".

I removed two tests that don't pass on the RI. They were the tests for
"IllegalStateException expected" that the patch would add to DeflaterTest.
correct behaviour should be.

Modified:
    harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java
    harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java
    harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java
    harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java
    harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java
    harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedInputStreamTest.java
    harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterTest.java
    harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/GZIPInputStreamTest.java
    harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java
    harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java
    harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java

Modified: harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java?rev=984577&r1=984576&r2=984577&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java
Wed Aug 11 20:50:24 2010
@@ -239,6 +239,9 @@ public class AttributesTest extends Test
         a2.putValue("One", "1");
         a2.putValue("TWO", "2");
         assertEquals(a1, a2);
+        assertEquals(a1, a1);
+        a2=null;
+        assertFalse(a1.equals(a2));
     }
 
     /**

Modified: harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java?rev=984577&r1=984576&r2=984577&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java
Wed Aug 11 20:50:24 2010
@@ -19,6 +19,7 @@ package org.apache.harmony.archive.tests
 
 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,18 @@ public class JarExceptionTest extends Te
             // correct
         }
     }
+    
+    /**
+     * @tests java.util.jar.JarException#JarException(java.lang.String)
+     */
+    public void test_ConstructorLjava_lang_String1() throws Exception {
+         assertEquals("Jar Exception", new JarException("Jar Exception").getMessage());
+    }
+
+    /**
+     * @tests java.util.jar.JarException#JarException()
+     */
+    public void test_Constructor_void() throws Exception {
+        new JarException();
+    }
 }

Modified: harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java?rev=984577&r1=984576&r2=984577&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java
Wed Aug 11 20:50:24 2010
@@ -287,6 +287,8 @@ public class JarFileTest extends TestCas
         // 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();
 

Modified: harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java?rev=984577&r1=984576&r2=984577&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java
Wed Aug 11 20:50:24 2010
@@ -120,6 +120,13 @@ public class JarOutputStreamTest extends
         } catch (IOException ee) {
             // expected
         }
+        
+        try {
+            new JarOutputStream(fos, null);
+            fail("NullPointerException expected");
+        } catch (NullPointerException ee) {
+            // expected
+        }
     }
 
     public void test_JarOutputStreamLjava_io_OutputStream() throws IOException {

Modified: harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java?rev=984577&r1=984576&r2=984577&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java
Wed Aug 11 20:50:24 2010
@@ -44,6 +44,8 @@ public class ManifestTest extends TestCa
     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.Regis
 tryService\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.Reg
 istryService\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 @@ public class ManifestTest extends TestCa
                 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
     }
 
     /**

Modified: harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedInputStreamTest.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/CheckedInputStreamTest.java?rev=984577&r1=984576&r2=984577&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedInputStreamTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedInputStreamTest.java
Wed Aug 11 20:50:24 2010
@@ -104,6 +104,7 @@ public class CheckedInputStreamTest exte
         // System.out.print(checkIn.getChecksum().getValue());
         assertEquals("checkSum value is not correct", 2235765342L, checkIn.getChecksum()
                 .getValue());
+        assertEquals(0, checkIn.skip(0));
         checkInput.close();
     }
 

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=984577&r1=984576&r2=984577&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
Wed Aug 11 20:50:24 2010
@@ -886,6 +886,18 @@ public class DeflaterTest extends TestCa
 			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 +1019,22 @@ public class DeflaterTest extends TestCa
 		} 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);

Modified: harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/GZIPInputStreamTest.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/GZIPInputStreamTest.java?rev=984577&r1=984576&r2=984577&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/GZIPInputStreamTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/GZIPInputStreamTest.java
Wed Aug 11 20:50:24 2010
@@ -92,6 +92,25 @@ public class GZIPInputStreamTest extends
 			assertEquals("the CRC value of the inputStream is not zero", 0, inGZIP
 					.getChecksum().getValue());
 			inGZIP.close();
+
+            try{
+                TestGZIPInputStream inGZIP1 = new TestGZIPInputStream(gInput
+                        .openConnection().getInputStream(), 0);   
+                fail("IllegalArgumentException expected");
+            }catch(IllegalArgumentException ioe){
+                //expected
+            }
+            
+            Support_Resources.copyFile(resources, null, "hyts_checkInput.txt");
+            final URL jarInput = new File(resources.toString()+ "/hyts_checkInput.txt").toURL();
+            try{
+                TestGZIPInputStream inGZIP1 = new TestGZIPInputStream(jarInput
+                        .openConnection().getInputStream(), 200);
+                fail("IOException expected");
+            }catch(IOException ex){
+                //expected
+            }
+            
 		} catch (IOException e) {
 			fail(
 					"an IO error occured while trying to open the input file");

Modified: harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.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/InflaterInputStreamTest.java?rev=984577&r1=984576&r2=984577&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java
Wed Aug 11 20:50:24 2010
@@ -112,6 +112,36 @@ public class InflaterInputStreamTest ext
 	}
 
     /**
+     * @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).bin");
+        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 iae){
+            //expected
+        }        
+    }
+
+    /**
      * @tests java.util.zip.InflaterInputStream#mark(int)
      */
     public void test_markI() {
@@ -160,6 +190,41 @@ public class InflaterInputStreamTest ext
 		}
 	}
 
+    /**
+     * @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).bin");
+        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
+        }
+        
+            inflatIP.close();
+        try {
+            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 };

Modified: harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.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/InflaterTest.java?rev=984577&r1=984576&r2=984577&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java
Wed Aug 11 20:50:24 2010
@@ -363,6 +363,7 @@ public class InflaterTest extends junit.
 		try {
 			while (!(inflate.finished())) {
 				if (inflate.needsInput()) {
+				    assertEquals(0, inflate.inflate(outPutInf, 0, 1));
 					inflate.setInput(outPutBuff1);
 				}
 				y += inflate.inflate(outPutInf, y, outPutInf.length - y);
@@ -395,6 +396,21 @@ public class InflaterTest extends junit.
 			r = 1;
 		}
 		assertEquals("out of bounds error did not get caught", 1, r);
+
+        try {
+            assertEquals(0, inflate.inflate(outPutInf, offSet, 0));
+        } catch (DataFormatException e) {
+            fail("Invalid input to be decompressed");
+        }
+        inflate.end();
+        try {
+            inflate.inflate(outPutInf, offSet, 1);
+            fail("IllegalStateException expected");
+        } catch (DataFormatException e) {
+            fail("Invalid input to be decompressed");
+        } catch (IllegalStateException e) {
+            //expected
+        }
 	}
 
     public void test_inflate$BII1() {
@@ -517,6 +533,7 @@ public class InflaterTest extends junit.
         assertEquals(0,inf.getTotalOut());
         assertEquals(0,inf.getBytesRead());
         assertEquals(0,inf.getBytesWritten());
+        assertEquals(1, inf.getAdler());
 	}
 
 	/**
@@ -924,6 +941,12 @@ public class InflaterTest extends junit.
             // expected.
         }
         infl1.end();
+        try{
+            infl1.setDictionary(dictionary2.getBytes());
+            fail("IllegalStateException expected");
+        }catch(IllegalStateException ise){
+            //expected
+        }
     }
 
     public void testSetDictionary$BII() throws Exception {
@@ -992,6 +1015,7 @@ public class InflaterTest extends junit.
         Inflater infl1 = new Inflater();
         Inflater infl2 = new Inflater();
         Inflater infl3 = new Inflater();
+        Inflater infl4 = new Inflater();
 
         byte[] result = new byte[100];
         int decLen;
@@ -1026,6 +1050,62 @@ public class InflaterTest extends junit.
         infl3.end();
         assertEquals(inputString, new String(result, 0, decLen));
 
+        //exception test
+        infl4.setInput(output3, 0, dataLen3);
+        decLen = infl4.inflate(result);
+        assertTrue(infl4.needsDictionary());
+
+        try{
+            infl4.setDictionary(dictionary1.getBytes(), 4, 4);
+            fail("ArrayIndexOutOfBoundsException expected");
+        }catch(ArrayIndexOutOfBoundsException aiob){
+            //expected
+        }
     }
 
+    public void testExceptions() throws Exception {
+        byte byteArray[] = { 5, 2, 3, 7, 8 };
+
+        int r = 0;
+        Inflater inflate = new Inflater();
+        inflate.setInput(byteArray);
+        inflate.end();
+        
+        try{
+            inflate.getAdler();
+            fail("IllegalStateException expected");
+        }catch(IllegalStateException ise){
+            //expected
+        }
+
+        try{
+            inflate.getBytesRead();
+            fail("NullPointerException expected");
+        }catch(NullPointerException ise){
+            //expected
+        }
+        
+        try{
+            inflate.getBytesWritten();
+            fail("NullPointerException expected");
+        }catch(NullPointerException ise){
+            //expected
+        }
+         
+        
+        try{
+            inflate.getTotalIn();
+            fail("IllegalStateException expected");
+        }catch(IllegalStateException ise){
+            //expected
+        }
+        
+        try{
+            inflate.getTotalOut();
+            fail("IllegalStateException expected");
+        }catch(IllegalStateException ise){
+            //expected
+        }
+         
+    }
 }

Modified: harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.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/ZipFileTest.java?rev=984577&r1=984576&r2=984577&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java
Wed Aug 11 20:50:24 2010
@@ -49,11 +49,16 @@ public class ZipFileTest extends junit.f
 	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 @@ public class ZipFileTest extends junit.f
                                           | ZipFile.OPEN_READ);
                 zip.close();
                 assertTrue("Zip should not exist", !file.exists());
+
+                file = new File(tempFileName);
+                try{
+                    zip = new ZipFile(file, 3);  //passing unkown argument
+                    fail("Should throw IllegalArgumentException");
+                }catch(IllegalArgumentException iae ){
+                    //expected
+                }
 	}
 
 	/**



Mime
View raw message