ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant/types/selectors BaseSelectorTest.java DateSelectorTest.java DependSelectorTest.java PresentSelectorTest.java
Date Sat, 06 Jul 2002 00:00:31 GMT
bruce       2002/07/05 17:00:31

  Modified:    src/etc/testcases/types Tag: ANT_15_BRANCH selectors.xml
               src/main/org/apache/tools/ant/types Tag: ANT_15_BRANCH
                        AbstractFileSet.java
               src/main/org/apache/tools/ant/types/selectors Tag:
                        ANT_15_BRANCH DependSelector.java
                        PresentSelector.java SelectorUtils.java
               src/testcases/org/apache/tools/ant/types/selectors Tag:
                        ANT_15_BRANCH BaseSelectorTest.java
                        DateSelectorTest.java DependSelectorTest.java
                        PresentSelectorTest.java
  Log:
  Fixed two bugs and improved tests, as follows:
    * Allowed paths in DependSelector and PresentSelector to be relative to the
      project basedir
    * Corrected problem with fileset reference detecting selector
    * Improved tests so that they test something even on JDK 1.1, where touch
      doesn't work properly
    * Fixed tests so that they work with the changes above
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +25 -0     jakarta-ant/src/etc/testcases/types/selectors.xml
  
  Index: selectors.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/etc/testcases/types/selectors.xml,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- selectors.xml	31 May 2002 22:31:30 -0000	1.1.2.1
  +++ selectors.xml	6 Jul 2002 00:00:30 -0000	1.1.2.2
  @@ -5,6 +5,8 @@
     <property name="etc.dir" value=".."/>
     <property name="test.dir"
             value="selectortest"/>
  +  <property name="mirror.dir"
  +          value="selectortest2"/>
   
     <target name="setupfiles">
       <mkdir dir="${test.dir}" />
  @@ -55,6 +57,29 @@
   
     <target name="cleanup">
       <delete dir="${test.dir}" />
  +  </target>
  +
  +  <target name="mirrorfiles">
  +    <mkdir dir="${mirror.dir}" />
  +    <mkdir dir="${mirror.dir}/zip" />
  +    <mkdir dir="${mirror.dir}/tar" />
  +    <mkdir dir="${mirror.dir}/tar/gz" />
  +    <mkdir dir="${mirror.dir}/tar/bz2" />
  +    <touch file="${mirror.dir}/asf-logo.gif.md5"/>
  +    <touch file="${mirror.dir}/asf-logo.gif.bz2"/>
  +    <sleep seconds="2"/>
  +    <touch file="${mirror.dir}/zip/asf-logo.gif.zip"/>
  +    <sleep seconds="3"/>
  +    <touch file="${mirror.dir}/tar/asf-logo.gif.tar"/>
  +    <sleep seconds="2"/>
  +    <touch file="${mirror.dir}/tar/asf-logo-huge.tar"/>
  +    <touch file="${mirror.dir}/tar/gz/asf-logo.gif.tar.gz"/>
  +    <touch file="${mirror.dir}/tar/bz2/asf-logo.gif.tar.bz2"/>
  +    <touch file="${mirror.dir}/tar/bz2/asf-logo-huge.tar.bz2"/>
  +  </target>
  +
  +  <target name="cleanup.mirrorfiles">
  +    <delete dir="${mirror.dir}" />
     </target>
   
   </project>
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.5.2.6   +1 -0      jakarta-ant/src/main/org/apache/tools/ant/types/AbstractFileSet.java
  
  Index: AbstractFileSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/AbstractFileSet.java,v
  retrieving revision 1.5.2.5
  retrieving revision 1.5.2.6
  diff -u -r1.5.2.5 -r1.5.2.6
  --- AbstractFileSet.java	29 May 2002 14:46:05 -0000	1.5.2.5
  +++ AbstractFileSet.java	6 Jul 2002 00:00:30 -0000	1.5.2.6
  @@ -99,6 +99,7 @@
           this.dir = fileset.dir;
           this.defaultPatterns = fileset.defaultPatterns;
           this.additionalPatterns = fileset.additionalPatterns;
  +        this.selectors = fileset.selectors;
           this.useDefaultExcludes = fileset.useDefaultExcludes;
           this.isCaseSensitive = fileset.isCaseSensitive;
           this.followSymlinks = fileset.followSymlinks;
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +11 -14    jakarta-ant/src/main/org/apache/tools/ant/types/selectors/DependSelector.java
  
  Index: DependSelector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/selectors/DependSelector.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- DependSelector.java	31 May 2002 22:31:31 -0000	1.1.2.1
  +++ DependSelector.java	6 Jul 2002 00:00:30 -0000	1.1.2.2
  @@ -74,8 +74,7 @@
    */
   public class DependSelector extends BaseSelector {
   
  -    private String targetdir = null;
  -    private File targetbase = null;
  +    private File targetdir = null;
       private Mapper mapperElement = null;
       private FileNameMapper map = null;
       private int granularity = 0;
  @@ -88,7 +87,12 @@
   
       public String toString() {
           StringBuffer buf = new StringBuffer("{dependselector targetdir: ");
  -        buf.append(targetdir);
  +        if (targetdir == null) {
  +            buf.append("NOT YET SET");
  +        }
  +        else {
  +            buf.append(targetdir.getName());
  +        }
           buf.append(" granularity: ");
           buf.append(granularity);
           if (map != null) {
  @@ -109,9 +113,8 @@
        *
        * @param targetdir the directory to scan looking for files.
        */
  -    public void setTargetdir(String targetdir) {
  -        this.targetdir = SelectorUtils.fixPath(targetdir);
  -        targetbase = new File(this.targetdir);
  +    public void setTargetdir(File targetdir) {
  +        this.targetdir = targetdir;
       }
   
       /**
  @@ -167,12 +170,6 @@
           // throw BuildException on error
           validate();
   
  -        // Get File object for the target directory
  -        File target = targetbase;
  -        if (target == null) {
  -            target = new File(basedir,targetdir);
  -        }
  -
           // Determine file whose out-of-dateness is to be checked
           String[] destfiles = map.mapFileName(filename);
           // If filename does not match the To attribute of the mapper
  @@ -183,10 +180,10 @@
           // Sanity check
           if (destfiles.length != 1 || destfiles[0] == null) {
               throw new BuildException("Invalid destination file results for "
  -                + targetdir + " with filename " + filename);
  +                + targetdir.getName() + " with filename " + filename);
           }
           String destname = destfiles[0];
  -        File destfile = new File(target,destname);
  +        File destfile = new File(targetdir,destname);
   
           return SelectorUtils.isOutOfDate(file, destfile, granularity);
       }
  
  
  
  1.1.2.2   +10 -13    jakarta-ant/src/main/org/apache/tools/ant/types/selectors/PresentSelector.java
  
  Index: PresentSelector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/selectors/PresentSelector.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- PresentSelector.java	31 May 2002 22:31:31 -0000	1.1.2.1
  +++ PresentSelector.java	6 Jul 2002 00:00:30 -0000	1.1.2.2
  @@ -74,8 +74,7 @@
    */
   public class PresentSelector extends BaseSelector {
   
  -    private String targetdir = null;
  -    private File targetbase = null;
  +    private File targetdir = null;
       private Mapper mapperElement = null;
       private FileNameMapper map = null;
       private boolean destmustexist = true;
  @@ -85,7 +84,12 @@
   
       public String toString() {
           StringBuffer buf = new StringBuffer("{presentselector targetdir: ");
  -        buf.append(targetdir);
  +        if (targetdir == null) {
  +            buf.append("NOT YET SET");
  +        }
  +        else {
  +            buf.append(targetdir.getName());
  +        }
           buf.append(" present: ");
           if (destmustexist) {
               buf.append("both");
  @@ -108,9 +112,8 @@
        *
        * @param targetdir the directory to scan looking for matching files.
        */
  -    public void setTargetdir(String targetdir) {
  -        this.targetdir = SelectorUtils.fixPath(targetdir);
  -        targetbase = new File(this.targetdir);
  +    public void setTargetdir(File targetdir) {
  +        this.targetdir = targetdir;
       }
   
       /**
  @@ -176,12 +179,6 @@
           // throw BuildException on error
           validate();
   
  -        // Get File object for the target directory
  -	File target = targetbase;
  -	if (target == null) {
  -            target = new File(basedir,targetdir);
  -	}
  -
           // Determine file whose existence is to be checked
           String[] destfiles = map.mapFileName(filename);
           // If filename does not match the To attribute of the mapper
  @@ -195,7 +192,7 @@
                   + targetdir + " with filename " + filename);
           }
           String destname = destfiles[0];
  -        File destfile = new File(target,destname);
  +        File destfile = new File(targetdir,destname);
           return destfile.exists() == destmustexist;
       }
   
  
  
  
  1.1.2.1   +0 -10     jakarta-ant/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java
  
  Index: SelectorUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- SelectorUtils.java	30 Apr 2002 22:38:36 -0000	1.1
  +++ SelectorUtils.java	6 Jul 2002 00:00:30 -0000	1.1.2.1
  @@ -522,16 +522,6 @@
           return ret;
       }
   
  -    /**
  -     * Helper method which corrects paths to use forward slashes.
  -     *
  -     * @param pattern the path pattern which needs correcting
  -     * @return corrected pattern
  -     */
  -    public static String fixPath(String pattern) {
  -        return pattern.replace('/',File.separatorChar).replace('\\',
  -                File.separatorChar);
  -    }
   
       /**
        * Returns dependency information on these two files. If src has been
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +67 -4     jakarta-ant/src/testcases/org/apache/tools/ant/types/selectors/BaseSelectorTest.java
  
  Index: BaseSelectorTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/types/selectors/BaseSelectorTest.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- BaseSelectorTest.java	31 May 2002 22:31:31 -0000	1.1.2.1
  +++ BaseSelectorTest.java	6 Jul 2002 00:00:30 -0000	1.1.2.2
  @@ -74,14 +74,19 @@
   
       private Project project;
       private TaskdefForMakingBed tbed = null;
  -    protected String basedirname = "src/etc/testcases/types/selectortest";
  +    protected String basedirname = "src/etc/testcases/types";
  +    protected String beddirname = basedirname + "/selectortest";
  +    protected String mirrordirname = basedirname + "/selectortest2";
       protected File basedir = new File(basedirname);
  +    protected File beddir = new File(beddirname);
  +    protected File mirrordir = new File(mirrordirname);
       protected String[] filenames = {".","asf-logo.gif.md5","asf-logo.gif.bz2",
               "asf-logo.gif.gz","copy.filterset.filtered","zip/asf-logo.gif.zip",
               "tar/asf-logo.gif.tar","tar/asf-logo-huge.tar",
               "tar/gz/asf-logo.gif.tar.gz","tar/bz2/asf-logo.gif.tar.bz2",
               "tar/bz2/asf-logo-huge.tar.bz2","tar/bz2"};
       protected File[] files = new File[filenames.length];
  +    protected File[] mirrorfiles = new File[filenames.length];
   
       public BaseSelectorTest(String name) {
           super(name);
  @@ -89,9 +94,11 @@
   
       public void setUp() {
           project = new Project();
  -        project.setBasedir(".");
  +        project.init();
  +        project.setBaseDir(basedir);
           for (int x = 0; x < files.length; x++) {
  -            files[x] = new File(basedir,filenames[x]);
  +            files[x] = new File(beddir,filenames[x]);
  +            mirrorfiles[x] = new File(mirrordir,filenames[x]);
           }
       }
   
  @@ -101,6 +108,10 @@
       public abstract BaseSelector getInstance();
   
   
  +    public Project getProject() {
  +        return project;
  +    }
  +
       /**
        * This is a test that all Selectors derived from BaseSelector can
        * use. It calls the setError() method and checks to ensure that a
  @@ -113,7 +124,7 @@
           }
           s.setError("test error");
           try {
  -            s.isSelected(basedir,filenames[0],files[0]);
  +            s.isSelected(beddir,filenames[0],files[0]);
               fail("Cannot cause BuildException when setError() is called");
           } catch (BuildException be) {
               assertEquals("test error",
  @@ -128,6 +139,26 @@
        * a string of "T"s amd "F"s
        */
       public String selectionString(FileSelector selector) {
  +        return selectionString(beddir,files,selector);
  +    }
  +
  +    /**
  +     * This is a helper method that takes a selector and calls its
  +     * isSelected() method on each file in the mirror testbed. This
  +     * variation is used for dependency checks and to get around the
  +     * limitations in the touch task when running JDK 1.1. It returns
  +     * a string of "T"s amd "F"s.
  +     */
  +    public String mirrorSelectionString(FileSelector selector) {
  +        return selectionString(mirrordir,mirrorfiles,selector);
  +    }
  +
  +    /**
  +     * Worker method for the two convenience methods above. Applies a
  +     * selector on a set of files passed in and returns a string of
  +     * "T"s amd "F"s from applying the selector to each file.
  +     */
  +    public String selectionString(File basedir, File[] files, FileSelector selector) {
           StringBuffer buf = new StringBuffer();
           for (int x = 0; x < files.length; x++) {
               if (selector.isSelected(basedir,filenames[x],files[x])) {
  @@ -168,6 +199,30 @@
       }
   
   
  +    /**
  +     * <p>Creates a mirror of the testbed for use in dependency checks.</p>
  +     *
  +     * <p>Note that the right way to call this is within a try block,
  +     * with a finally clause that calls cleanupMirror(). You place tests of
  +     * the isSelected() method within the try block.</p>
  +     */
  +    protected void makeMirror() {
  +        tbed = new TaskdefForMakingBed("mirrorfiles");
  +        tbed.setUp();
  +        tbed.makeMirror();
  +    }
  +
  +    /**
  +     * Cleans up the mirror testbed by calling a target in the
  +     * <code>src/etc/testcases/types/selectors.xml</code> file.
  +     */
  +    protected void cleanupMirror() {
  +        if (tbed != null) {
  +            tbed.deleteMirror();
  +            tbed = null;
  +        }
  +    }
  +
       private class TaskdefForMakingBed extends BuildFileTest {
   
           TaskdefForMakingBed(String name) {
  @@ -184,6 +239,14 @@
   
           public void makeTestbed() {
               executeTarget("setupfiles");
  +        }
  +
  +        public void makeMirror() {
  +            executeTarget("mirrorfiles");
  +        }
  +
  +        public void deleteMirror() {
  +            executeTarget("cleanup.mirrorfiles");
           }
       }
   
  
  
  
  1.1.2.3   +53 -26    jakarta-ant/src/testcases/org/apache/tools/ant/types/selectors/DateSelectorTest.java
  
  Index: DateSelectorTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/types/selectors/DateSelectorTest.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- DateSelectorTest.java	4 Jul 2002 14:54:43 -0000	1.1.2.2
  +++ DateSelectorTest.java	6 Jul 2002 00:00:30 -0000	1.1.2.3
  @@ -56,9 +56,13 @@
   
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Project;
  -import org.apache.tools.ant.util.*;
   import org.apache.tools.ant.BuildFileTest;
   import org.apache.tools.ant.types.Parameter;
  +import org.apache.tools.ant.util.JavaEnvUtils;
  +
  +import java.text.SimpleDateFormat;
  +import java.text.ParsePosition;
  +import java.util.Date;
   
   import junit.framework.TestCase;
   import junit.framework.AssertionFailedError;
  @@ -211,34 +215,35 @@
                   results = selectionString(s);
                   assertEquals("TFTFFFFFFFFT", results);
   
  -/*
  -            s = (DateSelector)getInstance();
  -            s.setDatetime("11/21/2001 4:55 AM");
  -            java.util.Date d = new java.util.Date("11/21/2001 4:55 AM");
  -            long milliseconds = s.getMillis();
  -            s.setWhen(equal);
  -            results = selectionString(s);
  -            assertEquals("TTFFTFFFTTTT", results);
  +                s = (DateSelector)getInstance();
  +                s.setDatetime("11/21/2001 4:55 AM");
  +                SimpleDateFormat formatter = new SimpleDateFormat();
  +                Date d = formatter.parse("11/21/2001 4:55 AM",new ParsePosition(0));
   
  -            s = (DateSelector)getInstance();
  -            s.setMillis(1006347300000L);
  -            s.setWhen(equal);
  -            results = selectionString(s);
  -            assertEquals("TTFFTFFFTTTT", results);
  +                long milliseconds = s.getMillis();
  +                s.setWhen(equal);
  +                results = selectionString(s);
  +                assertEquals("TTFFTFFFTTTT", results);
   
  -            s = (DateSelector)getInstance();
  -            s.setMillis(milliseconds);
  -            s.setWhen(equal);
  -            results = selectionString(s);
  -            assertEquals("TTFFTFFFTTTT", results);
  +                s = (DateSelector)getInstance();
  +                s.setMillis(1006347300000L);
  +                s.setWhen(equal);
  +                results = selectionString(s);
  +                assertEquals("TTFFTFFFTTTT", results);
  +
  +                s = (DateSelector)getInstance();
  +                s.setMillis(milliseconds);
  +                s.setWhen(equal);
  +                results = selectionString(s);
  +                assertEquals("TTFFTFFFTTTT", results);
  +
  +                s = (DateSelector)getInstance();
  +                s.setMillis(1006347305000L);
  +                s.setWhen(equal);
  +                s.setGranularity(15000);
  +                results = selectionString(s);
  +                assertEquals("TTFFTFFFTTTT", results);
   
  -            s = (DateSelector)getInstance();
  -            s.setMillis(1006347305000L);
  -            s.setWhen(equal);
  -            s.setGranularity(15000);
  -            results = selectionString(s);
  -            assertEquals("TTFFTFFFTTTT", results);
  -*/
                   s = (DateSelector)getInstance();
                   s.setDatetime("11/21/2001 4:56 AM");
                   s.setWhen(after);
  @@ -256,6 +261,28 @@
                   s.setParameters(params);
                   results = selectionString(s);
                   assertEquals("TFFTFTTTFFFT", results);
  +            }
  +            try {
  +                makeMirror();
  +
  +                s = (DateSelector)getInstance();
  +                long testtime = mirrorfiles[5].lastModified();
  +                s.setMillis(testtime);
  +                s.setWhen(after);
  +                s.setGranularity(2);
  +                results = mirrorSelectionString(s);
  +                assertEquals("TFFFFTTTTTTT", results);
  +
  +                s = (DateSelector)getInstance();
  +                testtime = mirrorfiles[6].lastModified();
  +                s.setMillis(testtime);
  +                s.setWhen(before);
  +                s.setGranularity(2);
  +                results = mirrorSelectionString(s);
  +                assertEquals("TTTTTTTFFFFT", results);
  +            }
  +            finally {
  +                cleanupMirror();
               }
   
           }
  
  
  
  1.1.2.3   +48 -8     jakarta-ant/src/testcases/org/apache/tools/ant/types/selectors/DependSelectorTest.java
  
  Index: DependSelectorTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/types/selectors/DependSelectorTest.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- DependSelectorTest.java	4 Jul 2002 14:54:43 -0000	1.1.2.2
  +++ DependSelectorTest.java	6 Jul 2002 00:00:30 -0000	1.1.2.3
  @@ -56,12 +56,14 @@
   
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Project;
  -import org.apache.tools.ant.util.*;
   import org.apache.tools.ant.BuildFileTest;
   import org.apache.tools.ant.types.Mapper;
   import org.apache.tools.ant.util.FileNameMapper;
   import org.apache.tools.ant.util.IdentityMapper;
   import org.apache.tools.ant.util.GlobPatternMapper;
  +import org.apache.tools.ant.util.JavaEnvUtils;
  +
  +import java.io.File;
   
   import junit.framework.TestCase;
   import junit.framework.AssertionFailedError;
  @@ -118,6 +120,7 @@
       public void testSelectionBehaviour() {
           DependSelector s;
           String results;
  +        File subdir;
           Mapper m;
           Mapper.MapperType identity = new Mapper.MapperType();
           identity.setValue("identity");
  @@ -130,12 +133,12 @@
               makeBed();
   
               s = (DependSelector)getInstance();
  -            s.setTargetdir(basedirname);
  +            s.setTargetdir(beddir);
               results = selectionString(s);
               assertEquals("FFFFFFFFFFFF", results);
   
               s = (DependSelector)getInstance();
  -            s.setTargetdir(basedirname);
  +            s.setTargetdir(beddir);
               m = s.createMapper();
               m.setType(identity);
               results = selectionString(s);
  @@ -143,30 +146,67 @@
   
               if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) {
                   s = (DependSelector)getInstance();
  -                s.setTargetdir(basedirname);
  +                s.setTargetdir(beddir);
                   m = s.createMapper();
                   m.setType(merge);
                   m.setTo("asf-logo.gif.gz");
                   results = selectionString(s);
  -                assertEquals("TFFFFTTTFFFF", results);
  -                
  +                assertEquals("TFFFFTTTFFF", results.substring(0,11));
  +
                   s = (DependSelector)getInstance();
  -                s.setTargetdir(basedirname);
  +                s.setTargetdir(beddir);
                   m = s.createMapper();
                   m.setType(merge);
                   m.setTo("asf-logo.gif.bz2");
                   results = selectionString(s);
                   assertEquals("TTFTTTTTTTTT", results);
  +
  +                // Test for path relative to project base directory
  +                s = (DependSelector)getInstance();
  +                subdir = new File("selectortest/tar/bz2");
  +                s.setTargetdir(subdir);
  +                m = s.createMapper();
  +                m.setType(glob);
  +                m.setFrom("*.bz2");
  +                m.setTo("*.tar.bz2");
  +                results = selectionString(s);
  +                assertEquals("FFTFFFFFFTTF", results);
               }
   
               s = (DependSelector)getInstance();
  -            s.setTargetdir(basedirname + "/tar/bz2");
  +            subdir = new File(beddir,"tar/bz2");
  +            s.setTargetdir(subdir);
               m = s.createMapper();
               m.setType(glob);
               m.setFrom("*.bz2");
               m.setTo("*.tar.bz2");
               results = selectionString(s);
               assertEquals("FFFFFFFFFTTF", results);
  +
  +            try {
  +                makeMirror();
  +
  +                s = (DependSelector)getInstance();
  +                File testdir = getProject().resolveFile("selectortest2");
  +                s.setTargetdir(testdir);
  +                results = selectionString(s);
  +                assertEquals("FFFTTFFFFFFF", results);
  +
  +                s = (DependSelector)getInstance();
  +                testdir = getProject().resolveFile("selectortest2/tar/bz2");
  +                s.setTargetdir(testdir);
  +                m = s.createMapper();
  +                m.setType(glob);
  +                m.setFrom("*.bz2");
  +                m.setTo("*.tar.bz2");
  +                results = mirrorSelectionString(s);
  +                assertEquals("FFFFFFFFFTTF", results);
  +                results = selectionString(s);
  +                assertEquals("FFFFFFFFFTTF", results);
  +            }
  +            finally {
  +                cleanupMirror();
  +            }
   
           }
           finally {
  
  
  
  1.1.2.2   +31 -6     jakarta-ant/src/testcases/org/apache/tools/ant/types/selectors/PresentSelectorTest.java
  
  Index: PresentSelectorTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/types/selectors/PresentSelectorTest.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- PresentSelectorTest.java	31 May 2002 22:31:31 -0000	1.1.2.1
  +++ PresentSelectorTest.java	6 Jul 2002 00:00:30 -0000	1.1.2.2
  @@ -63,6 +63,8 @@
   import org.apache.tools.ant.util.IdentityMapper;
   import org.apache.tools.ant.util.GlobPatternMapper;
   
  +import java.io.File;
  +
   import junit.framework.TestCase;
   import junit.framework.AssertionFailedError;
   
  @@ -132,26 +134,31 @@
               makeBed();
   
               s = (PresentSelector)getInstance();
  -            s.setTargetdir(basedirname);
  +            s.setTargetdir(beddir);
               results = selectionString(s);
               assertEquals("TTTTTTTTTTTT", results);
   
               s = (PresentSelector)getInstance();
  -            s.setTargetdir(basedirname);
  +            s.setTargetdir(beddir);
               m = s.createMapper();
               m.setType(identity);
               results = selectionString(s);
               assertEquals("TTTTTTTTTTTT", results);
   
               s = (PresentSelector)getInstance();
  -            s.setTargetdir("src/etc/testcases/taskdefs/expected");
  +            File subdir = new File("src/etc/testcases/taskdefs/expected");
  +            s.setTargetdir(subdir);
               m = s.createMapper();
               m.setType(flatten);
               results = selectionString(s);
  -            assertEquals("TTTTTTTTTTTF", results);
  +	    if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) {
  +                assertEquals("TTTTTFFFFFFF", results);
  +            } else {
  +                assertEquals("TTTTTTTTTTTF", results);
  +            }
   
               s = (PresentSelector)getInstance();
  -            s.setTargetdir(basedirname);
  +            s.setTargetdir(beddir);
               m = s.createMapper();
               m.setType(merge);
               m.setTo("asf-logo.gif.gz");
  @@ -159,13 +166,31 @@
               assertEquals("TTTTTTTTTTTT", results);
   
               s = (PresentSelector)getInstance();
  -            s.setTargetdir(basedirname + "/tar/bz2");
  +            subdir = new File(beddir, "tar/bz2");
  +            s.setTargetdir(subdir);
               m = s.createMapper();
               m.setType(glob);
               m.setFrom("*.bz2");
               m.setTo("*.tar.bz2");
               results = selectionString(s);
               assertEquals("FFTFFFFFFFFF", results);
  +
  +            try {
  +                makeMirror();
  +
  +                s = (PresentSelector)getInstance();
  +                subdir = getProject().resolveFile("selectortest2");
  +                s.setTargetdir(subdir);
  +                results = mirrorSelectionString(s);
  +                assertEquals("TTTFFTTTTTTT", results);
  +                results = selectionString(s);
  +                assertEquals("TTTFFTTTTTTT", results);
  +
  +
  +            }
  +            finally {
  +                cleanupMirror();
  +            }
   
           }
           finally {
  
  
  

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


Mime
View raw message