tests/libjava-mauve/src/gnu/testlet/java/util/zip/ZipFile/NoEntryTest.java
branchjk_new_structure
changeset 1541 75c2e24dea9a
parent 1540 92ac284961c1
child 1542 be11db817bcf
equal deleted inserted replaced
1540:92ac284961c1 1541:75c2e24dea9a
     1 // Tags: JDK1.1
       
     2 
       
     3 // Copyright (C) 2004 Free Software Foundation
       
     4 // Contributed by Anthony Green <green@redhat.com>
       
     5 
       
     6 // This file is part of Mauve.
       
     7 
       
     8 // Mauve is free software; you can redistribute it and/or modify
       
     9 // it under the terms of the GNU General Public License as published by
       
    10 // the Free Software Foundation; either version 2, or (at your option)
       
    11 // any later version.
       
    12 
       
    13 // Mauve is distributed in the hope that it will be useful,
       
    14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    16 // GNU General Public License for more details.
       
    17 
       
    18 // You should have received a copy of the GNU General Public License
       
    19 // along with Mauve; see the file COPYING.  If not, write to
       
    20 // the Free Software Foundation, 59 Temple Place - Suite 330,
       
    21 // Boston, MA 02111-1307, USA. 
       
    22 
       
    23 package gnu.testlet.java.util.zip.ZipFile;
       
    24 
       
    25 import gnu.testlet.Testlet;
       
    26 import gnu.testlet.TestHarness;
       
    27 
       
    28 import java.util.zip.*;
       
    29 import java.io.*;
       
    30 
       
    31 public class NoEntryTest implements Testlet
       
    32 {
       
    33     public void test (TestHarness harness)
       
    34     {
       
    35       boolean pass = false;
       
    36 
       
    37       try
       
    38 	{
       
    39 	  File temp = File.createTempFile ("NoEntryTest", ".zip");
       
    40 	  temp.deleteOnExit ();
       
    41 	  ZipOutputStream zout = 
       
    42 	    new ZipOutputStream(new FileOutputStream (temp));
       
    43 	  ZipEntry ze = new ZipEntry ("one");
       
    44 	  zout.putNextEntry (ze);
       
    45 	  zout.close();
       
    46 	  
       
    47 	  ZipFile zf = new ZipFile (temp);
       
    48 	  ze = new ZipEntry ("this/does/not/exist");
       
    49 	  InputStream is = zf.getInputStream (ze);
       
    50 	  
       
    51 	  if (is == null)
       
    52 	    pass = true;
       
    53 	}
       
    54       catch (Exception ex)
       
    55 	{
       
    56 	}
       
    57 
       
    58       harness.check (pass, "getInputStream for missing ZipEntry returns null");
       
    59     }
       
    60 }