ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject cvs commit: ant/src/etc/testcases/taskdefs copy.xml
Date Mon, 08 Aug 2005 20:07:18 GMT
jhm         2005/08/08 13:07:18

  Modified:    src/testcases/org/apache/tools/ant/taskdefs CopyTest.java
               src/main/org/apache/tools/ant/taskdefs defaults.properties
                        Copy.java
               src/etc/testcases/taskdefs copy.xml
  Log:
  Starting introducing Resources in <copy>. (Committing for SVN-migration)
  
  Revision  Changes    Path
  1.21      +60 -0     ant/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java
  
  Index: CopyTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- CopyTest.java	29 Mar 2005 18:35:45 -0000	1.20
  +++ CopyTest.java	8 Aug 2005 20:07:17 -0000	1.21
  @@ -20,6 +20,7 @@
   import org.apache.tools.ant.BuildFileTest;
   import org.apache.tools.ant.util.FileUtils;
   import java.io.File;
  +import java.io.FileReader;
   import java.io.IOException;
   
   /**
  @@ -146,4 +147,63 @@
           expectBuildException("testMissingDirBail", "not-there doesn't exist");
           assertTrue(getBuildException().getMessage().endsWith(" not found."));
       }
  +    
  +    public void _testFileResourcePlain() {
  +    	executeTarget("testFileResourcePlain");
  +    	File file1 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file1.txt");
  +    	File file2 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file2.txt");
  +    	File file3 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file3.txt");
  +    	assertTrue(file1.exists());
  +    	assertTrue(file2.exists());
  +    	assertTrue(file3.exists());
  +    }
  +    
  +    public void _testFileResourceWithMapper() {
  +    	executeTarget("testFileResourceWithMapper");
  +    	File file1 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file1.txt.bak");
  +    	File file2 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file2.txt.bak");
  +    	File file3 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file3.txt.bak");
  +    	assertTrue(file1.exists());
  +    	assertTrue(file2.exists());
  +    	assertTrue(file3.exists());
  +    }
  +    
  +    public void _testFileResourceWithFilter() {
  +    	executeTarget("testFileResourceWithFilter");
  +    	File file1 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/fileNR.txt");
  +    	assertTrue(file1.exists());
  +    	try {
  +			String file1Content = FILE_UTILS.readFully(new FileReader(file1));
  +			assertEquals(file1Content, "This is file 42");
  +		} catch (IOException e) {
  +			// no-op: not a real business error
  +		}
  +    }
  +    
  +    public void _testPathAsResource() {
  +    	executeTarget("testPathAsResource");
  +    	File file1 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file1.txt.bak");
  +    	File file2 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file2.txt.bak");
  +    	File file3 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file3.txt.bak");
  +    	assertTrue(file1.exists());
  +    	assertTrue(file2.exists());
  +    	assertTrue(file3.exists());
  +    }
  +    
  +    public void _testResourcePlain() {
  +    	executeTarget("testResourcePlain");
  +    }
  +    
  +    public void _testResourcePlainWithMapper() {
  +    	executeTarget("testResourcePlainWithMapper");
  +    }
  +    
  +    public void _testResourcePlainWithFilter() {
  +    	executeTarget("testResourcePlainWithFilter");
  +    }
  +    
  +    public void _testOnlineResources() {
  +    	executeTarget("testOnlineResources");
  +    }
  +    
   }
  
  
  
  1.172     +1 -1      ant/src/main/org/apache/tools/ant/taskdefs/defaults.properties
  
  Index: defaults.properties
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/defaults.properties,v
  retrieving revision 1.171
  retrieving revision 1.172
  diff -u -r1.171 -r1.172
  --- defaults.properties	12 Jun 2005 23:15:57 -0000	1.171
  +++ defaults.properties	8 Aug 2005 20:07:17 -0000	1.172
  @@ -82,7 +82,6 @@
   libraries=org.apache.tools.ant.taskdefs.repository.Libraries
   length=org.apache.tools.ant.taskdefs.Length
   clone=org.apache.tools.ant.taskdefs.Clone
  -copypath=org.apache.tools.ant.taskdefs.CopyPath
   diagnostics=org.apache.tools.ant.taskdefs.DiagnosticsTask
   
   # optional tasks
  @@ -220,3 +219,4 @@
   rename=org.apache.tools.ant.taskdefs.Rename
   WsdlToDotnet=org.apache.tools.ant.taskdefs.optional.dotnet.WsdlToDotnet
   style=org.apache.tools.ant.taskdefs.XSLTProcess
  +copypath=org.apache.tools.ant.taskdefs.CopyPath
  
  
  
  1.85      +40 -1     ant/src/main/org/apache/tools/ant/taskdefs/Copy.java
  
  Index: Copy.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Copy.java,v
  retrieving revision 1.84
  retrieving revision 1.85
  diff -u -r1.84 -r1.85
  --- Copy.java	31 May 2005 19:01:34 -0000	1.84
  +++ Copy.java	8 Aug 2005 20:07:17 -0000	1.85
  @@ -31,6 +31,10 @@
   import org.apache.tools.ant.types.FilterSet;
   import org.apache.tools.ant.types.FilterChain;
   import org.apache.tools.ant.types.FilterSetCollection;
  +import org.apache.tools.ant.types.Resource;
  +import org.apache.tools.ant.types.Path;
  +import org.apache.tools.ant.types.ResourceCollection;
  +import org.apache.tools.ant.types.resources.Resources;
   import org.apache.tools.ant.util.FileUtils;
   import org.apache.tools.ant.util.FileNameMapper;
   import org.apache.tools.ant.util.IdentityMapper;
  @@ -274,7 +278,42 @@
       public void addFileset(FileSet set) {
           filesets.addElement(set);
       }
  -
  +    
  +    /* JHM: It would be the finest solution to use this method directly.
  +     * But if I understood the IntrospectionHelper(final Class bean) 
  +     * right - especially line 258ff (the last "else if" statement), 
  +     * I must have a <b>class</b> with an no-arg constructor. But I only 
  +     * have an interface. :-(
  +     * So I have to add the three methods ... But I can reuse this
  +     * method :-)
  +     *  
  +     */
  +    public void add(ResourceCollection res) {
  +    	//TODO: implement resources
  +    }
  +    /**
  +     * Adds a <code>path</code> element as a nested ResourceCollection.
  +     * @param path
  +     */
  +    public void addPath(Path path) {
  +    	//add((ResourceCollection)path);
  +    }
  +    /**
  +     * Adds a Resource element as a nested ResourceCollection.
  +     * @param path
  +     * /
  +    public void add(Resource res) {
  +    	add((ResourceCollection)res);
  +    }
  +    /**
  +     * Adds a <code>resources</code> element as a nested ResourceCollection.
  +     * @param path
  +     * /
  +    public void add(Resources res) {
  +    	add((ResourceCollection)res);
  +    }
  +    */
  +    
       /**
        * Define the mapper to map source to destination files.
        * @return a mapper to be configured.
  
  
  
  1.14      +70 -1     ant/src/etc/testcases/taskdefs/copy.xml
  
  Index: copy.xml
  ===================================================================
  RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/copy.xml,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- copy.xml	7 Jan 2004 10:25:08 -0000	1.13
  +++ copy.xml	8 Aug 2005 20:07:18 -0000	1.14
  @@ -121,7 +121,76 @@
       </copy>
     </target>
   
  +<!--	
  +  <typedef name="resource" classname="org.apache.tools.ant.types.Resource"/>
  +  <typedef name="resources" classname="org.apache.tools.ant.types.resources.Resources"/>
  +-->  
  +	
  +  <target name="testFileResourcePlain" depends="testResource.prepare">
  +  	<copy todir="${to.dir}">
  +      <resources>
  +        <file file="${from.dir}/file1.txt"/>
  +        <file file="${from.dir}/file2.txt"/>
  +        <file file="${from.dir}/file3.txt"/>
  +	  </resources>  	  
  +  	</copy>
  +  </target>
  +
  +  <target name="testFileResourceWithMapper" depends="testResource.prepare">
  +  	<copy todir="${to.dir}">
  +      <resources>
  +        <file file="${from.dir}/file1.txt"/>
  +        <file file="${from.dir}/file2.txt"/>
  +        <file file="${from.dir}/file3.txt"/>
  +	  </resources>  	  
  +      <regexpmapper from="^(.*)\.txt$$" to="\1.txt.bak"/>
  +  	</copy>
  +  </target>
  +
  +
  +  <property name="to.dir" value="copy-todir-tmp"/>
  +  <property name="from.dir" value="copy-todir-tmp"/>
  +	
  +  <target name="testResource.prepare">
  +  	<mkdir dir="${from.dir}"/>
  +  	<concat destfile="${to.dir}/file1.txt">This is file 1</concat>
  +  	<concat destfile="${to.dir}/file2.txt">This is file 2</concat>
  +  	<concat destfile="${to.dir}/file3.txt">This is file 3</concat>
  +  	<concat destfile="${to.dir}/fileNR.txt">This is file @nr@</concat>
  +  </target>
  +	
  +  <target name="testFileResourceWithFilter" depends="testResource.prepare">
  +  	<copy todir="${to.dir}">
  +      <resources>
  +        <file file="${from.dir}/fileNR.txt"/>
  +	  </resources>  	  
  +      <filterset>
  +  	    <filter token="NR" value="42"/>
  +  	  </filterset>
  +  	</copy>
  +  </target>
  +		
  +  <target name="testResourcePlain">
  +  </target>
  +  	
  +  <target name="testResourcePlainWithMapper">
  +  </target>
       
  +  <target name="testResourcePlainWithFilter">
  +  </target>
  +	
  +  <target name="testOnlineResources">
  +  </target>
  +	
  +  <target name="testPathAsResource">
  +    <copy todir="${to.dir}">
  +      <path>
  +        <fileset dir="${from.dir}"/>
  +      </path> 	
  +    </copy>  	
  +  </target>
  +	
  +	
     
     <target name="cleanup"> 
       <delete file="copytest1.tmp"/>
  @@ -135,7 +204,7 @@
       <delete dir="copytest1dir"/>
       <delete quiet="yes" file="copy.filter.out"/>
       <delete quiet="yes" file="copy.filter.inp"/>
  +  	<delete dir="${to.dir}"/>
     </target>
   
  -
   </project>
  
  
  

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


Mime
View raw message