ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant/types DirSetTest.java FileSetTest.java
Date Wed, 03 Apr 2002 11:38:33 GMT
bodewig     02/04/03 03:38:33

  Modified:    src/main/org/apache/tools/ant/types DirSet.java
               src/testcases/org/apache/tools/ant/types DirSetTest.java
                        FileSetTest.java
  Log:
  reimplement DirSetTest as subclass of FileSetTest
  
  Revision  Changes    Path
  1.4       +2 -9      jakarta-ant/src/main/org/apache/tools/ant/types/DirSet.java
  
  Index: DirSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/DirSet.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DirSet.java	3 Apr 2002 11:24:54 -0000	1.3
  +++ DirSet.java	3 Apr 2002 11:38:33 -0000	1.4
  @@ -54,18 +54,11 @@
   
   package org.apache.tools.ant.types;
   
  -import org.apache.tools.ant.BuildException;
  -import org.apache.tools.ant.FileScanner;
  -import org.apache.tools.ant.DirectoryScanner;
  -import org.apache.tools.ant.Project;
  -
  -import java.io.File;
  -import java.util.Stack;
  -import java.util.Vector;
  -
   /**
    * Subclass as hint for supporting tasks that the included directories
    * instead of files should be used.
  + *
  + * @since Ant 1.5
    */
   public class DirSet extends FileSet {
       
  
  
  
  1.3       +12 -188   jakarta-ant/src/testcases/org/apache/tools/ant/types/DirSetTest.java
  
  Index: DirSetTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/types/DirSetTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DirSetTest.java	3 Apr 2002 11:24:55 -0000	1.2
  +++ DirSetTest.java	3 Apr 2002 11:38:33 -0000	1.3
  @@ -55,218 +55,42 @@
   package org.apache.tools.ant.types;
   
   import org.apache.tools.ant.BuildException;
  -import org.apache.tools.ant.Project;
  -
  -import junit.framework.TestCase;
  -import junit.framework.AssertionFailedError;
  -
  -import java.io.File;
   
   /**
    * JUnit 3 testcases for org.apache.tools.ant.types.DirSet.
    *
  - * <p>This doesn't actually test much, mainly reference handling.
  - *
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
    */
  -
  -public class DirSetTest extends TestCase {
  -
  -    private Project project;
  +public class DirSetTest extends FileSetTest {
   
       public DirSetTest(String name) {
           super(name);
       }
   
  -    public void setUp() {
  -        project = new Project();
  -        project.setBasedir(".");
  -    }
  -
  -    public void testEmptyElementIfIsReference() {
  -        DirSet f = new DirSet();
  -        f.setIncludes("**/*.java");
  -        try {
  -            f.setRefid(new Reference("dummyref"));
  -            fail("Can add reference to DirSet with elements from setIncludes");
  -        } catch (BuildException be) {
  -            assertEquals("You must not specify more than one attribute when using refid",
  -                         be.getMessage());
  -        }
  -
  -        f = new DirSet();
  -        f.createPatternSet();
  -        try {
  -            f.setRefid(new Reference("dummyref"));
  -            fail("Can add reference to DirSet with nested patternset element.");
  -        } catch (BuildException be) {
  -            assertEquals("You must not specify nested elements when using refid",
  -                         be.getMessage());
  -        }
  -
  -        f = new DirSet();
  -        f.createInclude();
  -        try {
  -            f.setRefid(new Reference("dummyref"));
  -            fail("Can add reference to DirSet with nested include element.");
  -        } catch (BuildException be) {
  -            assertEquals("You must not specify more than one attribute when using refid",
  -                         be.getMessage());
  -        }
  -
  -        f = new DirSet();
  -        f.setRefid(new Reference("dummyref"));
  -        try {
  -            f.setIncludes("**/*.java");
  -            fail("Can set includes in DirSet that is a reference.");
  -        } catch (BuildException be) {
  -            assertEquals("You must not specify more than one attribute when using refid",
  -                         be.getMessage());
  -        }
  -        try {
  -            f.setIncludesfile(new File("/a"));
  -            fail("Can set includesfile in DirSet that is a reference.");
  -        } catch (BuildException be) {
  -            assertEquals("You must not specify more than one attribute when using refid",
  -                         be.getMessage());
  -        }
  -        try {
  -            f.setExcludes("**/*.java");
  -            fail("Can set excludes in DirSet that is a reference.");
  -        } catch (BuildException be) {
  -            assertEquals("You must not specify more than one attribute when using refid",
  -                         be.getMessage());
  -        }
  -        try {
  -            f.setExcludesfile(new File("/a"));
  -            fail("Can set excludesfile in DirSet that is a reference.");
  -        } catch (BuildException be) {
  -            assertEquals("You must not specify more than one attribute when using refid",
  -                         be.getMessage());
  -        }
  -        try {
  -            f.setDir(project.resolveFile("."));
  -            fail("Can set dir in DirSet that is a reference.");
  -        } catch (BuildException be) {
  -            assertEquals("You must not specify more than one attribute when using refid",
  -                         be.getMessage());
  -        }
  -        try {
  -            f.createInclude();
  -            fail("Can add nested include in DirSet that is a reference.");
  -        } catch (BuildException be) {
  -            assertEquals("You must not specify nested elements when using refid",
  -                         be.getMessage());
  -        }
  -        try {
  -            f.createExclude();
  -            fail("Can add nested exclude in DirSet that is a reference.");
  -        } catch (BuildException be) {
  -            assertEquals("You must not specify nested elements when using refid",
  -                         be.getMessage());
  -        }
  -        try {
  -            f.createIncludesFile();
  -            fail("Can add nested includesfile in DirSet that is a reference.");
  -        } catch (BuildException be) {
  -            assertEquals("You must not specify nested elements when using refid",
  -                         be.getMessage());
  -        }
  -        try {
  -            f.createExcludesFile();
  -            fail("Can add nested excludesfile in DirSet that is a reference.");
  -        } catch (BuildException be) {
  -            assertEquals("You must not specify nested elements when using refid",
  -                         be.getMessage());
  -        }
  -        try {
  -            f.createPatternSet();
  -            fail("Can add nested patternset in DirSet that is a reference.");
  -        } catch (BuildException be) {
  -            assertEquals("You must not specify nested elements when using refid",
  -                         be.getMessage());
  -        }
  -    }
  -
  -    public void testCircularReferenceCheck() {
  -        DirSet f = new DirSet();
  -        project.addReference("dummy", f);
  -        f.setRefid(new Reference("dummy"));
  -        try {
  -            f.getDir(project);
  -            fail("Can make DirSet a Reference to itself.");
  -        } catch (BuildException be) {
  -            assertEquals("This data type contains a circular reference.",
  -                         be.getMessage());
  -        }
  -        try {
  -            f.getDirectoryScanner(project);
  -            fail("Can make DirSet a Reference to itself.");
  -        } catch (BuildException be) {
  -            assertEquals("This data type contains a circular reference.",
  -                         be.getMessage());
  -        }
  -
  -        // dummy1 --> dummy2 --> dummy3 --> dummy1
  -        DirSet f1 = new DirSet();
  -        project.addReference("dummy1", f1);
  -        f1.setRefid(new Reference("dummy2"));
  -        DirSet f2 = new DirSet();
  -        project.addReference("dummy2", f2);
  -        f2.setRefid(new Reference("dummy3"));
  -        DirSet f3 = new DirSet();
  -        project.addReference("dummy3", f3);
  -        f3.setRefid(new Reference("dummy1"));
  -        try {
  -            f1.getDir(project);
  -            fail("Can make circular reference.");
  -        } catch (BuildException be) {
  -            assertEquals("This data type contains a circular reference.",
  -                         be.getMessage());
  -        }
  -        try {
  -            f1.getDirectoryScanner(project);
  -            fail("Can make circular reference.");
  -        } catch (BuildException be) {
  -            assertEquals("This data type contains a circular reference.",
  -                         be.getMessage());
  -        }
  -
  -        // dummy1 --> dummy2 --> dummy3 
  -        // (which has the Project's basedir as root).
  -        f1 = new DirSet();
  -        project.addReference("dummy1", f1);
  -        f1.setRefid(new Reference("dummy2"));
  -        f2 = new DirSet();
  -        project.addReference("dummy2", f2);
  -        f2.setRefid(new Reference("dummy3"));
  -        f3 = new DirSet();
  -        project.addReference("dummy3", f3);
  -        f3.setDir(project.resolveFile("."));
  -        File dir = f1.getDir(project);
  -        assertEquals("Dir is basedir", dir, project.getBaseDir());
  +    protected FileSet getInstance() {
  +        return new DirSet();
       }
   
       public void testFileSetIsNoDirSet() {
  -        DirSet ds = new DirSet();
  -        ds.setProject(project);
  +        DirSet ds = (DirSet) getInstance();
  +        ds.setProject(getProject());
           FileSet fs = new FileSet();
  -        fs.setProject(project);
  -        project.addReference("dummy", fs);
  +        fs.setProject(getProject());
  +        getProject().addReference("dummy", fs);
           ds.setRefid(new Reference("dummy"));
           try {
  -            ds.getDir(project);
  +            ds.getDir(getProject());
               fail("DirSet created from FileSet reference");
           } catch (BuildException e) {
               assertEquals("dummy doesn\'t denote a dirset", e.getMessage());
           }
   
  -        ds = new DirSet();
  -        ds.setProject(project);
  -        project.addReference("dummy2", ds);
  +        ds = (DirSet) getInstance();
  +        ds.setProject(getProject());
  +        getProject().addReference("dummy2", ds);
           fs.setRefid(new Reference("dummy2"));
           try {
  -            fs.getDir(project);
  +            fs.getDir(getProject());
               fail("FileSet created from DirSet reference");
           } catch (BuildException e) {
               assertEquals("dummy2 doesn\'t denote a fileset", e.getMessage());
  
  
  
  1.7       +19 -11    jakarta-ant/src/testcases/org/apache/tools/ant/types/FileSetTest.java
  
  Index: FileSetTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/types/FileSetTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- FileSetTest.java	3 Apr 2002 10:54:54 -0000	1.6
  +++ FileSetTest.java	3 Apr 2002 11:38:33 -0000	1.7
  @@ -83,8 +83,16 @@
           project.setBasedir(".");
       }
   
  +    protected FileSet getInstance() {
  +        return new FileSet();
  +    }
  +
  +    protected Project getProject() {
  +        return project;
  +    }
  +
       public void testEmptyElementIfIsReference() {
  -        FileSet f = new FileSet();
  +        FileSet f = getInstance();
           f.setIncludes("**/*.java");
           try {
               f.setRefid(new Reference("dummyref"));
  @@ -94,7 +102,7 @@
                            be.getMessage());
           }
   
  -        f = new FileSet();
  +        f = getInstance();
           f.createPatternSet();
           try {
               f.setRefid(new Reference("dummyref"));
  @@ -104,7 +112,7 @@
                            be.getMessage());
           }
   
  -        f = new FileSet();
  +        f = getInstance();
           f.createInclude();
           try {
               f.setRefid(new Reference("dummyref"));
  @@ -114,7 +122,7 @@
                            be.getMessage());
           }
   
  -        f = new FileSet();
  +        f = getInstance();
           f.setRefid(new Reference("dummyref"));
           try {
               f.setIncludes("**/*.java");
  @@ -189,7 +197,7 @@
       }
   
       public void testCircularReferenceCheck() {
  -        FileSet f = new FileSet();
  +        FileSet f = getInstance();
           project.addReference("dummy", f);
           f.setRefid(new Reference("dummy"));
           try {
  @@ -208,13 +216,13 @@
           }
   
           // dummy1 --> dummy2 --> dummy3 --> dummy1
  -        FileSet f1 = new FileSet();
  +        FileSet f1 = getInstance();
           project.addReference("dummy1", f1);
           f1.setRefid(new Reference("dummy2"));
  -        FileSet f2 = new FileSet();
  +        FileSet f2 = getInstance();
           project.addReference("dummy2", f2);
           f2.setRefid(new Reference("dummy3"));
  -        FileSet f3 = new FileSet();
  +        FileSet f3 = getInstance();
           project.addReference("dummy3", f3);
           f3.setRefid(new Reference("dummy1"));
           try {
  @@ -234,13 +242,13 @@
   
           // dummy1 --> dummy2 --> dummy3 
           // (which has the Project's basedir as root).
  -        f1 = new FileSet();
  +        f1 = getInstance();
           project.addReference("dummy1", f1);
           f1.setRefid(new Reference("dummy2"));
  -        f2 = new FileSet();
  +        f2 = getInstance();
           project.addReference("dummy2", f2);
           f2.setRefid(new Reference("dummy3"));
  -        f3 = new FileSet();
  +        f3 = getInstance();
           project.addReference("dummy3", f3);
           f3.setDir(project.resolveFile("."));
           File dir = f1.getDir(project);
  
  
  

--
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