Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@apache.org Received: (qmail 86811 invoked from network); 28 May 2002 06:13:28 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 28 May 2002 06:13:28 -0000 Received: (qmail 8259 invoked by uid 97); 28 May 2002 06:13:30 -0000 Delivered-To: qmlist-jakarta-archive-ant-dev@jakarta.apache.org Received: (qmail 8129 invoked by uid 97); 28 May 2002 06:13:29 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 8104 invoked by uid 97); 28 May 2002 06:13:28 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Date: 28 May 2002 06:13:11 -0000 Message-ID: <20020528061311.16363.qmail@icarus.apache.org> From: bodewig@apache.org To: jakarta-ant-cvs@apache.org Subject: cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant/util FileUtilsTest.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N bodewig 02/05/27 23:13:11 Modified: src/etc/testcases/taskdefs Tag: ANT_15_BRANCH available.xml src/main/org/apache/tools/ant/taskdefs Tag: ANT_15_BRANCH Available.java Definer.java src/main/org/apache/tools/ant/util Tag: ANT_15_BRANCH FileUtils.java src/testcases/org/apache/tools/ant/taskdefs Tag: ANT_15_BRANCH AvailableTest.java src/testcases/org/apache/tools/ant/util Tag: ANT_15_BRANCH FileUtilsTest.java Log: Change signature of Available#setFile back to a File argument without breaking the path seatch ability. PR: 9079 Revision Changes Path No revision No revision 1.9.2.2 +10 -0 jakarta-ant/src/etc/testcases/taskdefs/available.xml Index: available.xml =================================================================== RCS file: /home/cvs/jakarta-ant/src/etc/testcases/taskdefs/available.xml,v retrieving revision 1.9.2.1 retrieving revision 1.9.2.2 diff -u -r1.9.2.1 -r1.9.2.2 --- available.xml 21 May 2002 09:52:23 -0000 1.9.2.1 +++ available.xml 28 May 2002 06:13:10 -0000 1.9.2.2 @@ -141,4 +141,14 @@ + + + + + + + + No revision No revision 1.44.2.2 +3 -2 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Available.java Index: Available.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Available.java,v retrieving revision 1.44.2.1 retrieving revision 1.44.2.2 diff -u -r1.44.2.1 -r1.44.2.2 --- Available.java 7 May 2002 12:06:49 -0000 1.44.2.1 +++ Available.java 28 May 2002 06:13:10 -0000 1.44.2.2 @@ -185,8 +185,9 @@ * * @param file the name of the file which is required. */ - public void setFile(String file) { - this.file = file; + public void setFile(File f) { + this.file = FileUtils.newFileUtils() + .removeLeadingPath(getProject().getBaseDir(), f); } /** 1.15.2.4 +3 -1 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Definer.java Index: Definer.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Definer.java,v retrieving revision 1.15.2.3 retrieving revision 1.15.2.4 diff -u -r1.15.2.3 -r1.15.2.4 --- Definer.java 27 May 2002 15:15:36 -0000 1.15.2.3 +++ Definer.java 28 May 2002 06:13:10 -0000 1.15.2.4 @@ -128,6 +128,8 @@ * This allow multiple taskdef/typedef to use the same class loader, * so they can be used togheter. It eliminate the need to * put them in the CLASSPATH. + * + * @since Ant 1.5 */ public void setLoaderRef(Reference r) { loaderId = r.getRefId(); @@ -240,7 +242,7 @@ if (loaderId != null) { Object reusedLoader = project.getReference(loaderId); if (reusedLoader != null) { - if(reusedLoader instanceof AntClassLoader) { + if (reusedLoader instanceof AntClassLoader) { return (AntClassLoader)reusedLoader; } // In future the reference object may be the type No revision No revision 1.25.2.3 +25 -1 jakarta-ant/src/main/org/apache/tools/ant/util/FileUtils.java Index: FileUtils.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/util/FileUtils.java,v retrieving revision 1.25.2.2 retrieving revision 1.25.2.3 diff -u -r1.25.2.2 -r1.25.2.3 --- FileUtils.java 23 May 2002 05:37:37 -0000 1.25.2.2 +++ FileUtils.java 28 May 2002 06:13:10 -0000 1.25.2.3 @@ -95,7 +95,7 @@ * @author Magesh Umasankar * @author Jeff Tulley * - * @version $Revision: 1.25.2.2 $ + * @version $Revision: 1.25.2.3 $ */ public class FileUtils { @@ -854,5 +854,29 @@ return !toTest.getAbsolutePath().equals(toTest.getCanonicalPath()); } + /** + * Removes a leading path from a second path. + * + * @param leading The leading path, must not be null, must be absolute. + * @param path The path to remove from, must not be null, must be absolute. + * + * @return path's normalized absolute if it doesn't start with + * leading, path's path with leading's path removed otherwise. + * + * @since Ant 1.5 + */ + public String removeLeadingPath(File leading, File path) { + String l = normalize(leading.getAbsolutePath()).getAbsolutePath(); + String p = normalize(path.getAbsolutePath()).getAbsolutePath(); + if (p.startsWith(l)) { + String result = p.substring(l.length()); + if (result.startsWith(File.separator)) { + result = result.substring(File.separator.length()); + } + return result; + } else { + return p; + } + } } No revision No revision 1.10.2.2 +12 -0 jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/AvailableTest.java Index: AvailableTest.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/AvailableTest.java,v retrieving revision 1.10.2.1 retrieving revision 1.10.2.2 diff -u -r1.10.2.1 -r1.10.2.2 --- AvailableTest.java 7 May 2002 12:06:49 -0000 1.10.2.1 +++ AvailableTest.java 28 May 2002 06:13:10 -0000 1.10.2.2 @@ -222,4 +222,16 @@ executeTarget("test24"); assertEquals("true",project.getProperty("test")); } + + // File is not found in specified filepath + public void testSearchInPathNotThere() { + executeTarget("searchInPathNotThere"); + assertNull(project.getProperty("test")); + } + + // File is not found in specified filepath + public void testSearchInPathIsThere() { + executeTarget("searchInPathIsThere"); + assertEquals("true",project.getProperty("test")); + } } No revision No revision 1.9.2.1 +24 -0 jakarta-ant/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java Index: FileUtilsTest.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java,v retrieving revision 1.9 retrieving revision 1.9.2.1 diff -u -r1.9 -r1.9.2.1 --- FileUtilsTest.java 2 Apr 2002 08:42:44 -0000 1.9 +++ FileUtilsTest.java 28 May 2002 06:13:11 -0000 1.9.2.1 @@ -383,6 +383,30 @@ } /** + * Test removeLeadingPath. + */ + public void testRemoveLeadingPath() { + assertEquals("bar", fu.removeLeadingPath(new File("/foo"), + new File("/foo/bar"))); + assertEquals("bar", fu.removeLeadingPath(new File("/foo/"), + new File("/foo/bar"))); + assertEquals("bar", fu.removeLeadingPath(new File("\\foo"), + new File("\\foo\\bar"))); + assertEquals("bar", fu.removeLeadingPath(new File("\\foo\\"), + new File("\\foo\\bar"))); + assertEquals("bar", fu.removeLeadingPath(new File("c:/foo"), + new File("c:/foo/bar"))); + assertEquals("bar", fu.removeLeadingPath(new File("c:/foo/"), + new File("c:/foo/bar"))); + assertEquals("bar", fu.removeLeadingPath(new File("c:\\foo"), + new File("c:\\foo\\bar"))); + assertEquals("bar", fu.removeLeadingPath(new File("c:\\foo\\"), + new File("c:\\foo\\bar"))); + assertEquals(fu.normalize("/bar").getAbsolutePath(), + fu.removeLeadingPath(new File("/foo"), new File("/bar"))); + } + + /** * adapt file separators to local conventions */ private String localize(String path) { -- To unsubscribe, e-mail: For additional commands, e-mail: