ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antoine Levy-Lambert" <anto...@antbuild.com>
Subject Re: cvs commit: ant/src/etc/testcases/core directoryscanner.xml
Date Fri, 11 Jul 2003 13:08:49 GMT
I have prepared fixes to speed up DirectoryScanner, and I have added new
testcases in DirectoryScannerTest.
I plan to commit my fixes to DirectoryScanner/SelectorUtils next week.
Cheers,
Antoine
----- Original Message -----
From: <antoine@apache.org>
To: <ant-cvs@apache.org>
Sent: Friday, July 11, 2003 2:59 PM
Subject: cvs commit: ant/src/etc/testcases/core directoryscanner.xml


> antoine     2003/07/11 05:59:30
>
>   Modified:    src/testcases/org/apache/tools/ant
DirectoryScannerTest.java
>   Added:       src/etc/testcases/core directoryscanner.xml
>   Log:
>   added 3 new testcases for DirectoryScanner
>
>   Revision  Changes    Path
>   1.11      +61 -1
ant/src/testcases/org/apache/tools/ant/DirectoryScannerTest.java
>
>   Index: DirectoryScannerTest.java
>   ===================================================================
>   RCS file:
/home/cvs/ant/src/testcases/org/apache/tools/ant/DirectoryScannerTest.java,v
>   retrieving revision 1.10
>   retrieving revision 1.11
>   diff -u -r1.10 -r1.11
>   --- DirectoryScannerTest.java 7 Mar 2003 11:23:10 -0000 1.10
>   +++ DirectoryScannerTest.java 11 Jul 2003 12:59:29 -0000 1.11
>   @@ -62,13 +62,15 @@
>    import junit.framework.AssertionFailedError;
>    import java.io.File;
>    import java.io.IOException;
>   +import java.util.TreeSet;
>   +import java.util.Iterator;
>
>    /**
>     * JUnit 3 testcases for org.apache.tools.ant.DirectoryScanner
>     *
>     * @author Stefan Bodewig
>     */
>   -public class DirectoryScannerTest extends TestCase {
>   +public class DirectoryScannerTest extends BuildFileTest {
>
>        public DirectoryScannerTest(String name) {super(name);}
>
>   @@ -76,6 +78,64 @@
>        private boolean supportsSymlinks = Os.isFamily("unix")
>            && !JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1);
>
>   +    public void setUp() {
>   +
configureProject("src/etc/testcases/core/directoryscanner.xml");
>   +        getProject().executeTarget("setup");
>   +    }
>   +    private void compareFiles(DirectoryScanner ds, String[]
expectedFiles, String[] expectedDirectories) {
>   +        String includedFiles[] = ds.getIncludedFiles();
>   +        String includedDirectories[] = ds.getIncludedDirectories();
>   +        assertTrue("expecting : " + expectedFiles.length + " files,
present : " + includedFiles.length, includedFiles.length ==
expectedFiles.length);
>   +        assertTrue("expecting : " + expectedDirectories.length + "
directories, present : " + includedDirectories.length,
includedDirectories.length == expectedDirectories.length);
>   +        TreeSet files = new TreeSet();
>   +        for (int counter=0; counter < includedFiles.length; counter++)
{
>   +
files.add(includedFiles[counter].replace(File.separatorChar,'/'));
>   +        }
>   +        TreeSet directories = new TreeSet();
>   +        for (int counter=0; counter < includedDirectories.length;
counter++) {
>   +
directories.add(includedDirectories[counter].replace(File.separatorChar,'/')
);
>   +        }
>   +        String currentfile;
>   +        Iterator i = files.iterator();
>   +        int counter = 0;
>   +        while (i.hasNext()) {
>   +            currentfile = (String) i.next();
>   +            assertTrue("expecting file " + expectedFiles[counter],
currentfile.equals(expectedFiles[counter]));
>   +            counter++;
>   +        }
>   +        String currentdirectory;
>   +        Iterator dirit = directories.iterator();
>   +        counter = 0;
>   +        while (dirit.hasNext()) {
>   +            currentdirectory = (String) dirit.next();
>   +            assertTrue("expecting directory " +
expectedDirectories[counter],
currentdirectory.equals(expectedDirectories[counter]));
>   +            counter++;
>   +        }
>   +
>   +    }
>   +    public void test1() {
>   +        DirectoryScanner ds = new DirectoryScanner();
>   +        ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));
>   +        ds.setIncludes(new String[] {"alpha"});
>   +        ds.scan();
>   +        compareFiles(ds, new String[] {} ,new String[] {"alpha"});
>   +    }
>   +    public void test2() {
>   +        DirectoryScanner ds = new DirectoryScanner();
>   +        ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));
>   +        ds.setIncludes(new String[] {"alpha/"});
>   +        ds.scan();
>   +        compareFiles(ds, new String[] {"alpha/beta/beta.xml",
"alpha/beta/gamma/gamma.xml"} ,new String[] {"alpha", "alpha/beta",
"alpha/beta/gamma"});
>   +    }
>   +    public void test3() {
>   +        DirectoryScanner ds = new DirectoryScanner();
>   +        ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));
>   +        ds.scan();
>   +        compareFiles(ds, new String[] {"alpha/beta/beta.xml",
"alpha/beta/gamma/gamma.xml"} ,new String[] {"", "alpha", "alpha/beta",
"alpha/beta/gamma"});
>   +    }
>   +    public void tearDown() {
>   +        getProject().executeTarget("cleanup");
>   +    }
>        /**
>         * Test case for setFollowLinks() and associated funtionality.
>         * Only supports test on linux, at the moment because Java has
>
>
>
>   1.1                  ant/src/etc/testcases/core/directoryscanner.xml
>
>   Index: directoryscanner.xml
>   ===================================================================
>   <project name="directoryscanner-test" basedir=".">
>       <property name="tmp.dir" location="tmp"/>
>       <target name="setup">
>           <mkdir dir="${tmp.dir}"/>
>           <mkdir dir="${tmp.dir}/alpha"/>
>           <mkdir dir="${tmp.dir}/alpha/beta"/>
>           <mkdir dir="${tmp.dir}/alpha/beta/gamma"/>
>           <touch file="${tmp.dir}/alpha/beta/gamma/gamma.xml"/>
>           <touch file="${tmp.dir}/alpha/beta/beta.xml"/>
>       </target>
>       <target name="cleanup">
>           <delete dir="${tmp.dir}" quiet="true"/>
>       </target>
>   </project>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message