ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: ant/src/testcases/org/apache/tools/ant/taskdefs JarTest.java
Date Thu, 20 Feb 2003 17:15:46 GMT
bodewig     2003/02/20 09:15:46

  Modified:    src/testcases/org/apache/tools/ant/taskdefs JarTest.java
  Log:
  Make sure streams get closed so that the temporary files can be deleted
  
  Revision  Changes    Path
  1.17      +22 -10    ant/src/testcases/org/apache/tools/ant/taskdefs/JarTest.java
  
  Index: JarTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/JarTest.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- JarTest.java	10 Feb 2003 14:14:45 -0000	1.16
  +++ JarTest.java	20 Feb 2003 17:15:46 -0000	1.17
  @@ -57,6 +57,7 @@
   import java.io.File;
   import java.io.FileReader;
   import java.io.IOException;
  +import java.io.Reader;
   import java.util.Date;
   import org.apache.tools.ant.BuildFileTest;
   
  @@ -66,6 +67,7 @@
   public class JarTest extends BuildFileTest {
   
       private static String tempJar = "tmp.jar";
  +    private Reader r1, r2;
   
       public JarTest(String name) {
           super(name);
  @@ -76,12 +78,21 @@
       }
   
       public void tearDown() {
  +        if (r1 != null) {
  +            try {
  +                r1.close();
  +            } catch (IOException e) {
  +            }
  +        }
  +        if (r2 != null) {
  +            try {
  +                r2.close();
  +            } catch (IOException e) {
  +            }
  +        }
  +        
           executeTarget("cleanup");
       }
  -    
  -//    public static junit.framework.Test suite() {
  -//        return new JarTest("testNoRecreateWithoutUpdate");
  -//    }
   
       public void test1() {
           expectBuildException("test1", "required argument not specified");
  @@ -157,12 +168,13 @@
       public void testManifestStaysIntact() 
           throws IOException, ManifestException {
           executeTarget("testManifestStaysIntact");
  -        Manifest mf1 = 
  -            new Manifest(new FileReader(getProject()
  -                                        .resolveFile("jartmp/manifest")));
  -        Manifest mf2 = 
  -            new Manifest(new FileReader(getProject()
  -                                        .resolveFile("jartmp/META-INF/MANIFEST.MF")));
  +
  +        r1 = new FileReader(getProject()
  +                            .resolveFile("jartmp/manifest"));
  +        r2 = new FileReader(getProject()
  +                            .resolveFile("jartmp/META-INF/MANIFEST.MF"));
  +        Manifest mf1 = new Manifest(r1);
  +        Manifest mf2 = new Manifest(r2);
           assertEquals(mf1, mf2);
       }
   
  
  
  

Mime
View raw message