changeset 8421:5a5d79d3760f

test case for IllegalStateException
author henryjen
date Mon, 29 Apr 2013 21:53:30 -0700
parents b168e7e5eb62
children ff29a0e4ca86
files test/java/util/zip/ZipFile/StreamZipEntriesTest.java
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/util/zip/ZipFile/StreamZipEntriesTest.java	Mon Apr 29 21:34:09 2013 -0700
+++ b/test/java/util/zip/ZipFile/StreamZipEntriesTest.java	Mon Apr 29 21:53:30 2013 -0700
@@ -41,6 +41,7 @@
 
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
 
 public class StreamZipEntriesTest {
 
@@ -68,4 +69,28 @@
             assertEquals(elements[2].toString(), "ReleaseInflater.java");
         }
     }
+
+    @Test
+    public void testClosedZipFile() throws IOException {
+        ZipFile zf = new ZipFile(new File(System.getProperty("test.src", "."), "input.zip"));
+        zf.close();
+        try {
+            Stream s = zf.stream();
+            fail("Should have thrown IllegalStateException");
+        } catch (IllegalStateException e) {
+            // expected;
+        }
+    }
+
+    @Test
+    public void testClosedJarFile() throws IOException {
+        JarFile jf = new JarFile(new File(System.getProperty("test.src", "."), "input.jar"));
+        jf.close();
+        try {
+            Stream s = jf.stream();
+            fail("Should have thrown IllegalStateException");
+        } catch (IllegalStateException e) {
+            // expected;
+        }
+    }
 }