ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@locus.apache.org
Subject cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs FilterTest.java
Date Wed, 04 Oct 2000 10:42:04 GMT
bodewig     00/10/04 03:42:02

  Modified:    src/etc/testcases/taskdefs filter.xml
               src/testcases/org/apache/tools/ant/taskdefs FilterTest.java
  Added:       src/etc/testcases/taskdefs filter1.txt filter2.txt
  Log:
  Extended testcase for <filter> to show that Bug #38 (report #184) has
  already been fixed.
  Submitted by:	Erik Meade <emeade@geekfarm.org>
  
  Revision  Changes    Path
  1.2       +20 -0     jakarta-ant/src/etc/testcases/taskdefs/filter.xml
  
  Index: filter.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/etc/testcases/taskdefs/filter.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- filter.xml	2000/09/20 13:38:47	1.1
  +++ filter.xml	2000/10/04 10:41:57	1.2
  @@ -18,4 +18,24 @@
       <filter token="" value=""/>
     </target>
   
  +  <target name="test5">
  +    <filter token="year" value="2000" />
  +    <copyfile src="filter1.txt" dest="filtered.tmp" filtering="yes"/>
  +  </target>
  +
  +  <target name="test6">
  +    <filter token="year" value="2000" />
  +    <copydir src="." dest="./taskdefs.tmp" filtering="yes" includes="filter1.txt"/>
  +  </target>
  +
  +  <target name="test7">
  +    <filter token="ROOT" value="root" />
  +    <copyfile src="filter2.txt" dest="filtered.tmp" filtering="yes"/>
  +  </target>
  +
  +  <target name="test8">
  +    <filter token="ROOT" value="root" />
  +    <copydir src="." dest="./taskdefs.tmp" filtering="yes" includes="filter2.txt"/>
  +  </target>
  +
   </project>
  
  
  
  1.1                  jakarta-ant/src/etc/testcases/taskdefs/filter1.txt
  
  Index: filter1.txt
  ===================================================================
  @year@
  
  
  
  1.1                  jakarta-ant/src/etc/testcases/taskdefs/filter2.txt
  
  Index: filter2.txt
  ===================================================================
  <%@ include file="@ROOT@/some/include.jsp"%>
  
  
  
  1.2       +57 -1     jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/FilterTest.java
  
  Index: FilterTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/FilterTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FilterTest.java	2000/09/20 13:38:50	1.1
  +++ FilterTest.java	2000/10/04 10:42:00	1.2
  @@ -54,17 +54,25 @@
   
   package org.apache.tools.ant.taskdefs;
   
  +import java.io.BufferedReader;
  +import java.io.File;
  +import java.io.FileNotFoundException;
  +import java.io.FileReader;
  +import java.io.IOException;
  +
   /**
    * @author Nico Seessle <nico@seessle.de> 
    */
   public class FilterTest extends TaskdefsTest { 
       
  +    private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/";
  +    
       public FilterTest(String name) { 
           super(name);
       }    
       
       public void setUp() { 
  -        configureProject("src/etc/testcases/taskdefs/filter.xml");
  +        configureProject(TASKDEFS_DIR + "filter.xml");
       }
   
       public void test1() { 
  @@ -83,4 +91,52 @@
           executeTarget("test4");
       }
       
  +    public void test5() {
  +        executeTarget("test5");
  +        assertEquals("2000",
  +                     getFilteredFile("5", TASKDEFS_DIR + "filtered.tmp"));
  +    }
  +
  +
  +    public void test6() {
  +        executeTarget("test6");
  +        assertEquals("2000",
  +                     getFilteredFile("6", TASKDEFS_DIR + "taskdefs.tmp/filter1.txt"));
  +    }
  +
  +    public void test7() {
  +        executeTarget("test7");
  +        assertEquals("<%@ include file=\"root/some/include.jsp\"%>",
  +                     getFilteredFile("7", TASKDEFS_DIR + "filtered.tmp"));
  +    }
  +    
  +    public void test8() {
  +        executeTarget("test8");
  +        assertEquals("<%@ include file=\"root/some/include.jsp\"%>",
  +                     getFilteredFile("8", TASKDEFS_DIR + "taskdefs.tmp/filter2.txt"));
  +    }
  +    
  +    private String getFilteredFile(String testNumber, String filteredFile) {
  +    
  +        String line = null;
  +        File f = new File(filteredFile);
  +        if (!f.exists()) {
  +            fail("filter test"+testNumber+" failed");
  +        } else {
  +            BufferedReader in = null;
  +            try {
  +                in = new BufferedReader(new FileReader(f));
  +            } catch (FileNotFoundException fnfe) {
  +                fail("filter test"+testNumber+" failed, filtered file: " + f.toString()
+ " not found");
  +            }
  +            try {
  +                line = in.readLine();
  +                in.close();
  +            } catch (IOException ioe) {
  +                fail("filter test"+testNumber+" failed.  IOException while reading filtered
file: " + ioe);
  +            }
  +        }
  +        f.delete();
  +        return line;
  +    }
   }
  
  
  

Mime
View raw message