Also removed unused/* imports along the way. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277295 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -47,7 +47,7 @@ import org.apache.tools.ant.util.LoaderUtils; | |||||
| */ | */ | ||||
| public class AntClassLoader extends ClassLoader implements SubBuildListener { | public class AntClassLoader extends ClassLoader implements SubBuildListener { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.newFileUtils(); | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * An enumeration of all resources of a given name found within the | * An enumeration of all resources of a given name found within the | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -165,6 +165,9 @@ public class DirectoryScanner | |||||
| "**/.DS_Store" | "**/.DS_Store" | ||||
| }; | }; | ||||
| /** Helper. */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * Patterns which should be excluded by default. | * Patterns which should be excluded by default. | ||||
| * | * | ||||
| @@ -241,9 +244,6 @@ public class DirectoryScanner | |||||
| */ | */ | ||||
| private boolean followSymlinks = true; | private boolean followSymlinks = true; | ||||
| /** Helper. */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.newFileUtils(); | |||||
| /** Whether or not everything tested so far has been included. */ | /** Whether or not everything tested so far has been included. */ | ||||
| protected boolean everythingIncluded = true; | protected boolean everythingIncluded = true; | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000,2002-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -39,6 +39,8 @@ public class Location implements Serializable { | |||||
| /** Location to use when one is needed but no information is available */ | /** Location to use when one is needed but no information is available */ | ||||
| public static final Location UNKNOWN_LOCATION = new Location(); | public static final Location UNKNOWN_LOCATION = new Location(); | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * Creates an "unknown" location. | * Creates an "unknown" location. | ||||
| */ | */ | ||||
| @@ -84,7 +86,7 @@ public class Location implements Serializable { | |||||
| */ | */ | ||||
| public Location(String fileName, int lineNumber, int columnNumber) { | public Location(String fileName, int lineNumber, int columnNumber) { | ||||
| if (fileName != null && fileName.startsWith("file:")) { | if (fileName != null && fileName.startsWith("file:")) { | ||||
| this.fileName = FileUtils.newFileUtils().fromURI(fileName); | |||||
| this.fileName = FILE_UTILS.fromURI(fileName); | |||||
| } else { | } else { | ||||
| this.fileName = fileName; | this.fileName = fileName; | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -123,6 +123,9 @@ public class Project { | |||||
| /** Default filter end token. */ | /** Default filter end token. */ | ||||
| public static final String TOKEN_END = FilterSet.DEFAULT_TOKEN_END; | public static final String TOKEN_END = FilterSet.DEFAULT_TOKEN_END; | ||||
| /** Instance of a utility class to use for file operations. */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** Name of this project. */ | /** Name of this project. */ | ||||
| private String name; | private String name; | ||||
| /** Description for this project (if any). */ | /** Description for this project (if any). */ | ||||
| @@ -185,6 +188,11 @@ public class Project { | |||||
| */ | */ | ||||
| private boolean keepGoingMode = false; | private boolean keepGoingMode = false; | ||||
| /** | |||||
| * Flag which catches Listeners which try to use System.out or System.err | |||||
| */ | |||||
| private boolean loggingMessage = false; | |||||
| /** | /** | ||||
| * Sets the input handler | * Sets the input handler | ||||
| * | * | ||||
| @@ -227,19 +235,10 @@ public class Project { | |||||
| return inputHandler; | return inputHandler; | ||||
| } | } | ||||
| /** Instance of a utility class to use for file operations. */ | |||||
| private FileUtils fileUtils; | |||||
| /** | |||||
| * Flag which catches Listeners which try to use System.out or System.err | |||||
| */ | |||||
| private boolean loggingMessage = false; | |||||
| /** | /** | ||||
| * Creates a new Ant project. | * Creates a new Ant project. | ||||
| */ | */ | ||||
| public Project() { | public Project() { | ||||
| fileUtils = FileUtils.newFileUtils(); | |||||
| inputHandler = new DefaultInputHandler(); | inputHandler = new DefaultInputHandler(); | ||||
| } | } | ||||
| @@ -731,7 +730,7 @@ public class Project { | |||||
| * isn't a directory | * isn't a directory | ||||
| */ | */ | ||||
| public void setBaseDir(File baseDir) throws BuildException { | public void setBaseDir(File baseDir) throws BuildException { | ||||
| baseDir = fileUtils.normalize(baseDir.getAbsolutePath()); | |||||
| baseDir = FILE_UTILS.normalize(baseDir.getAbsolutePath()); | |||||
| if (!baseDir.exists()) { | if (!baseDir.exists()) { | ||||
| throw new BuildException("Basedir " + baseDir.getAbsolutePath() | throw new BuildException("Basedir " + baseDir.getAbsolutePath() | ||||
| + " does not exist"); | + " does not exist"); | ||||
| @@ -1300,7 +1299,7 @@ public class Project { | |||||
| * @deprecated | * @deprecated | ||||
| */ | */ | ||||
| public File resolveFile(String fileName, File rootDir) { | public File resolveFile(String fileName, File rootDir) { | ||||
| return fileUtils.resolveFile(rootDir, fileName); | |||||
| return FILE_UTILS.resolveFile(rootDir, fileName); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -1316,7 +1315,7 @@ public class Project { | |||||
| * | * | ||||
| */ | */ | ||||
| public File resolveFile(String fileName) { | public File resolveFile(String fileName) { | ||||
| return fileUtils.resolveFile(baseDir, fileName); | |||||
| return FILE_UTILS.resolveFile(baseDir, fileName); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -1370,7 +1369,7 @@ public class Project { | |||||
| */ | */ | ||||
| public void copyFile(String sourceFile, String destFile) | public void copyFile(String sourceFile, String destFile) | ||||
| throws IOException { | throws IOException { | ||||
| fileUtils.copyFile(sourceFile, destFile); | |||||
| FILE_UTILS.copyFile(sourceFile, destFile); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -1390,7 +1389,7 @@ public class Project { | |||||
| */ | */ | ||||
| public void copyFile(String sourceFile, String destFile, boolean filtering) | public void copyFile(String sourceFile, String destFile, boolean filtering) | ||||
| throws IOException { | throws IOException { | ||||
| fileUtils.copyFile(sourceFile, destFile, | |||||
| FILE_UTILS.copyFile(sourceFile, destFile, | |||||
| filtering ? globalFilters : null); | filtering ? globalFilters : null); | ||||
| } | } | ||||
| @@ -1414,7 +1413,7 @@ public class Project { | |||||
| */ | */ | ||||
| public void copyFile(String sourceFile, String destFile, boolean filtering, | public void copyFile(String sourceFile, String destFile, boolean filtering, | ||||
| boolean overwrite) throws IOException { | boolean overwrite) throws IOException { | ||||
| fileUtils.copyFile(sourceFile, destFile, | |||||
| FILE_UTILS.copyFile(sourceFile, destFile, | |||||
| filtering ? globalFilters : null, overwrite); | filtering ? globalFilters : null, overwrite); | ||||
| } | } | ||||
| @@ -1444,7 +1443,7 @@ public class Project { | |||||
| public void copyFile(String sourceFile, String destFile, boolean filtering, | public void copyFile(String sourceFile, String destFile, boolean filtering, | ||||
| boolean overwrite, boolean preserveLastModified) | boolean overwrite, boolean preserveLastModified) | ||||
| throws IOException { | throws IOException { | ||||
| fileUtils.copyFile(sourceFile, destFile, | |||||
| FILE_UTILS.copyFile(sourceFile, destFile, | |||||
| filtering ? globalFilters : null, overwrite, preserveLastModified); | filtering ? globalFilters : null, overwrite, preserveLastModified); | ||||
| } | } | ||||
| @@ -1462,7 +1461,7 @@ public class Project { | |||||
| * @deprecated | * @deprecated | ||||
| */ | */ | ||||
| public void copyFile(File sourceFile, File destFile) throws IOException { | public void copyFile(File sourceFile, File destFile) throws IOException { | ||||
| fileUtils.copyFile(sourceFile, destFile); | |||||
| FILE_UTILS.copyFile(sourceFile, destFile); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -1482,7 +1481,7 @@ public class Project { | |||||
| */ | */ | ||||
| public void copyFile(File sourceFile, File destFile, boolean filtering) | public void copyFile(File sourceFile, File destFile, boolean filtering) | ||||
| throws IOException { | throws IOException { | ||||
| fileUtils.copyFile(sourceFile, destFile, | |||||
| FILE_UTILS.copyFile(sourceFile, destFile, | |||||
| filtering ? globalFilters : null); | filtering ? globalFilters : null); | ||||
| } | } | ||||
| @@ -1506,7 +1505,7 @@ public class Project { | |||||
| */ | */ | ||||
| public void copyFile(File sourceFile, File destFile, boolean filtering, | public void copyFile(File sourceFile, File destFile, boolean filtering, | ||||
| boolean overwrite) throws IOException { | boolean overwrite) throws IOException { | ||||
| fileUtils.copyFile(sourceFile, destFile, | |||||
| FILE_UTILS.copyFile(sourceFile, destFile, | |||||
| filtering ? globalFilters : null, overwrite); | filtering ? globalFilters : null, overwrite); | ||||
| } | } | ||||
| @@ -1536,7 +1535,7 @@ public class Project { | |||||
| public void copyFile(File sourceFile, File destFile, boolean filtering, | public void copyFile(File sourceFile, File destFile, boolean filtering, | ||||
| boolean overwrite, boolean preserveLastModified) | boolean overwrite, boolean preserveLastModified) | ||||
| throws IOException { | throws IOException { | ||||
| fileUtils.copyFile(sourceFile, destFile, | |||||
| FILE_UTILS.copyFile(sourceFile, destFile, | |||||
| filtering ? globalFilters : null, overwrite, preserveLastModified); | filtering ? globalFilters : null, overwrite, preserveLastModified); | ||||
| } | } | ||||
| @@ -1557,7 +1556,7 @@ public class Project { | |||||
| */ | */ | ||||
| public void setFileLastModified(File file, long time) | public void setFileLastModified(File file, long time) | ||||
| throws BuildException { | throws BuildException { | ||||
| fileUtils.setFileLastModified(file, time); | |||||
| FILE_UTILS.setFileLastModified(file, time); | |||||
| log("Setting modification time for " + file, MSG_VERBOSE); | log("Setting modification time for " + file, MSG_VERBOSE); | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -64,7 +64,7 @@ public class ProjectHelper2 extends ProjectHelper { | |||||
| /** | /** | ||||
| * helper for path -> URI and URI -> path conversions. | * helper for path -> URI and URI -> path conversions. | ||||
| */ | */ | ||||
| private static FileUtils fu = FileUtils.newFileUtils(); | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * Parse an unknown element from a url | * Parse an unknown element from a url | ||||
| @@ -157,7 +157,7 @@ public class ProjectHelper2 extends ProjectHelper { | |||||
| if (source instanceof File) { | if (source instanceof File) { | ||||
| buildFile = (File) source; | buildFile = (File) source; | ||||
| buildFile = fu.normalize(buildFile.getAbsolutePath()); | |||||
| buildFile = FILE_UTILS.normalize(buildFile.getAbsolutePath()); | |||||
| context.setBuildFile(buildFile); | context.setBuildFile(buildFile); | ||||
| buildFileName = buildFile.toString(); | buildFileName = buildFile.toString(); | ||||
| // } else if (source instanceof InputStream ) { | // } else if (source instanceof InputStream ) { | ||||
| @@ -188,7 +188,7 @@ public class ProjectHelper2 extends ProjectHelper { | |||||
| String uri = null; | String uri = null; | ||||
| if (buildFile != null) { | if (buildFile != null) { | ||||
| uri = fu.toURI(buildFile.getAbsolutePath()); | |||||
| uri = FILE_UTILS.toURI(buildFile.getAbsolutePath()); | |||||
| inputStream = new FileInputStream(buildFile); | inputStream = new FileInputStream(buildFile); | ||||
| } else { | } else { | ||||
| inputStream = url.openStream(); | inputStream = url.openStream(); | ||||
| @@ -415,16 +415,16 @@ public class ProjectHelper2 extends ProjectHelper { | |||||
| + systemId, Project.MSG_VERBOSE); | + systemId, Project.MSG_VERBOSE); | ||||
| if (systemId.startsWith("file:")) { | if (systemId.startsWith("file:")) { | ||||
| String path = fu.fromURI(systemId); | |||||
| String path = FILE_UTILS.fromURI(systemId); | |||||
| File file = new File(path); | File file = new File(path); | ||||
| if (!file.isAbsolute()) { | if (!file.isAbsolute()) { | ||||
| file = fu.resolveFile(context.getBuildFileParent(), path); | |||||
| file = FILE_UTILS.resolveFile(context.getBuildFileParent(), path); | |||||
| } | } | ||||
| try { | try { | ||||
| InputSource inputSource = | InputSource inputSource = | ||||
| new InputSource(new FileInputStream(file)); | new InputSource(new FileInputStream(file)); | ||||
| inputSource.setSystemId(fu.toURI(file.getAbsolutePath())); | |||||
| inputSource.setSystemId(FILE_UTILS.toURI(file.getAbsolutePath())); | |||||
| return inputSource; | return inputSource; | ||||
| } catch (FileNotFoundException fne) { | } catch (FileNotFoundException fne) { | ||||
| context.getProject().log(file.getAbsolutePath() | context.getProject().log(file.getAbsolutePath() | ||||
| @@ -695,7 +695,7 @@ public class ProjectHelper2 extends ProjectHelper { | |||||
| if ((new File(baseDir)).isAbsolute()) { | if ((new File(baseDir)).isAbsolute()) { | ||||
| project.setBasedir(baseDir); | project.setBasedir(baseDir); | ||||
| } else { | } else { | ||||
| project.setBaseDir(fu.resolveFile( | |||||
| project.setBaseDir(FILE_UTILS.resolveFile( | |||||
| context.getBuildFileParent(), baseDir)); | context.getBuildFileParent(), baseDir)); | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -51,6 +51,11 @@ import org.xml.sax.helpers.XMLReaderAdapter; | |||||
| */ | */ | ||||
| public class ProjectHelperImpl extends ProjectHelper { | public class ProjectHelperImpl extends ProjectHelper { | ||||
| /** | |||||
| * helper for path -> URI and URI -> path conversions. | |||||
| */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * SAX 1 style parser used to parse the given file. This may | * SAX 1 style parser used to parse the given file. This may | ||||
| * in fact be a SAX 2 XMLReader wrapped in an XMLReaderAdapter. | * in fact be a SAX 2 XMLReader wrapped in an XMLReaderAdapter. | ||||
| @@ -78,10 +83,6 @@ public class ProjectHelperImpl extends ProjectHelper { | |||||
| * been placed outside of targets.</p> | * been placed outside of targets.</p> | ||||
| */ | */ | ||||
| private Target implicitTarget = new Target(); | private Target implicitTarget = new Target(); | ||||
| /** | |||||
| * helper for path -> URI and URI -> path conversions. | |||||
| */ | |||||
| private static FileUtils fu = FileUtils.newFileUtils(); | |||||
| /** | /** | ||||
| * default constructor | * default constructor | ||||
| @@ -119,7 +120,7 @@ public class ProjectHelperImpl extends ProjectHelper { | |||||
| } | } | ||||
| String uri = fu.toURI(bFile.getAbsolutePath()); | |||||
| String uri = FILE_UTILS.toURI(bFile.getAbsolutePath()); | |||||
| inputStream = new FileInputStream(bFile); | inputStream = new FileInputStream(bFile); | ||||
| inputSource = new InputSource(inputStream); | inputSource = new InputSource(inputStream); | ||||
| inputSource.setSystemId(uri); | inputSource.setSystemId(uri); | ||||
| @@ -296,15 +297,15 @@ public class ProjectHelperImpl extends ProjectHelper { | |||||
| helperImpl.project.log("resolving systemId: " + systemId, Project.MSG_VERBOSE); | helperImpl.project.log("resolving systemId: " + systemId, Project.MSG_VERBOSE); | ||||
| if (systemId.startsWith("file:")) { | if (systemId.startsWith("file:")) { | ||||
| String path = fu.fromURI(systemId); | |||||
| String path = FILE_UTILS.fromURI(systemId); | |||||
| File file = new File(path); | File file = new File(path); | ||||
| if (!file.isAbsolute()) { | if (!file.isAbsolute()) { | ||||
| file = fu.resolveFile(helperImpl.buildFileParent, path); | |||||
| file = FILE_UTILS.resolveFile(helperImpl.buildFileParent, path); | |||||
| } | } | ||||
| try { | try { | ||||
| InputSource inputSource = new InputSource(new FileInputStream(file)); | InputSource inputSource = new InputSource(new FileInputStream(file)); | ||||
| inputSource.setSystemId(fu.toURI(file.getAbsolutePath())); | |||||
| inputSource.setSystemId(FILE_UTILS.toURI(file.getAbsolutePath())); | |||||
| return inputSource; | return inputSource; | ||||
| } catch (FileNotFoundException fne) { | } catch (FileNotFoundException fne) { | ||||
| helperImpl.project.log(file.getAbsolutePath() + " could not be found", | helperImpl.project.log(file.getAbsolutePath() + " could not be found", | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2003-2004 The Apache Software Foundation | |||||
| * Copyright 2003-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -44,7 +44,7 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| */ | */ | ||||
| public class AntClassLoader2 extends AntClassLoader { | public class AntClassLoader2 extends AntClassLoader { | ||||
| /** Instance of a utility class to use for file operations. */ | /** Instance of a utility class to use for file operations. */ | ||||
| private FileUtils fileUtils; | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** Static map of jar file/time to manifiest class-path entries */ | /** Static map of jar file/time to manifiest class-path entries */ | ||||
| private static Map pathMap = Collections.synchronizedMap(new HashMap()); | private static Map pathMap = Collections.synchronizedMap(new HashMap()); | ||||
| @@ -53,7 +53,6 @@ public class AntClassLoader2 extends AntClassLoader { | |||||
| * Constructor | * Constructor | ||||
| */ | */ | ||||
| public AntClassLoader2() { | public AntClassLoader2() { | ||||
| fileUtils = FileUtils.newFileUtils(); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -279,7 +278,7 @@ public class AntClassLoader2 extends AntClassLoader { | |||||
| } | } | ||||
| if (!"".equals(classpath)) { | if (!"".equals(classpath)) { | ||||
| URL baseURL = fileUtils.getFileURL(pathComponent); | |||||
| URL baseURL = FILE_UTILS.getFileURL(pathComponent); | |||||
| StringTokenizer st = new StringTokenizer(classpath); | StringTokenizer st = new StringTokenizer(classpath); | ||||
| while (st.hasMoreTokens()) { | while (st.hasMoreTokens()) { | ||||
| String classpathElement = st.nextToken(); | String classpathElement = st.nextToken(); | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -67,6 +67,8 @@ public class Ant extends Task { | |||||
| /** Target Executor */ | /** Target Executor */ | ||||
| private static final Executor EXECUTOR = new SingleCheckExecutor(); | private static final Executor EXECUTOR = new SingleCheckExecutor(); | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** the basedir where is executed the build file */ | /** the basedir where is executed the build file */ | ||||
| private File dir = null; | private File dir = null; | ||||
| @@ -164,7 +166,7 @@ public class Ant extends Task { | |||||
| if (output != null) { | if (output != null) { | ||||
| File outfile = null; | File outfile = null; | ||||
| if (dir != null) { | if (dir != null) { | ||||
| outfile = FileUtils.newFileUtils().resolveFile(dir, output); | |||||
| outfile = FILE_UTILS.resolveFile(dir, output); | |||||
| } else { | } else { | ||||
| outfile = getProject().resolveFile(output); | outfile = getProject().resolveFile(output); | ||||
| } | } | ||||
| @@ -305,7 +307,7 @@ public class Ant extends Task { | |||||
| antFile = "build.xml"; | antFile = "build.xml"; | ||||
| } | } | ||||
| File file = FileUtils.newFileUtils().resolveFile(dir, antFile); | |||||
| File file = FILE_UTILS.resolveFile(dir, antFile); | |||||
| antFile = file.getAbsolutePath(); | antFile = file.getAbsolutePath(); | ||||
| log("calling target(s) " | log("calling target(s) " | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -38,6 +38,7 @@ import org.apache.tools.ant.util.StringUtils; | |||||
| * @ant.task category="control" | * @ant.task category="control" | ||||
| */ | */ | ||||
| public class Available extends Task implements Condition { | public class Available extends Task implements Condition { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private String property; | private String property; | ||||
| private String classname; | private String classname; | ||||
| @@ -143,8 +144,7 @@ public class Available extends Task implements Condition { | |||||
| * @param file the name of the file which is required. | * @param file the name of the file which is required. | ||||
| */ | */ | ||||
| public void setFile(File file) { | public void setFile(File file) { | ||||
| this.file = FileUtils.newFileUtils() | |||||
| .removeLeadingPath(getProject().getBaseDir(), file); | |||||
| this.file = FILE_UTILS.removeLeadingPath(getProject().getBaseDir(), file); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2002-2004 The Apache Software Foundation | |||||
| * Copyright 2002-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -48,6 +48,8 @@ public class BuildNumber | |||||
| /** The default filename to use if no file specified. */ | /** The default filename to use if no file specified. */ | ||||
| private static final String DEFAULT_FILENAME = DEFAULT_PROPERTY_NAME; | private static final String DEFAULT_FILENAME = DEFAULT_PROPERTY_NAME; | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** The File in which the build number is stored. */ | /** The File in which the build number is stored. */ | ||||
| private File myFile; | private File myFile; | ||||
| @@ -177,7 +179,7 @@ public class BuildNumber | |||||
| if (!myFile.exists()) { | if (!myFile.exists()) { | ||||
| try { | try { | ||||
| FileUtils.newFileUtils().createNewFile(myFile); | |||||
| FILE_UTILS.createNewFile(myFile); | |||||
| } catch (final IOException ioe) { | } catch (final IOException ioe) { | ||||
| final String message = | final String message = | ||||
| myFile + " doesn't exist and new file can't be created."; | myFile + " doesn't exist and new file can't be created."; | ||||
| @@ -68,6 +68,7 @@ public class Concat extends Task { | |||||
| // The size of buffers to be used | // The size of buffers to be used | ||||
| private static final int BUFFER_SIZE = 8192; | private static final int BUFFER_SIZE = 8192; | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| // Attributes. | // Attributes. | ||||
| /** | /** | ||||
| @@ -125,9 +126,6 @@ public class Concat extends Task { | |||||
| /** internal variable - used to collect the source files from sources */ | /** internal variable - used to collect the source files from sources */ | ||||
| private Vector sourceFiles = new Vector(); | private Vector sourceFiles = new Vector(); | ||||
| /** 1.1 utilities and copy utilities */ | |||||
| private static FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| // Attribute setters. | // Attribute setters. | ||||
| /** | /** | ||||
| @@ -465,7 +463,7 @@ public class Concat extends Task { | |||||
| continue; | continue; | ||||
| } | } | ||||
| if (destinationFile != null | if (destinationFile != null | ||||
| && fileUtils.fileNameEquals(destinationFile, file)) { | |||||
| && FILE_UTILS.fileNameEquals(destinationFile, file)) { | |||||
| throw new BuildException("Input file \"" | throw new BuildException("Input file \"" | ||||
| + file + "\" " | + file + "\" " | ||||
| + "is the same as the output file."); | + "is the same as the output file."); | ||||
| @@ -24,7 +24,6 @@ import java.util.Vector; | |||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.taskdefs.condition.Os; | |||||
| import org.apache.tools.ant.types.FileList; | import org.apache.tools.ant.types.FileList; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| @@ -78,6 +77,8 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| */ | */ | ||||
| public class DependSet extends MatchingTask { | public class DependSet extends MatchingTask { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private Vector sourceFileSets = new Vector(); | private Vector sourceFileSets = new Vector(); | ||||
| private Vector sourceFileLists = new Vector(); | private Vector sourceFileLists = new Vector(); | ||||
| private Vector targetFileSets = new Vector(); | private Vector targetFileSets = new Vector(); | ||||
| @@ -138,7 +139,7 @@ public class DependSet extends MatchingTask { | |||||
| We have to munge the time to allow for the filesystem time | We have to munge the time to allow for the filesystem time | ||||
| granularity. | granularity. | ||||
| */ | */ | ||||
| now += FileUtils.getFileUtils().getFileTimestampGranularity(); | |||||
| now += FILE_UTILS.getFileTimestampGranularity(); | |||||
| // | // | ||||
| // Grab all the target files specified via filesets | // Grab all the target files specified via filesets | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2001-2004 The Apache Software Foundation | |||||
| * Copyright 2001-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -32,10 +32,11 @@ import org.apache.tools.zip.ZipOutputStream; | |||||
| * @ant.task category="packaging" | * @ant.task category="packaging" | ||||
| */ | */ | ||||
| public class Ear extends Jar { | public class Ear extends Jar { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private File deploymentDescriptor; | private File deploymentDescriptor; | ||||
| private boolean descriptorAdded; | private boolean descriptorAdded; | ||||
| private static final FileUtils fu = FileUtils.newFileUtils(); | |||||
| /** | /** | ||||
| * Create an Ear task. | * Create an Ear task. | ||||
| @@ -108,7 +109,7 @@ public class Ear extends Jar { | |||||
| // <fileset> element. | // <fileset> element. | ||||
| if (vPath.equalsIgnoreCase("META-INF/application.xml")) { | if (vPath.equalsIgnoreCase("META-INF/application.xml")) { | ||||
| if (deploymentDescriptor == null | if (deploymentDescriptor == null | ||||
| || !fu.fileNameEquals(deploymentDescriptor, file) | |||||
| || !FILE_UTILS.fileNameEquals(deploymentDescriptor, file) | |||||
| || descriptorAdded) { | || descriptorAdded) { | ||||
| log("Warning: selected " + archiveType | log("Warning: selected " + archiveType | ||||
| + " files include a META-INF/application.xml which will" | + " files include a META-INF/application.xml which will" | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -39,6 +39,8 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| */ | */ | ||||
| public class ExecTask extends Task { | public class ExecTask extends Task { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private String os; | private String os; | ||||
| private File dir; | private File dir; | ||||
| @@ -392,10 +394,9 @@ public class ExecTask extends Task { | |||||
| return executableFile.getAbsolutePath(); | return executableFile.getAbsolutePath(); | ||||
| } | } | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| // now try to resolve against the dir if given | // now try to resolve against the dir if given | ||||
| if (dir != null) { | if (dir != null) { | ||||
| executableFile = fileUtils.resolveFile(dir, exec); | |||||
| executableFile = FILE_UTILS.resolveFile(dir, exec); | |||||
| if (executableFile.exists()) { | if (executableFile.exists()) { | ||||
| return executableFile.getAbsolutePath(); | return executableFile.getAbsolutePath(); | ||||
| } | } | ||||
| @@ -430,7 +431,7 @@ public class ExecTask extends Task { | |||||
| if (p != null) { | if (p != null) { | ||||
| String[] dirs = p.list(); | String[] dirs = p.list(); | ||||
| for (int i = 0; i < dirs.length; i++) { | for (int i = 0; i < dirs.length; i++) { | ||||
| executableFile = fileUtils.resolveFile(new File(dirs[i]), | |||||
| executableFile = FILE_UTILS.resolveFile(new File(dirs[i]), | |||||
| exec); | exec); | ||||
| if (executableFile.exists()) { | if (executableFile.exists()) { | ||||
| return executableFile.getAbsolutePath(); | return executableFile.getAbsolutePath(); | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -49,6 +49,8 @@ public class Execute { | |||||
| /** Invalid exit code. **/ | /** Invalid exit code. **/ | ||||
| public static final int INVALID = Integer.MAX_VALUE; | public static final int INVALID = Integer.MAX_VALUE; | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private String[] cmdl = null; | private String[] cmdl = null; | ||||
| private String[] env = null; | private String[] env = null; | ||||
| private int exitValue = INVALID; | private int exitValue = INVALID; | ||||
| @@ -1152,7 +1154,7 @@ public class Execute { | |||||
| */ | */ | ||||
| private File createCommandFile(String[] cmd, String[] env) | private File createCommandFile(String[] cmd, String[] env) | ||||
| throws IOException { | throws IOException { | ||||
| File script = FileUtils.newFileUtils().createTempFile("ANT", ".COM", null); | |||||
| File script = FILE_UTILS.createTempFile("ANT", ".COM", null); | |||||
| //TODO: bind the longevity of the file to the exe | //TODO: bind the longevity of the file to the exe | ||||
| script.deleteOnExit(); | script.deleteOnExit(); | ||||
| PrintWriter out = null; | PrintWriter out = null; | ||||
| @@ -63,6 +63,8 @@ public class Expand extends Task { | |||||
| private String encoding = "UTF8"; | private String encoding = "UTF8"; | ||||
| /** Error message when more that one mapper is defined */ | /** Error message when more that one mapper is defined */ | ||||
| public static final String ERROR_MULTIPLE_MAPPERS = "Cannot define more than one mapper"; | public static final String ERROR_MULTIPLE_MAPPERS = "Cannot define more than one mapper"; | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * Do the work. | * Do the work. | ||||
| @@ -88,14 +90,12 @@ public class Expand extends Task { | |||||
| throw new BuildException("Dest must be a directory.", getLocation()); | throw new BuildException("Dest must be a directory.", getLocation()); | ||||
| } | } | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| if (source != null) { | if (source != null) { | ||||
| if (source.isDirectory()) { | if (source.isDirectory()) { | ||||
| throw new BuildException("Src must not be a directory." | throw new BuildException("Src must not be a directory." | ||||
| + " Use nested filesets instead.", getLocation()); | + " Use nested filesets instead.", getLocation()); | ||||
| } else { | } else { | ||||
| expandFile(fileUtils, source, dest); | |||||
| expandFile(FILE_UTILS, source, dest); | |||||
| } | } | ||||
| } | } | ||||
| if (filesets.size() > 0) { | if (filesets.size() > 0) { | ||||
| @@ -107,7 +107,7 @@ public class Expand extends Task { | |||||
| String[] files = ds.getIncludedFiles(); | String[] files = ds.getIncludedFiles(); | ||||
| for (int i = 0; i < files.length; ++i) { | for (int i = 0; i < files.length; ++i) { | ||||
| File file = new File(fromDir, files[i]); | File file = new File(fromDir, files[i]); | ||||
| expandFile(fileUtils, file, dest); | |||||
| expandFile(FILE_UTILS, file, dest); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -106,6 +106,8 @@ public class FixCRLF extends MatchingTask { | |||||
| private static final char CTRLZ = '\u001A'; | private static final char CTRLZ = '\u001A'; | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private int tablength = 8; | private int tablength = 8; | ||||
| private String spaces = " "; | private String spaces = " "; | ||||
| private StringBuffer linebuf = new StringBuffer(1024); | private StringBuffer linebuf = new StringBuffer(1024); | ||||
| @@ -120,8 +122,6 @@ public class FixCRLF extends MatchingTask { | |||||
| private File srcDir; | private File srcDir; | ||||
| private File destDir = null; | private File destDir = null; | ||||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| /** | /** | ||||
| * Encoding to assume for the files | * Encoding to assume for the files | ||||
| */ | */ | ||||
| @@ -373,7 +373,7 @@ public class FixCRLF extends MatchingTask { | |||||
| try { | try { | ||||
| // Set up the output Writer | // Set up the output Writer | ||||
| try { | try { | ||||
| tmpFile = fileUtils.createTempFile("fixcrlf", "", null); | |||||
| tmpFile = FILE_UTILS.createTempFile("fixcrlf", "", null); | |||||
| tmpFile.deleteOnExit(); | tmpFile.deleteOnExit(); | ||||
| Writer writer = (encoding == null) ? new FileWriter(tmpFile) | Writer writer = (encoding == null) ? new FileWriter(tmpFile) | ||||
| : new OutputStreamWriter(new FileOutputStream(tmpFile), | : new OutputStreamWriter(new FileOutputStream(tmpFile), | ||||
| @@ -527,7 +527,7 @@ public class FixCRLF extends MatchingTask { | |||||
| if (destFile.exists()) { | if (destFile.exists()) { | ||||
| // Compare the destination with the temp file | // Compare the destination with the temp file | ||||
| log("destFile exists", Project.MSG_DEBUG); | log("destFile exists", Project.MSG_DEBUG); | ||||
| if (!fileUtils.contentEquals(destFile, tmpFile)) { | |||||
| if (!FILE_UTILS.contentEquals(destFile, tmpFile)) { | |||||
| log(destFile + " is being written", Project.MSG_DEBUG); | log(destFile + " is being written", Project.MSG_DEBUG); | ||||
| } else { | } else { | ||||
| log(destFile + " is not written, as the contents " | log(destFile + " is not written, as the contents " | ||||
| @@ -537,7 +537,7 @@ public class FixCRLF extends MatchingTask { | |||||
| } | } | ||||
| if (destIsWrong) { | if (destIsWrong) { | ||||
| fileUtils.rename(tmpFile, destFile); | |||||
| FILE_UTILS.rename(tmpFile, destFile); | |||||
| tmpFile = null; | tmpFile = null; | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -43,6 +43,9 @@ import java.util.Date; | |||||
| * @ant.task category="network" | * @ant.task category="network" | ||||
| */ | */ | ||||
| public class Get extends Task { | public class Get extends Task { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private URL source; // required | private URL source; // required | ||||
| private File dest; // required | private File dest; // required | ||||
| private boolean verbose = false; | private boolean verbose = false; | ||||
| @@ -243,8 +246,7 @@ public class Get extends Task { | |||||
| : ""), logLevel); | : ""), logLevel); | ||||
| } | } | ||||
| if (remoteTimestamp != 0) { | if (remoteTimestamp != 0) { | ||||
| FileUtils.newFileUtils() | |||||
| .setFileLastModified(dest, remoteTimestamp); | |||||
| FILE_UTILS.setFileLastModified(dest, remoteTimestamp); | |||||
| } | } | ||||
| } | } | ||||
| @@ -54,7 +54,7 @@ import java.util.Vector; | |||||
| public class ImportTask extends Task { | public class ImportTask extends Task { | ||||
| private String file; | private String file; | ||||
| private boolean optional; | private boolean optional; | ||||
| private static final FileUtils FILE_UTILS = FileUtils.newFileUtils(); | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * sets the optional attribute | * sets the optional attribute | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -344,6 +344,8 @@ public class Javadoc extends Task { | |||||
| } | } | ||||
| } | } | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** The command line built to execute Javadoc. */ | /** The command line built to execute Javadoc. */ | ||||
| private Commandline cmd = new Commandline(); | private Commandline cmd = new Commandline(); | ||||
| @@ -427,7 +429,6 @@ public class Javadoc extends Task { | |||||
| private Html footer = null; | private Html footer = null; | ||||
| private Html bottom = null; | private Html bottom = null; | ||||
| private boolean useExternalFile = false; | private boolean useExternalFile = false; | ||||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| private String source = null; | private String source = null; | ||||
| private boolean linksource = false; | private boolean linksource = false; | ||||
| private boolean breakiterator = false; | private boolean breakiterator = false; | ||||
| @@ -1709,7 +1710,7 @@ public class Javadoc extends Task { | |||||
| if (packageListFile.exists()) { | if (packageListFile.exists()) { | ||||
| try { | try { | ||||
| String packageListURL = | String packageListURL = | ||||
| fileUtils.getFileURL(packageListLocation) | |||||
| FILE_UTILS.getFileURL(packageListLocation) | |||||
| .toExternalForm(); | .toExternalForm(); | ||||
| toExecute.createArgument() | toExecute.createArgument() | ||||
| .setValue("-linkoffline"); | .setValue("-linkoffline"); | ||||
| @@ -1858,7 +1859,7 @@ public class Javadoc extends Task { | |||||
| */ | */ | ||||
| if (useExternalFile) { | if (useExternalFile) { | ||||
| if (tmpList == null) { | if (tmpList == null) { | ||||
| tmpList = fileUtils.createTempFile("javadoc", "", null); | |||||
| tmpList = FILE_UTILS.createTempFile("javadoc", "", null); | |||||
| tmpList.deleteOnExit(); | tmpList.deleteOnExit(); | ||||
| toExecute.createArgument() | toExecute.createArgument() | ||||
| .setValue("@" + tmpList.getAbsolutePath()); | .setValue("@" + tmpList.getAbsolutePath()); | ||||
| @@ -21,7 +21,6 @@ import java.io.File; | |||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
| import java.util.Arrays; | |||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import java.util.HashSet; | import java.util.HashSet; | ||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| @@ -30,7 +29,6 @@ import org.apache.tools.ant.Task; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.dispatch.Dispatchable; | |||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.types.EnumeratedAttribute; | import org.apache.tools.ant.types.EnumeratedAttribute; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| @@ -45,6 +43,7 @@ public class Length extends Task { | |||||
| private static final String ALL = "all"; | private static final String ALL = "all"; | ||||
| private static final String EACH = "each"; | private static final String EACH = "each"; | ||||
| private static final String STRING = "string"; | private static final String STRING = "string"; | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | ||||
| private String property; | private String property; | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -32,6 +32,8 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| */ | */ | ||||
| public class Rename extends Task { | public class Rename extends Task { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private File src; | private File src; | ||||
| private File dest; | private File dest; | ||||
| private boolean replace = true; | private boolean replace = true; | ||||
| @@ -83,7 +85,7 @@ public class Rename extends Task { | |||||
| } | } | ||||
| try { | try { | ||||
| FileUtils.newFileUtils().rename(src, dest); | |||||
| FILE_UTILS.rename(src, dest); | |||||
| } catch (IOException e) { | } catch (IOException e) { | ||||
| throw new BuildException("Unable to rename " + src + " to " | throw new BuildException("Unable to rename " + src + " to " | ||||
| + dest, e, getLocation()); | + dest, e, getLocation()); | ||||
| @@ -52,6 +52,8 @@ import org.apache.tools.ant.util.StringUtils; | |||||
| */ | */ | ||||
| public class Replace extends MatchingTask { | public class Replace extends MatchingTask { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private File src = null; | private File src = null; | ||||
| private NestedString token = null; | private NestedString token = null; | ||||
| private NestedString value = new NestedString(); | private NestedString value = new NestedString(); | ||||
| @@ -70,8 +72,6 @@ public class Replace extends MatchingTask { | |||||
| /** The encoding used to read and write files - if null, uses default */ | /** The encoding used to read and write files - if null, uses default */ | ||||
| private String encoding = null; | private String encoding = null; | ||||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| /** | /** | ||||
| * An inline string to use as the replacement text. | * An inline string to use as the replacement text. | ||||
| */ | */ | ||||
| @@ -587,7 +587,7 @@ public class Replace extends MatchingTask { | |||||
| try { | try { | ||||
| in = new FileInput(src); | in = new FileInput(src); | ||||
| temp = fileUtils.createTempFile("rep", ".tmp", | |||||
| temp = FILE_UTILS.createTempFile("rep", ".tmp", | |||||
| src.getParentFile()); | src.getParentFile()); | ||||
| out = new FileOutput(temp); | out = new FileOutput(temp); | ||||
| @@ -613,7 +613,7 @@ public class Replace extends MatchingTask { | |||||
| boolean changes = (replaceCount != repCountStart); | boolean changes = (replaceCount != repCountStart); | ||||
| if (changes) { | if (changes) { | ||||
| fileUtils.rename(temp, src); | |||||
| FILE_UTILS.rename(temp, src); | |||||
| temp = null; | temp = null; | ||||
| } | } | ||||
| } catch (IOException ioe) { | } catch (IOException ioe) { | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -104,8 +104,6 @@ public class Rmic extends MatchingTask { | |||||
| private ClassLoader loader = null; | private ClassLoader loader = null; | ||||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| private FacadeTaskHelper facade; | private FacadeTaskHelper facade; | ||||
| /** unable to verify message */ | /** unable to verify message */ | ||||
| public static final String ERROR_UNABLE_TO_VERIFY_CLASS = "Unable to verify class "; | public static final String ERROR_UNABLE_TO_VERIFY_CLASS = "Unable to verify class "; | ||||
| @@ -122,6 +120,8 @@ public class Rmic extends MatchingTask { | |||||
| /** base attribute not set message */ | /** base attribute not set message */ | ||||
| public static final String ERROR_BASE_NOT_SET = "base attribute must be set!"; | public static final String ERROR_BASE_NOT_SET = "base attribute must be set!"; | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * Constructor for Rmic. | * Constructor for Rmic. | ||||
| */ | */ | ||||
| @@ -607,11 +607,11 @@ public class Rmic extends MatchingTask { | |||||
| File newFile = new File(sourceBaseFile, sourceFileName); | File newFile = new File(sourceBaseFile, sourceFileName); | ||||
| try { | try { | ||||
| if (filtering) { | if (filtering) { | ||||
| fileUtils.copyFile(oldFile, newFile, | |||||
| FILE_UTILS.copyFile(oldFile, newFile, | |||||
| new FilterSetCollection(getProject() | new FilterSetCollection(getProject() | ||||
| .getGlobalFilterSet())); | .getGlobalFilterSet())); | ||||
| } else { | } else { | ||||
| fileUtils.copyFile(oldFile, newFile); | |||||
| FILE_UTILS.copyFile(oldFile, newFile); | |||||
| } | } | ||||
| oldFile.delete(); | oldFile.delete(); | ||||
| } catch (IOException ioe) { | } catch (IOException ioe) { | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -40,6 +40,8 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| */ | */ | ||||
| public class SignJar extends Task { | public class SignJar extends Task { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * The name of the jar file. | * The name of the jar file. | ||||
| */ | */ | ||||
| @@ -351,7 +353,7 @@ public class SignJar extends Task { | |||||
| if (jarFile.equals(signedjarFile)) { | if (jarFile.equals(signedjarFile)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (FileUtils.newFileUtils().isUpToDate(jarFile, signedjarFile)) { | |||||
| if (FILE_UTILS.isUpToDate(jarFile, signedjarFile)) { | |||||
| return true; | return true; | ||||
| } | } | ||||
| } else { | } else { | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -40,6 +40,8 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| public class TempFile extends Task { | public class TempFile extends Task { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * Name of property to set. | * Name of property to set. | ||||
| */ | */ | ||||
| @@ -115,8 +117,7 @@ public class TempFile extends Task { | |||||
| if (destDir == null) { | if (destDir == null) { | ||||
| destDir = getProject().resolveFile("."); | destDir = getProject().resolveFile("."); | ||||
| } | } | ||||
| FileUtils utils = FileUtils.newFileUtils(); | |||||
| File tfile = utils.createTempFile(prefix, suffix, destDir); | |||||
| File tfile = FILE_UTILS.createTempFile(prefix, suffix, destDir); | |||||
| getProject().setNewProperty(property, tfile.toString()); | getProject().setNewProperty(property, tfile.toString()); | ||||
| } | } | ||||
| } | } | ||||
| @@ -72,13 +72,13 @@ public class Touch extends Task { | |||||
| DateFormat.MEDIUM, Locale.US); | DateFormat.MEDIUM, Locale.US); | ||||
| } | } | ||||
| }; | }; | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private File file; | private File file; | ||||
| private long millis = -1; | private long millis = -1; | ||||
| private String dateTime; | private String dateTime; | ||||
| private Vector filesets = new Vector(); | private Vector filesets = new Vector(); | ||||
| private Vector filelists = new Vector(); | private Vector filelists = new Vector(); | ||||
| private FileUtils fileUtils; | |||||
| private boolean dateTimeConfigured; | private boolean dateTimeConfigured; | ||||
| private boolean mkdirs; | private boolean mkdirs; | ||||
| private boolean verbose = true; | private boolean verbose = true; | ||||
| @@ -89,7 +89,6 @@ public class Touch extends Task { | |||||
| * Construct a new <code>Touch</code> task. | * Construct a new <code>Touch</code> task. | ||||
| */ | */ | ||||
| public Touch() { | public Touch() { | ||||
| fileUtils = FileUtils.newFileUtils(); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -315,7 +314,7 @@ public class Touch extends Task { | |||||
| } | } | ||||
| private void touch(File fromDir, String filename, long defaultTimestamp) { | private void touch(File fromDir, String filename, long defaultTimestamp) { | ||||
| File f = fileUtils.resolveFile(fromDir, filename); | |||||
| File f = FILE_UTILS.resolveFile(fromDir, filename); | |||||
| if (fileNameMapper == null) { | if (fileNameMapper == null) { | ||||
| touch(f, defaultTimestamp); | touch(f, defaultTimestamp); | ||||
| } else { | } else { | ||||
| @@ -334,7 +333,7 @@ public class Touch extends Task { | |||||
| log("Creating " + file, | log("Creating " + file, | ||||
| ((verbose) ? Project.MSG_INFO : Project.MSG_VERBOSE)); | ((verbose) ? Project.MSG_INFO : Project.MSG_VERBOSE)); | ||||
| try { | try { | ||||
| fileUtils.createNewFile(file, mkdirs); | |||||
| FILE_UTILS.createNewFile(file, mkdirs); | |||||
| } catch (IOException ioe) { | } catch (IOException ioe) { | ||||
| throw new BuildException("Could not create " + file, ioe, | throw new BuildException("Could not create " + file, ioe, | ||||
| getLocation()); | getLocation()); | ||||
| @@ -344,7 +343,7 @@ public class Touch extends Task { | |||||
| throw new BuildException("Can not change modification date of " | throw new BuildException("Can not change modification date of " | ||||
| + "read-only file " + file); | + "read-only file " + file); | ||||
| } | } | ||||
| fileUtils.setFileLastModified(file, modTime); | |||||
| FILE_UTILS.setFileLastModified(file, modTime); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -55,7 +55,7 @@ public class War extends Jar { | |||||
| */ | */ | ||||
| private boolean descriptorAdded; | private boolean descriptorAdded; | ||||
| private static final FileUtils fu = FileUtils.newFileUtils(); | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| public War() { | public War() { | ||||
| super(); | super(); | ||||
| @@ -146,7 +146,7 @@ public class War extends Jar { | |||||
| // by the "webxml" attribute and in a <fileset> element. | // by the "webxml" attribute and in a <fileset> element. | ||||
| if (vPath.equalsIgnoreCase("WEB-INF/web.xml")) { | if (vPath.equalsIgnoreCase("WEB-INF/web.xml")) { | ||||
| if (deploymentDescriptor == null | if (deploymentDescriptor == null | ||||
| || !fu.fileNameEquals(deploymentDescriptor, file) | |||||
| || !FILE_UTILS.fileNameEquals(deploymentDescriptor, file) | |||||
| || descriptorAdded) { | || descriptorAdded) { | ||||
| log("Warning: selected " + archiveType | log("Warning: selected " + archiveType | ||||
| + " files include a WEB-INF/web.xml which will be ignored " | + " files include a WEB-INF/web.xml which will be ignored " | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -82,9 +82,6 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
| /** force output of target files even if they already exist */ | /** force output of target files even if they already exist */ | ||||
| private boolean force = false; | private boolean force = false; | ||||
| /** Utilities used for file operations */ | |||||
| private FileUtils fileUtils; | |||||
| /** XSL output properties to be used */ | /** XSL output properties to be used */ | ||||
| private Vector outputProperties = new Vector(); | private Vector outputProperties = new Vector(); | ||||
| @@ -103,6 +100,9 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
| private static final String XALAN_LIAISON_CLASS = | private static final String XALAN_LIAISON_CLASS = | ||||
| "org.apache.tools.ant.taskdefs.optional.XalanLiaison"; | "org.apache.tools.ant.taskdefs.optional.XalanLiaison"; | ||||
| /** Utilities used for file operations */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * Whether to style all files in the included directories as well. | * Whether to style all files in the included directories as well. | ||||
| * | * | ||||
| @@ -145,7 +145,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
| * Creates a new XSLTProcess Task. | * Creates a new XSLTProcess Task. | ||||
| */ | */ | ||||
| public XSLTProcess() { | public XSLTProcess() { | ||||
| fileUtils = FileUtils.newFileUtils(); | |||||
| } //-- XSLTProcess | } //-- XSLTProcess | ||||
| /** | /** | ||||
| @@ -221,7 +221,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
| File stylesheet = getProject().resolveFile(xslFile); | File stylesheet = getProject().resolveFile(xslFile); | ||||
| if (!stylesheet.exists()) { | if (!stylesheet.exists()) { | ||||
| stylesheet = fileUtils.resolveFile(baseDir, xslFile); | |||||
| stylesheet = FILE_UTILS.resolveFile(baseDir, xslFile); | |||||
| /* | /* | ||||
| * shouldn't throw out deprecation warnings before we know, | * shouldn't throw out deprecation warnings before we know, | ||||
| * the wrong version has been used. | * the wrong version has been used. | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2002-2004 The Apache Software Foundation | |||||
| * Copyright 2002-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -179,7 +179,6 @@ public class XmlProperty extends org.apache.tools.ant.Task { | |||||
| private boolean semanticAttributes = false; | private boolean semanticAttributes = false; | ||||
| private boolean includeSemanticAttribute = false; | private boolean includeSemanticAttribute = false; | ||||
| private File rootDirectory = null; | private File rootDirectory = null; | ||||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| private Hashtable addedAttributes = new Hashtable(); | private Hashtable addedAttributes = new Hashtable(); | ||||
| private XMLCatalog xmlCatalog = new XMLCatalog(); | private XMLCatalog xmlCatalog = new XMLCatalog(); | ||||
| @@ -192,6 +191,7 @@ public class XmlProperty extends org.apache.tools.ant.Task { | |||||
| private static final String[] ATTRIBUTES = new String[] { | private static final String[] ATTRIBUTES = new String[] { | ||||
| ID, REF_ID, LOCATION, VALUE, PATH, PATHID | ID, REF_ID, LOCATION, VALUE, PATH, PATHID | ||||
| }; | }; | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * Constructor. | * Constructor. | ||||
| @@ -686,7 +686,7 @@ public class XmlProperty extends org.apache.tools.ant.Task { | |||||
| if (rootDirectory == null) { | if (rootDirectory == null) { | ||||
| return getProject().resolveFile(fileName); | return getProject().resolveFile(fileName); | ||||
| } | } | ||||
| return fileUtils.resolveFile(rootDirectory, fileName); | |||||
| return FILE_UTILS.resolveFile(rootDirectory, fileName); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -84,7 +84,7 @@ public class Zip extends MatchingTask { | |||||
| protected boolean doubleFilePass = false; | protected boolean doubleFilePass = false; | ||||
| protected boolean skipWriting = false; | protected boolean skipWriting = false; | ||||
| private static FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * true when we are adding new files into the Zip file, as opposed | * true when we are adding new files into the Zip file, as opposed | ||||
| @@ -406,12 +406,12 @@ public class Zip extends MatchingTask { | |||||
| if (doUpdate) { | if (doUpdate) { | ||||
| renamedFile = | renamedFile = | ||||
| fileUtils.createTempFile("zip", ".tmp", | |||||
| FILE_UTILS.createTempFile("zip", ".tmp", | |||||
| zipFile.getParentFile()); | zipFile.getParentFile()); | ||||
| renamedFile.deleteOnExit(); | renamedFile.deleteOnExit(); | ||||
| try { | try { | ||||
| fileUtils.rename(zipFile, renamedFile); | |||||
| FILE_UTILS.rename(zipFile, renamedFile); | |||||
| } catch (SecurityException e) { | } catch (SecurityException e) { | ||||
| throw new BuildException( | throw new BuildException( | ||||
| "Not allowed to rename old file (" | "Not allowed to rename old file (" | ||||
| @@ -528,7 +528,7 @@ public class Zip extends MatchingTask { | |||||
| if (doUpdate && renamedFile != null) { | if (doUpdate && renamedFile != null) { | ||||
| try { | try { | ||||
| fileUtils.rename(renamedFile, zipFile); | |||||
| FILE_UTILS.rename(renamedFile, zipFile); | |||||
| } catch (IOException e) { | } catch (IOException e) { | ||||
| msg += " (and I couldn't rename the temporary file " | msg += " (and I couldn't rename the temporary file " | ||||
| + renamedFile.getName() + " back)"; | + renamedFile.getName() + " back)"; | ||||
| @@ -641,7 +641,7 @@ public class Zip extends MatchingTask { | |||||
| } | } | ||||
| if (!resources[i].isDirectory() && dealingWithFiles) { | if (!resources[i].isDirectory() && dealingWithFiles) { | ||||
| File f = fileUtils.resolveFile(base, | |||||
| File f = FILE_UTILS.resolveFile(base, | |||||
| resources[i].getName()); | resources[i].getName()); | ||||
| zipFile(f, zOut, prefix + name, fileMode); | zipFile(f, zOut, prefix + name, fileMode); | ||||
| } else if (!resources[i].isDirectory()) { | } else if (!resources[i].isDirectory()) { | ||||
| @@ -827,7 +827,7 @@ public class Zip extends MatchingTask { | |||||
| for (int j = 0; j < initialResources[i].length; j++) { | for (int j = 0; j < initialResources[i].length; j++) { | ||||
| File resourceAsFile = | File resourceAsFile = | ||||
| fileUtils.resolveFile(base, | |||||
| FILE_UTILS.resolveFile(base, | |||||
| initialResources[i][j].getName()); | initialResources[i][j].getName()); | ||||
| if (resourceAsFile.equals(zipFile)) { | if (resourceAsFile.equals(zipFile)) { | ||||
| throw new BuildException("A zip file cannot include " | throw new BuildException("A zip file cannot include " | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2001-2004 The Apache Software Foundation | |||||
| * Copyright 2001-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -41,6 +41,8 @@ import org.apache.tools.ant.taskdefs.condition.Os; | |||||
| */ | */ | ||||
| public abstract class DefaultCompilerAdapter implements CompilerAdapter { | public abstract class DefaultCompilerAdapter implements CompilerAdapter { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /* jdg - TODO - all these attributes are currently protected, but they | /* jdg - TODO - all these attributes are currently protected, but they | ||||
| * should probably be private in the near future. | * should probably be private in the near future. | ||||
| */ | */ | ||||
| @@ -69,7 +71,6 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { | |||||
| protected static final String lSep = System.getProperty("line.separator"); | protected static final String lSep = System.getProperty("line.separator"); | ||||
| protected Javac attributes; | protected Javac attributes; | ||||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| /** | /** | ||||
| * Set the Javac instance which contains the configured compilation | * Set the Javac instance which contains the configured compilation | ||||
| @@ -408,7 +409,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { | |||||
| && firstFileName >= 0) { | && firstFileName >= 0) { | ||||
| PrintWriter out = null; | PrintWriter out = null; | ||||
| try { | try { | ||||
| tmpFile = fileUtils.createTempFile( | |||||
| tmpFile = FILE_UTILS.createTempFile( | |||||
| "files", "", getJavac().getTempdir()); | "files", "", getJavac().getTempdir()); | ||||
| tmpFile.deleteOnExit(); | tmpFile.deleteOnExit(); | ||||
| out = new PrintWriter(new FileWriter(tmpFile)); | out = new PrintWriter(new FileWriter(tmpFile)); | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2002-2004 The Apache Software Foundation | |||||
| * Copyright 2002-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -32,14 +32,15 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| public class FilesMatch implements Condition { | public class FilesMatch implements Condition { | ||||
| /** | /** | ||||
| * files to compare | |||||
| * Helper that provides the file comparison method. | |||||
| */ | */ | ||||
| private File file1, file2; | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * Helper that provides the file comparison method. | |||||
| * files to compare | |||||
| */ | */ | ||||
| private FileUtils fu = FileUtils.newFileUtils(); | |||||
| private File file1, file2; | |||||
| /** | /** | ||||
| * Sets the File1 attribute | * Sets the File1 attribute | ||||
| @@ -78,7 +79,7 @@ public class FilesMatch implements Condition { | |||||
| //#now match the files | //#now match the files | ||||
| boolean matches = false; | boolean matches = false; | ||||
| try { | try { | ||||
| matches = fu.contentEquals(file1, file2); | |||||
| matches = FILE_UTILS.contentEquals(file1, file2); | |||||
| } catch (IOException ioe) { | } catch (IOException ioe) { | ||||
| throw new BuildException("when comparing files: " | throw new BuildException("when comparing files: " | ||||
| + ioe.getMessage(), ioe); | + ioe.getMessage(), ioe); | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2004 The Apache Software Foundation | |||||
| * Copyright 2004-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -25,7 +25,9 @@ import org.apache.tools.ant.types.selectors.AbstractSelectorContainer; | |||||
| * This is a condition that checks to see if a file passes an embedded selector. | * This is a condition that checks to see if a file passes an embedded selector. | ||||
| */ | */ | ||||
| public class IsFileSelected extends AbstractSelectorContainer implements Condition { | public class IsFileSelected extends AbstractSelectorContainer implements Condition { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.newFileUtils(); | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private File file; | private File file; | ||||
| private File baseDir; | private File baseDir; | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2002-2004 The Apache Software Foundation | |||||
| * Copyright 2002-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -65,6 +65,12 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| * @ant.task name="cvstagdiff" | * @ant.task name="cvstagdiff" | ||||
| */ | */ | ||||
| public class CvsTagDiff extends AbstractCvsTask { | public class CvsTagDiff extends AbstractCvsTask { | ||||
| /** | |||||
| * Used to create the temp file for cvs log | |||||
| */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * Token to identify the word file in the rdiff log | * Token to identify the word file in the rdiff log | ||||
| */ | */ | ||||
| @@ -122,11 +128,6 @@ public class CvsTagDiff extends AbstractCvsTask { | |||||
| */ | */ | ||||
| private File mydestfile; | private File mydestfile; | ||||
| /** | |||||
| * Used to create the temp file for cvs log | |||||
| */ | |||||
| private FileUtils myfileUtils = FileUtils.newFileUtils(); | |||||
| /** | /** | ||||
| * The package/module to analyze. | * The package/module to analyze. | ||||
| * @param p the name of the package to analyse | * @param p the name of the package to analyse | ||||
| @@ -215,7 +216,7 @@ public class CvsTagDiff extends AbstractCvsTask { | |||||
| setCommand(""); | setCommand(""); | ||||
| File tmpFile = null; | File tmpFile = null; | ||||
| try { | try { | ||||
| tmpFile = myfileUtils.createTempFile("cvstagdiff", ".log", null); | |||||
| tmpFile = FILE_UTILS.createTempFile("cvstagdiff", ".log", null); | |||||
| tmpFile.deleteOnExit(); | tmpFile.deleteOnExit(); | ||||
| setOutput(tmpFile); | setOutput(tmpFile); | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -84,12 +84,11 @@ public class ANTLR extends Task { | |||||
| /** Instance of a utility class to use for file operations. */ | /** Instance of a utility class to use for file operations. */ | ||||
| private FileUtils fileUtils; | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| public ANTLR() { | public ANTLR() { | ||||
| commandline.setVm(JavaEnvUtils.getJreExecutable("java")); | commandline.setVm(JavaEnvUtils.getJreExecutable("java")); | ||||
| commandline.setClassname("antlr.Tool"); | commandline.setClassname("antlr.Tool"); | ||||
| fileUtils = FileUtils.newFileUtils(); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -120,7 +119,7 @@ public class ANTLR extends Task { | |||||
| } else { | } else { | ||||
| sg = superGrammar; | sg = superGrammar; | ||||
| } | } | ||||
| setGlib(fileUtils.resolveFile(getProject().getBaseDir(), sg)); | |||||
| setGlib(FILE_UTILS.resolveFile(getProject().getBaseDir(), sg)); | |||||
| } | } | ||||
| /** | /** | ||||
| * Sets an optional super grammar file | * Sets an optional super grammar file | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -53,7 +53,7 @@ public class Cab extends MatchingTask { | |||||
| protected String archiveType = "cab"; | protected String archiveType = "cab"; | ||||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * The name/location of where to create the .cab file. | * The name/location of where to create the .cab file. | ||||
| @@ -138,7 +138,7 @@ public class Cab extends MatchingTask { | |||||
| boolean upToDate = true; | boolean upToDate = true; | ||||
| for (int i = 0; i < files.size() && upToDate; i++) { | for (int i = 0; i < files.size() && upToDate; i++) { | ||||
| String file = files.elementAt(i).toString(); | String file = files.elementAt(i).toString(); | ||||
| if (fileUtils.resolveFile(baseDir, file).lastModified() | |||||
| if (FILE_UTILS.resolveFile(baseDir, file).lastModified() | |||||
| > cabFile.lastModified()) { | > cabFile.lastModified()) { | ||||
| upToDate = false; | upToDate = false; | ||||
| } | } | ||||
| @@ -152,7 +152,7 @@ public class Cab extends MatchingTask { | |||||
| */ | */ | ||||
| protected File createListFile(Vector files) | protected File createListFile(Vector files) | ||||
| throws IOException { | throws IOException { | ||||
| File listFile = fileUtils.createTempFile("ant", "", null); | |||||
| File listFile = FILE_UTILS.createTempFile("ant", "", null); | |||||
| listFile.deleteOnExit(); | listFile.deleteOnExit(); | ||||
| PrintWriter writer = new PrintWriter(new FileOutputStream(listFile)); | PrintWriter writer = new PrintWriter(new FileOutputStream(listFile)); | ||||
| @@ -283,7 +283,7 @@ public class Cab extends MatchingTask { | |||||
| exec.setDir(baseDir); | exec.setDir(baseDir); | ||||
| if (!doVerbose) { | if (!doVerbose) { | ||||
| outFile = fileUtils.createTempFile("ant", "", null); | |||||
| outFile = FILE_UTILS.createTempFile("ant", "", null); | |||||
| outFile.deleteOnExit(); | outFile.deleteOnExit(); | ||||
| exec.setOutput(outFile); | exec.setOutput(outFile); | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2001-2004 The Apache Software Foundation | |||||
| * Copyright 2001-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -120,7 +120,7 @@ public class ReplaceRegExp extends Task { | |||||
| private RegularExpression regex; | private RegularExpression regex; | ||||
| private Substitution subs; | private Substitution subs; | ||||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * Encoding to assume for the files | * Encoding to assume for the files | ||||
| @@ -321,7 +321,7 @@ public class ReplaceRegExp extends Task { | |||||
| */ | */ | ||||
| protected void doReplace(File f, int options) | protected void doReplace(File f, int options) | ||||
| throws IOException { | throws IOException { | ||||
| File temp = fileUtils.createTempFile("replace", ".txt", null); | |||||
| File temp = FILE_UTILS.createTempFile("replace", ".txt", null); | |||||
| temp.deleteOnExit(); | temp.deleteOnExit(); | ||||
| Reader r = null; | Reader r = null; | ||||
| @@ -445,7 +445,7 @@ public class ReplaceRegExp extends Task { | |||||
| if (changes) { | if (changes) { | ||||
| log("File has changed; saving the updated file", Project.MSG_VERBOSE); | log("File has changed; saving the updated file", Project.MSG_VERBOSE); | ||||
| try { | try { | ||||
| fileUtils.rename(temp, f); | |||||
| FILE_UTILS.rename(temp, f); | |||||
| temp = null; | temp = null; | ||||
| } catch (IOException e) { | } catch (IOException e) { | ||||
| throw new BuildException("Couldn't rename temporary file " | throw new BuildException("Couldn't rename temporary file " | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -57,7 +57,7 @@ public class XMLValidateTask extends Task { | |||||
| /** | /** | ||||
| * helper for path -> URI and URI -> path conversions. | * helper for path -> URI and URI -> path conversions. | ||||
| */ | */ | ||||
| private static final FileUtils FILE_UTILS = FileUtils.newFileUtils(); | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| protected static final String INIT_FAILED_MSG = | protected static final String INIT_FAILED_MSG = | ||||
| "Could not start xml validation: "; | "Could not start xml validation: "; | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2003-2004 The Apache Software Foundation | |||||
| * Copyright 2003-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -58,6 +58,8 @@ import java.io.File; | |||||
| */ | */ | ||||
| public class Ildasm extends Task { | public class Ildasm extends Task { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * source file (mandatory) | * source file (mandatory) | ||||
| */ | */ | ||||
| @@ -328,7 +330,7 @@ public class Ildasm extends Task { | |||||
| } | } | ||||
| long sourceTime = sourceFile.lastModified(); | long sourceTime = sourceFile.lastModified(); | ||||
| long destTime = destFile.lastModified(); | long destTime = destFile.lastModified(); | ||||
| if (sourceTime > (destTime + FileUtils.newFileUtils().getFileTimestampGranularity())) { | |||||
| if (sourceTime > (destTime + FILE_UTILS.getFileTimestampGranularity())) { | |||||
| log("Source file is newer than the dest file: a rebuild is required", | log("Source file is newer than the dest file: a rebuild is required", | ||||
| Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
| return true; | return true; | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -44,6 +44,7 @@ import java.io.File; | |||||
| */ | */ | ||||
| public class ImportTypelib extends Task { | public class ImportTypelib extends Task { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * input file; precedes options | * input file; precedes options | ||||
| @@ -166,7 +167,7 @@ public class ImportTypelib extends Task { | |||||
| } | } | ||||
| long sourceTime = srcFile.lastModified(); | long sourceTime = srcFile.lastModified(); | ||||
| long destTime = destFile.lastModified(); | long destTime = destFile.lastModified(); | ||||
| if (sourceTime > (destTime + FileUtils.newFileUtils().getFileTimestampGranularity())) { | |||||
| if (sourceTime > (destTime + FILE_UTILS.getFileTimestampGranularity())) { | |||||
| log("Source file is newer than the dest file: a rebuild is required", | log("Source file is newer than the dest file: a rebuild is required", | ||||
| Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
| return true; | return true; | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -31,7 +31,6 @@ import java.io.IOException; | |||||
| import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
| import java.io.PrintWriter; | import java.io.PrintWriter; | ||||
| import java.io.BufferedOutputStream; | import java.io.BufferedOutputStream; | ||||
| import java.io.FileNotFoundException; | |||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| @@ -56,6 +55,8 @@ import org.apache.tools.ant.types.Commandline; | |||||
| public class NetCommand { | public class NetCommand { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * owner project | * owner project | ||||
| */ | */ | ||||
| @@ -326,9 +327,8 @@ public class NetCommand { | |||||
| //and set @tmpfile as the command -then we remember to delete the tempfile | //and set @tmpfile as the command -then we remember to delete the tempfile | ||||
| //afterwards | //afterwards | ||||
| FileOutputStream fos = null; | FileOutputStream fos = null; | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| temporaryCommandFile = fileUtils.createTempFile("cmd", ".txt", null); | |||||
| temporaryCommandFile = FILE_UTILS.createTempFile("cmd", ".txt", null); | |||||
| owner.log("Using response file" + temporaryCommandFile, Project.MSG_VERBOSE); | owner.log("Using response file" + temporaryCommandFile, Project.MSG_VERBOSE); | ||||
| try { | try { | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2002-2004 The Apache Software Foundation | |||||
| * Copyright 2002-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -19,7 +19,6 @@ package org.apache.tools.ant.taskdefs.optional.dotnet; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import java.net.URL; | |||||
| import java.net.MalformedURLException; | import java.net.MalformedURLException; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| @@ -52,6 +51,11 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| public class WsdlToDotnet extends Task { | public class WsdlToDotnet extends Task { | ||||
| /** | |||||
| * used for timestamp checking | |||||
| */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * name of output file (required) | * name of output file (required) | ||||
| */ | */ | ||||
| @@ -124,11 +128,6 @@ public class WsdlToDotnet extends Task { | |||||
| */ | */ | ||||
| public static final String ERROR_NO_DEST_FILE = "destination file must be specified"; | public static final String ERROR_NO_DEST_FILE = "destination file must be specified"; | ||||
| /** | |||||
| * used for timestamp checking | |||||
| */ | |||||
| private FileUtils fileutils = FileUtils.newFileUtils(); | |||||
| /** | /** | ||||
| * Name of the file to generate. Required | * Name of the file to generate. Required | ||||
| * @param destFile filename | * @param destFile filename | ||||
| @@ -346,7 +345,7 @@ public class WsdlToDotnet extends Task { | |||||
| if (destLastModified == -1) { | if (destLastModified == -1) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| return !fileutils.isUpToDate(schema.getTimestamp(), destLastModified); | |||||
| return !FILE_UTILS.isUpToDate(schema.getTimestamp(), destLastModified); | |||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -86,6 +86,9 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool { | |||||
| protected static final String COMPILER_EJB11 = "weblogic.ejbc"; | protected static final String COMPILER_EJB11 = "weblogic.ejbc"; | ||||
| protected static final String COMPILER_EJB20 = "weblogic.ejbc20"; | protected static final String COMPILER_EJB20 = "weblogic.ejbc20"; | ||||
| /** File utilities instance for copying jars */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** Instance variable that stores the suffix for the weblogic jarfile. */ | /** Instance variable that stores the suffix for the weblogic jarfile. */ | ||||
| private String jarSuffix = ".jar"; | private String jarSuffix = ".jar"; | ||||
| @@ -136,9 +139,6 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool { | |||||
| */ | */ | ||||
| private Integer jvmDebugLevel = null; | private Integer jvmDebugLevel = null; | ||||
| /** File utilities instance for copying jars */ | |||||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| private File outputDir; | private File outputDir; | ||||
| /** | /** | ||||
| @@ -498,7 +498,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool { | |||||
| if (noEJBC) { | if (noEJBC) { | ||||
| try { | try { | ||||
| fileUtils.copyFile(sourceJar, destJar); | |||||
| FILE_UTILS.copyFile(sourceJar, destJar); | |||||
| if (!keepgenerated) { | if (!keepgenerated) { | ||||
| sourceJar.delete(); | sourceJar.delete(); | ||||
| } | } | ||||
| @@ -840,7 +840,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool { | |||||
| } | } | ||||
| try { | try { | ||||
| fileUtils.rename(newWLJarFile, weblogicJarFile); | |||||
| FILE_UTILS.rename(newWLJarFile, weblogicJarFile); | |||||
| } catch (IOException renameException) { | } catch (IOException renameException) { | ||||
| log(renameException.getMessage(), Project.MSG_WARN); | log(renameException.getMessage(), Project.MSG_WARN); | ||||
| rebuild = true; | rebuild = true; | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2001-2004 The Apache Software Foundation | |||||
| * Copyright 2001-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -84,6 +84,8 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool { | |||||
| protected static final String WAS_CMP_MAP = "Map.mapxmi"; | protected static final String WAS_CMP_MAP = "Map.mapxmi"; | ||||
| protected static final String WAS_CMP_SCHEMA = "Schema.dbxmi"; | protected static final String WAS_CMP_SCHEMA = "Schema.dbxmi"; | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** Instance variable that stores the suffix for the websphere jarfile. */ | /** Instance variable that stores the suffix for the websphere jarfile. */ | ||||
| private String jarSuffix = ".jar"; | private String jarSuffix = ".jar"; | ||||
| @@ -840,8 +842,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool { | |||||
| } | } | ||||
| try { | try { | ||||
| FileUtils.newFileUtils().rename(newwasJarFile, | |||||
| websphereJarFile); | |||||
| FILE_UTILS.rename(newwasJarFile, websphereJarFile); | |||||
| } catch (IOException renameException) { | } catch (IOException renameException) { | ||||
| log(renameException.getMessage(), Project.MSG_WARN); | log(renameException.getMessage(), Project.MSG_WARN); | ||||
| rebuild = true; | rebuild = true; | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2001-2004 The Apache Software Foundation | |||||
| * Copyright 2001-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -145,7 +145,7 @@ public class Translate extends MatchingTask { | |||||
| * Used to resolve file names. | * Used to resolve file names. | ||||
| */ | */ | ||||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * Last Modified Timestamp of resource bundle file being used. | * Last Modified Timestamp of resource bundle file being used. | ||||
| @@ -499,7 +499,7 @@ public class Translate extends MatchingTask { | |||||
| String[] srcFiles = ds.getIncludedFiles(); | String[] srcFiles = ds.getIncludedFiles(); | ||||
| for (int j = 0; j < srcFiles.length; j++) { | for (int j = 0; j < srcFiles.length; j++) { | ||||
| try { | try { | ||||
| File dest = fileUtils.resolveFile(toDir, srcFiles[j]); | |||||
| File dest = FILE_UTILS.resolveFile(toDir, srcFiles[j]); | |||||
| //Make sure parent dirs exist, else, create them. | //Make sure parent dirs exist, else, create them. | ||||
| try { | try { | ||||
| File destDir = new File(dest.getParent()); | File destDir = new File(dest.getParent()); | ||||
| @@ -512,7 +512,7 @@ public class Translate extends MatchingTask { | |||||
| Project.MSG_DEBUG); | Project.MSG_DEBUG); | ||||
| } | } | ||||
| destLastModified = dest.lastModified(); | destLastModified = dest.lastModified(); | ||||
| File src = fileUtils.resolveFile(ds.getBasedir(), srcFiles[j]); | |||||
| File src = FILE_UTILS.resolveFile(ds.getBasedir(), srcFiles[j]); | |||||
| srcLastModified = src.lastModified(); | srcLastModified = src.lastModified(); | ||||
| //Check to see if dest file has to be recreated | //Check to see if dest file has to be recreated | ||||
| boolean needsWork = forceOverwrite | boolean needsWork = forceOverwrite | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -151,6 +151,8 @@ public class JUnitTask extends Task { | |||||
| private static final int STRING_BUFFER_SIZE = 128; | private static final int STRING_BUFFER_SIZE = 128; | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * If true, force ant to re-classload all classes for each JUnit TestCase | * If true, force ant to re-classload all classes for each JUnit TestCase | ||||
| * | * | ||||
| @@ -925,7 +927,7 @@ public class JUnitTask extends Task { | |||||
| */ | */ | ||||
| private File createTempPropertiesFile(String prefix) { | private File createTempPropertiesFile(String prefix) { | ||||
| File propsFile = | File propsFile = | ||||
| FileUtils.newFileUtils().createTempFile(prefix, ".properties", | |||||
| FILE_UTILS.createTempFile(prefix, ".properties", | |||||
| tmpDir != null ? tmpDir : getProject().getBaseDir()); | tmpDir != null ? tmpDir : getProject().getBaseDir()); | ||||
| propsFile.deleteOnExit(); | propsFile.deleteOnExit(); | ||||
| return propsFile; | return propsFile; | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2001-2004 The Apache Software Foundation | |||||
| * Copyright 2001-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -46,6 +46,8 @@ import org.apache.tools.ant.util.JavaEnvUtils; | |||||
| */ | */ | ||||
| public abstract class AbstractMetamataTask extends Task { | public abstract class AbstractMetamataTask extends Task { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * The user classpath to be provided. It matches the -classpath of the | * The user classpath to be provided. It matches the -classpath of the | ||||
| * command line. The classpath must includes both the <tt>.class</tt> and the | * command line. The classpath must includes both the <tt>.class</tt> and the | ||||
| @@ -282,7 +284,7 @@ public abstract class AbstractMetamataTask extends Task { | |||||
| } | } | ||||
| protected final File createTmpFile() { | protected final File createTmpFile() { | ||||
| File tmpFile = FileUtils.newFileUtils() | |||||
| File tmpFile = FILE_UTILS | |||||
| .createTempFile("metamata", ".tmp", getProject().getBaseDir()); | .createTempFile("metamata", ".tmp", getProject().getBaseDir()); | ||||
| tmpFile.deleteOnExit(); | tmpFile.deleteOnExit(); | ||||
| return tmpFile; | return tmpFile; | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -84,6 +84,8 @@ public class FTP | |||||
| /** Default port for FTP */ | /** Default port for FTP */ | ||||
| public static final int DEFAULT_FTP_PORT = 21; | public static final int DEFAULT_FTP_PORT = 21; | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private String remotedir; | private String remotedir; | ||||
| private String server; | private String server; | ||||
| private String userid; | private String userid; | ||||
| @@ -107,7 +109,6 @@ public class FTP | |||||
| private boolean preserveLastModified = false; | private boolean preserveLastModified = false; | ||||
| private String chmod = null; | private String chmod = null; | ||||
| private String umask = null; | private String umask = null; | ||||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| protected static final String[] ACTION_STRS = { | protected static final String[] ACTION_STRS = { | ||||
| "sending", | "sending", | ||||
| @@ -1487,7 +1488,7 @@ public class FTP | |||||
| File tempFile = findFileName(ftp); | File tempFile = findFileName(ftp); | ||||
| try { | try { | ||||
| // create a local temporary file | // create a local temporary file | ||||
| fileUtils.createNewFile(tempFile); | |||||
| FILE_UTILS.createNewFile(tempFile); | |||||
| long localTimeStamp = tempFile.lastModified(); | long localTimeStamp = tempFile.lastModified(); | ||||
| BufferedInputStream instream = new BufferedInputStream(new FileInputStream(tempFile)); | BufferedInputStream instream = new BufferedInputStream(new FileInputStream(tempFile)); | ||||
| ftp.storeFile(tempFile.getName(), instream); | ftp.storeFile(tempFile.getName(), instream); | ||||
| @@ -1518,7 +1519,7 @@ public class FTP | |||||
| FTPFile [] theFiles = null; | FTPFile [] theFiles = null; | ||||
| final int maxIterations = 1000; | final int maxIterations = 1000; | ||||
| for (int counter = 1; counter < maxIterations; counter++) { | for (int counter = 1; counter < maxIterations; counter++) { | ||||
| File localFile = fileUtils.createTempFile("ant" + Integer.toString(counter), ".tmp", | |||||
| File localFile = FILE_UTILS.createTempFile("ant" + Integer.toString(counter), ".tmp", | |||||
| null); | null); | ||||
| String fileName = localFile.getName(); | String fileName = localFile.getName(); | ||||
| boolean found = false; | boolean found = false; | ||||
| @@ -1809,7 +1810,7 @@ public class FTP | |||||
| outstream = null; | outstream = null; | ||||
| FTPFile[] remote = ftp.listFiles(resolveFile(filename)); | FTPFile[] remote = ftp.listFiles(resolveFile(filename)); | ||||
| if (remote.length > 0) { | if (remote.length > 0) { | ||||
| fileUtils.setFileLastModified(file, | |||||
| FILE_UTILS.setFileLastModified(file, | |||||
| remote[0].getTimestamp() | remote[0].getTimestamp() | ||||
| .getTime().getTime()); | .getTime().getTime()); | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2003-2004 The Apache Software Foundation | |||||
| * Copyright 2003-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -30,7 +30,7 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| */ | */ | ||||
| public abstract class CovBase extends Task { | public abstract class CovBase extends Task { | ||||
| private File home; | private File home; | ||||
| private static FileUtils fu = FileUtils.newFileUtils(); | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private boolean isJProbe4 = false; | private boolean isJProbe4 = false; | ||||
| private static boolean isDos = Os.isFamily("dos"); | private static boolean isDos = Os.isFamily("dos"); | ||||
| @@ -48,11 +48,11 @@ public abstract class CovBase extends Task { | |||||
| protected File findCoverageJar() { | protected File findCoverageJar() { | ||||
| File loc = null; | File loc = null; | ||||
| if (isJProbe4) { | if (isJProbe4) { | ||||
| loc = fu.resolveFile(home, "lib/coverage.jar"); | |||||
| loc = FILE_UTILS.resolveFile(home, "lib/coverage.jar"); | |||||
| } else { | } else { | ||||
| loc = fu.resolveFile(home, "coverage/coverage.jar"); | |||||
| loc = FILE_UTILS.resolveFile(home, "coverage/coverage.jar"); | |||||
| if (!loc.canRead()) { | if (!loc.canRead()) { | ||||
| File newLoc = fu.resolveFile(home, "lib/coverage.jar"); | |||||
| File newLoc = FILE_UTILS.resolveFile(home, "lib/coverage.jar"); | |||||
| if (newLoc.canRead()) { | if (newLoc.canRead()) { | ||||
| isJProbe4 = true; | isJProbe4 = true; | ||||
| loc = newLoc; | loc = newLoc; | ||||
| @@ -70,11 +70,11 @@ public abstract class CovBase extends Task { | |||||
| File loc = null; | File loc = null; | ||||
| if (isJProbe4) { | if (isJProbe4) { | ||||
| loc = fu.resolveFile(home, "bin/" + relativePath); | |||||
| loc = FILE_UTILS.resolveFile(home, "bin/" + relativePath); | |||||
| } else { | } else { | ||||
| loc = fu.resolveFile(home, relativePath); | |||||
| loc = FILE_UTILS.resolveFile(home, relativePath); | |||||
| if (!loc.canRead()) { | if (!loc.canRead()) { | ||||
| File newLoc = fu.resolveFile(home, "bin/" + relativePath); | |||||
| File newLoc = FILE_UTILS.resolveFile(home, "bin/" + relativePath); | |||||
| if (newLoc.canRead()) { | if (newLoc.canRead()) { | ||||
| isJProbe4 = true; | isJProbe4 = true; | ||||
| loc = newLoc; | loc = newLoc; | ||||
| @@ -85,7 +85,7 @@ public abstract class CovBase extends Task { | |||||
| } | } | ||||
| protected File createTempFile(String prefix) { | protected File createTempFile(String prefix) { | ||||
| return fu.createTempFile(prefix, ".tmp", null); | |||||
| return FILE_UTILS.createTempFile(prefix, ".tmp", null); | |||||
| } | } | ||||
| protected String getParamFileArgument() { | protected String getParamFileArgument() { | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2002-2004 The Apache Software Foundation | |||||
| * Copyright 2002-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -118,6 +118,8 @@ public class Symlink extends Task { | |||||
| private boolean overwrite; | private boolean overwrite; | ||||
| private boolean failonerror; | private boolean failonerror; | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** Initialize the task. */ | /** Initialize the task. */ | ||||
| public void init() throws BuildException { | public void init() throws BuildException { | ||||
| @@ -163,10 +165,9 @@ public class Symlink extends Task { | |||||
| // handle the case where the link exists | // handle the case where the link exists | ||||
| // and points to a directory (bug 25181) | // and points to a directory (bug 25181) | ||||
| try { | try { | ||||
| FileUtils fu = FileUtils.newFileUtils(); | |||||
| File test = new File(link); | File test = new File(link); | ||||
| File testRes = new File(resource); | File testRes = new File(resource); | ||||
| if (!fu.isSymbolicLink(test.getParentFile(), | |||||
| if (!FILE_UTILS.isSymbolicLink(test.getParentFile(), | |||||
| test.getName())) { | test.getName())) { | ||||
| doLink(resource, link); | doLink(resource, link); | ||||
| } else { | } else { | ||||
| @@ -396,12 +397,12 @@ public class Symlink extends Task { | |||||
| // rename the resource, thus breaking the link | // rename the resource, thus breaking the link | ||||
| String parentStr = canfil.getParent(); | String parentStr = canfil.getParent(); | ||||
| File parentDir = new File(parentStr); | File parentDir = new File(parentStr); | ||||
| FileUtils fu = FileUtils.newFileUtils(); | |||||
| File temp = fu.createTempFile("symlink", ".tmp", parentDir); | |||||
| File temp = FILE_UTILS.createTempFile("symlink", ".tmp", parentDir); | |||||
| temp.deleteOnExit(); | temp.deleteOnExit(); | ||||
| try { | try { | ||||
| try { | try { | ||||
| fu.rename(canfil, temp); | |||||
| FILE_UTILS.rename(canfil, temp); | |||||
| } catch (IOException e) { | } catch (IOException e) { | ||||
| throw new IOException("Couldn't rename resource when " | throw new IOException("Couldn't rename resource when " | ||||
| + "attempting to delete " + linkfil); | + "attempting to delete " + linkfil); | ||||
| @@ -416,7 +417,7 @@ public class Symlink extends Task { | |||||
| } finally { | } finally { | ||||
| // return the resource to its original name. | // return the resource to its original name. | ||||
| try { | try { | ||||
| fu.rename(temp, canfil); | |||||
| FILE_UTILS.rename(temp, canfil); | |||||
| } catch (IOException e) { | } catch (IOException e) { | ||||
| throw new IOException("Couldn't return resource " + temp | throw new IOException("Couldn't return resource " + temp | ||||
| + " to its original name: " + canstr | + " to its original name: " + canstr | ||||
| @@ -626,7 +627,6 @@ public class Symlink extends Task { | |||||
| File parentNext, next; | File parentNext, next; | ||||
| String nameParentNext; | String nameParentNext; | ||||
| FileUtils fu = FileUtils.newFileUtils(); | |||||
| Vector removals = new Vector(); | Vector removals = new Vector(); | ||||
| while (enumLinks.hasMoreElements()) { | while (enumLinks.hasMoreElements()) { | ||||
| next = (File) enumLinks.nextElement(); | next = (File) enumLinks.nextElement(); | ||||
| @@ -634,7 +634,7 @@ public class Symlink extends Task { | |||||
| parentNext = new File(nameParentNext); | parentNext = new File(nameParentNext); | ||||
| try { | try { | ||||
| if (!fu.isSymbolicLink(parentNext, next.getName())) { | |||||
| if (!FILE_UTILS.isSymbolicLink(parentNext, next.getName())) { | |||||
| removals.addElement(next); | removals.addElement(next); | ||||
| } | } | ||||
| } catch (IOException ioe) { | } catch (IOException ioe) { | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2004 The Apache Software Foundation | |||||
| * Copyright 2004-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -35,7 +35,7 @@ public class Library implements EnabledLibraryElement { | |||||
| */ | */ | ||||
| private boolean enabled = true; | private boolean enabled = true; | ||||
| private static FileUtils FILE_UTILS = FileUtils.newFileUtils(); | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * turn policy on/off | * turn policy on/off | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2002-2004 The Apache Software Foundation | |||||
| * Copyright 2002-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -120,7 +120,7 @@ public class XMLCatalog extends DataType | |||||
| implements Cloneable, EntityResolver, URIResolver { | implements Cloneable, EntityResolver, URIResolver { | ||||
| /** helper for some File.toURL connversions */ | /** helper for some File.toURL connversions */ | ||||
| private static FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| //-- Fields ---------------------------------------------------------------- | //-- Fields ---------------------------------------------------------------- | ||||
| @@ -453,7 +453,7 @@ public class XMLCatalog extends DataType | |||||
| URL baseURL = null; | URL baseURL = null; | ||||
| try { | try { | ||||
| if (base == null) { | if (base == null) { | ||||
| baseURL = fileUtils.getFileURL(getProject().getBaseDir()); | |||||
| baseURL = FILE_UTILS.getFileURL(getProject().getBaseDir()); | |||||
| } else { | } else { | ||||
| baseURL = new URL(base); | baseURL = new URL(base); | ||||
| } | } | ||||
| @@ -649,7 +649,7 @@ public class XMLCatalog extends DataType | |||||
| baseURL = matchingEntry.getBase(); | baseURL = matchingEntry.getBase(); | ||||
| } else { | } else { | ||||
| try { | try { | ||||
| baseURL = fileUtils.getFileURL(getProject().getBaseDir()); | |||||
| baseURL = FILE_UTILS.getFileURL(getProject().getBaseDir()); | |||||
| } catch (MalformedURLException ex) { | } catch (MalformedURLException ex) { | ||||
| throw new BuildException("Project basedir cannot be converted to a URL"); | throw new BuildException("Project basedir cannot be converted to a URL"); | ||||
| } | } | ||||
| @@ -667,7 +667,7 @@ public class XMLCatalog extends DataType | |||||
| log("uri : '" | log("uri : '" | ||||
| + uri + "' matches a readable file", Project.MSG_DEBUG); | + uri + "' matches a readable file", Project.MSG_DEBUG); | ||||
| try { | try { | ||||
| url = fileUtils.getFileURL(testFile); | |||||
| url = FILE_UTILS.getFileURL(testFile); | |||||
| } catch (MalformedURLException ex1) { | } catch (MalformedURLException ex1) { | ||||
| throw new BuildException("could not find an URL for :" + testFile.getAbsolutePath()); | throw new BuildException("could not find an URL for :" + testFile.getAbsolutePath()); | ||||
| } | } | ||||
| @@ -679,7 +679,7 @@ public class XMLCatalog extends DataType | |||||
| } | } | ||||
| if (url != null) { | if (url != null) { | ||||
| String fileName = fileUtils.fromURI(url.toString()); | |||||
| String fileName = FILE_UTILS.fromURI(url.toString()); | |||||
| if (fileName != null) { | if (fileName != null) { | ||||
| log("fileName " + fileName, Project.MSG_DEBUG); | log("fileName " + fileName, Project.MSG_DEBUG); | ||||
| File resFile = new File(fileName); | File resFile = new File(fileName); | ||||
| @@ -756,7 +756,7 @@ public class XMLCatalog extends DataType | |||||
| baseURL = matchingEntry.getBase(); | baseURL = matchingEntry.getBase(); | ||||
| } else { | } else { | ||||
| try { | try { | ||||
| baseURL = fileUtils.getFileURL(getProject().getBaseDir()); | |||||
| baseURL = FILE_UTILS.getFileURL(getProject().getBaseDir()); | |||||
| } catch (MalformedURLException ex) { | } catch (MalformedURLException ex) { | ||||
| throw new BuildException("Project basedir cannot be converted to a URL"); | throw new BuildException("Project basedir cannot be converted to a URL"); | ||||
| } | } | ||||
| @@ -24,7 +24,6 @@ import java.text.ParseException; | |||||
| import java.util.Locale; | import java.util.Locale; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.taskdefs.condition.Os; | |||||
| import org.apache.tools.ant.types.EnumeratedAttribute; | import org.apache.tools.ant.types.EnumeratedAttribute; | ||||
| import org.apache.tools.ant.types.Parameter; | import org.apache.tools.ant.types.Parameter; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| @@ -36,6 +35,9 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| */ | */ | ||||
| public class DateSelector extends BaseExtendSelector { | public class DateSelector extends BaseExtendSelector { | ||||
| /** Utilities used for file operations */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private long millis = -1; | private long millis = -1; | ||||
| private String dateTime = null; | private String dateTime = null; | ||||
| private boolean includeDirs = false; | private boolean includeDirs = false; | ||||
| @@ -60,7 +62,7 @@ public class DateSelector extends BaseExtendSelector { | |||||
| * | * | ||||
| */ | */ | ||||
| public DateSelector() { | public DateSelector() { | ||||
| granularity = FileUtils.getFileUtils().getFileTimestampGranularity(); | |||||
| granularity = FILE_UTILS.getFileTimestampGranularity(); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -48,7 +48,7 @@ import java.io.IOException; | |||||
| */ | */ | ||||
| public class DifferentSelector extends MappingSelector { | public class DifferentSelector extends MappingSelector { | ||||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private boolean ignoreFileTimes = true; | private boolean ignoreFileTimes = true; | ||||
| private boolean ignoreContents = false; | private boolean ignoreContents = false; | ||||
| @@ -101,7 +101,7 @@ public class DifferentSelector extends MappingSelector { | |||||
| if (!ignoreContents) { | if (!ignoreContents) { | ||||
| //here do a bulk comparison | //here do a bulk comparison | ||||
| try { | try { | ||||
| return !fileUtils.contentEquals(srcfile, destfile); | |||||
| return !FILE_UTILS.contentEquals(srcfile, destfile); | |||||
| } catch (IOException e) { | } catch (IOException e) { | ||||
| throw new BuildException("while comparing " + srcfile + " and " | throw new BuildException("while comparing " + srcfile + " and " | ||||
| + destfile, e); | + destfile, e); | ||||
| @@ -30,6 +30,10 @@ import java.io.File; | |||||
| * selector | * selector | ||||
| */ | */ | ||||
| public abstract class MappingSelector extends BaseSelector { | public abstract class MappingSelector extends BaseSelector { | ||||
| /** Utilities used for file operations */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| protected File targetdir = null; | protected File targetdir = null; | ||||
| protected Mapper mapperElement = null; | protected Mapper mapperElement = null; | ||||
| protected FileNameMapper map = null; | protected FileNameMapper map = null; | ||||
| @@ -40,7 +44,7 @@ public abstract class MappingSelector extends BaseSelector { | |||||
| * | * | ||||
| */ | */ | ||||
| public MappingSelector() { | public MappingSelector() { | ||||
| granularity = (int) FileUtils.getFileUtils().getFileTimestampGranularity(); | |||||
| granularity = (int) FILE_UTILS.getFileTimestampGranularity(); | |||||
| } | } | ||||
| @@ -58,14 +58,16 @@ import org.apache.tools.ant.launch.Locator; | |||||
| */ | */ | ||||
| public class FileUtils { | public class FileUtils { | ||||
| private static final FileUtils PRIMARY_INSTANCE = new FileUtils(); | private static final FileUtils PRIMARY_INSTANCE = new FileUtils(); | ||||
| //get some non-crypto-grade randomness from various places. | //get some non-crypto-grade randomness from various places. | ||||
| private static Random rand = new Random(System.currentTimeMillis() | private static Random rand = new Random(System.currentTimeMillis() | ||||
| + Runtime.getRuntime().freeMemory()); | + Runtime.getRuntime().freeMemory()); | ||||
| private static boolean onNetWare = Os.isFamily("netware"); | private static boolean onNetWare = Os.isFamily("netware"); | ||||
| private static final int BUF_SIZE = 8192; | |||||
| // for toURI | // for toURI | ||||
| private static boolean[] isSpecial = new boolean[256]; | private static boolean[] isSpecial = new boolean[256]; | ||||
| @@ -119,6 +121,7 @@ public class FileUtils { | |||||
| * Method to retrieve The FileUtils, which is shared by all users of this | * Method to retrieve The FileUtils, which is shared by all users of this | ||||
| * method. | * method. | ||||
| * @return an instance of FileUtils. | * @return an instance of FileUtils. | ||||
| * @since Ant 1.7 | |||||
| */ | */ | ||||
| public static FileUtils getFileUtils() { | public static FileUtils getFileUtils() { | ||||
| return PRIMARY_INSTANCE; | return PRIMARY_INSTANCE; | ||||
| @@ -555,7 +558,7 @@ public class FileUtils { | |||||
| if (filterChainsAvailable) { | if (filterChainsAvailable) { | ||||
| ChainReaderHelper crh = new ChainReaderHelper(); | ChainReaderHelper crh = new ChainReaderHelper(); | ||||
| crh.setBufferSize(8192); | |||||
| crh.setBufferSize(BUF_SIZE); | |||||
| crh.setPrimaryReader(in); | crh.setPrimaryReader(in); | ||||
| crh.setFilterChains(filterChains); | crh.setFilterChains(filterChains); | ||||
| crh.setProject(project); | crh.setProject(project); | ||||
| @@ -612,14 +615,14 @@ public class FileUtils { | |||||
| if (filterChainsAvailable) { | if (filterChainsAvailable) { | ||||
| ChainReaderHelper crh = new ChainReaderHelper(); | ChainReaderHelper crh = new ChainReaderHelper(); | ||||
| crh.setBufferSize(8192); | |||||
| crh.setBufferSize(BUF_SIZE); | |||||
| crh.setPrimaryReader(in); | crh.setPrimaryReader(in); | ||||
| crh.setFilterChains(filterChains); | crh.setFilterChains(filterChains); | ||||
| crh.setProject(project); | crh.setProject(project); | ||||
| Reader rdr = crh.getAssembledReader(); | Reader rdr = crh.getAssembledReader(); | ||||
| in = new BufferedReader(rdr); | in = new BufferedReader(rdr); | ||||
| } | } | ||||
| char[] buffer = new char[1024 * 8]; | |||||
| char[] buffer = new char[BUF_SIZE]; | |||||
| while (true) { | while (true) { | ||||
| int nRead = in.read(buffer, 0, buffer.length); | int nRead = in.read(buffer, 0, buffer.length); | ||||
| if (nRead == -1) { | if (nRead == -1) { | ||||
| @@ -1052,7 +1055,7 @@ public class FileUtils { | |||||
| * reader. | * reader. | ||||
| */ | */ | ||||
| public static final String readFully(Reader rdr) throws IOException { | public static final String readFully(Reader rdr) throws IOException { | ||||
| return readFully(rdr, 8192); | |||||
| return readFully(rdr, BUF_SIZE); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2002-2004 The Apache Software Foundation | |||||
| * Copyright 2002-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -43,7 +43,7 @@ public class JAXPUtils { | |||||
| * | * | ||||
| * @since Ant 1.6 | * @since Ant 1.6 | ||||
| */ | */ | ||||
| private static final FileUtils fu = FileUtils.newFileUtils(); | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * Parser factory to use to create parsers. | * Parser factory to use to create parsers. | ||||
| @@ -175,7 +175,7 @@ public class JAXPUtils { | |||||
| * @since Ant 1.5.2 | * @since Ant 1.5.2 | ||||
| */ | */ | ||||
| public static String getSystemId(File file) { | public static String getSystemId(File file) { | ||||
| return fu.toURI(file.getAbsolutePath()); | |||||
| return FILE_UTILS.toURI(file.getAbsolutePath()); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2002-2004 The Apache Software Foundation | |||||
| * Copyright 2002-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -46,7 +46,7 @@ public class JavaEnvUtils { | |||||
| private static final String javaHome = System.getProperty("java.home"); | private static final String javaHome = System.getProperty("java.home"); | ||||
| /** FileUtils instance for path normalization */ | /** FileUtils instance for path normalization */ | ||||
| private static final FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** Version of currently running VM. */ | /** Version of currently running VM. */ | ||||
| private static String javaVersion; | private static String javaVersion; | ||||
| @@ -250,7 +250,7 @@ public class JavaEnvUtils { | |||||
| * @return null if the executable cannot be found. | * @return null if the executable cannot be found. | ||||
| */ | */ | ||||
| private static File findInDir(String dirName, String commandName) { | private static File findInDir(String dirName, String commandName) { | ||||
| File dir = fileUtils.normalize(dirName); | |||||
| File dir = FILE_UTILS.normalize(dirName); | |||||
| File executable = null; | File executable = null; | ||||
| if (dir.exists()) { | if (dir.exists()) { | ||||
| executable = new File(dir, addExtension(commandName)); | executable = new File(dir, addExtension(commandName)); | ||||
| @@ -371,8 +371,7 @@ public class JavaEnvUtils { | |||||
| */ | */ | ||||
| public static File createVmsJavaOptionFile(String[] cmd) | public static File createVmsJavaOptionFile(String[] cmd) | ||||
| throws IOException { | throws IOException { | ||||
| File script = FileUtils.newFileUtils() | |||||
| .createTempFile("ANT", ".JAVA_OPTS", null); | |||||
| File script = FILE_UTILS.createTempFile("ANT", ".JAVA_OPTS", null); | |||||
| PrintWriter out = null; | PrintWriter out = null; | ||||
| try { | try { | ||||
| out = new PrintWriter(new BufferedWriter(new FileWriter(script))); | out = new PrintWriter(new BufferedWriter(new FileWriter(script))); | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2002-2004 The Apache Software Foundation | |||||
| * Copyright 2002-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -25,6 +25,10 @@ import org.apache.tools.ant.launch.Locator; | |||||
| * | * | ||||
| */ | */ | ||||
| public class LoaderUtils { | public class LoaderUtils { | ||||
| /** Utilities used for file operations */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * Set the context classloader | * Set the context classloader | ||||
| * | * | ||||
| @@ -67,9 +71,8 @@ public class LoaderUtils { | |||||
| */ | */ | ||||
| private static File normalizeSource(File source) { | private static File normalizeSource(File source) { | ||||
| if (source != null) { | if (source != null) { | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| try { | try { | ||||
| source = fileUtils.normalize(source.getAbsolutePath()); | |||||
| source = FILE_UTILS.normalize(source.getAbsolutePath()); | |||||
| } catch (BuildException e) { | } catch (BuildException e) { | ||||
| // relative path | // relative path | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2003-2004 The Apache Software Foundation | |||||
| * Copyright 2003-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -32,6 +32,9 @@ import java.util.Vector; | |||||
| */ | */ | ||||
| public class ResourceUtils { | public class ResourceUtils { | ||||
| /** Utilities used for file operations */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * tells which source files should be reprocessed based on the | * tells which source files should be reprocessed based on the | ||||
| * last modification date of target files | * last modification date of target files | ||||
| @@ -51,8 +54,7 @@ public class ResourceUtils { | |||||
| FileNameMapper mapper, | FileNameMapper mapper, | ||||
| ResourceFactory targets) { | ResourceFactory targets) { | ||||
| return selectOutOfDateSources(logTo, source, mapper, targets, | return selectOutOfDateSources(logTo, source, mapper, targets, | ||||
| FileUtils.newFileUtils() | |||||
| .getFileTimestampGranularity()); | |||||
| FILE_UTILS.getFileTimestampGranularity()); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -36,7 +36,7 @@ public class SourceFileScanner implements ResourceFactory { | |||||
| protected Task task; | protected Task task; | ||||
| private FileUtils fileUtils; | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private File destDir; // base directory of the fileset | private File destDir; // base directory of the fileset | ||||
| /** | /** | ||||
| @@ -44,7 +44,6 @@ public class SourceFileScanner implements ResourceFactory { | |||||
| */ | */ | ||||
| public SourceFileScanner(Task task) { | public SourceFileScanner(Task task) { | ||||
| this.task = task; | this.task = task; | ||||
| fileUtils = FileUtils.newFileUtils(); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -61,7 +60,7 @@ public class SourceFileScanner implements ResourceFactory { | |||||
| public String[] restrict(String[] files, File srcDir, File destDir, | public String[] restrict(String[] files, File srcDir, File destDir, | ||||
| FileNameMapper mapper) { | FileNameMapper mapper) { | ||||
| return restrict(files, srcDir, destDir, mapper, | return restrict(files, srcDir, destDir, mapper, | ||||
| fileUtils.getFileTimestampGranularity()); | |||||
| FILE_UTILS.getFileTimestampGranularity()); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -85,7 +84,7 @@ public class SourceFileScanner implements ResourceFactory { | |||||
| this.destDir = destDir; | this.destDir = destDir; | ||||
| Vector v = new Vector(); | Vector v = new Vector(); | ||||
| for (int i = 0; i < files.length; i++) { | for (int i = 0; i < files.length; i++) { | ||||
| File src = fileUtils.resolveFile(srcDir, files[i]); | |||||
| File src = FILE_UTILS.resolveFile(srcDir, files[i]); | |||||
| v.addElement(new Resource(files[i], src.exists(), | v.addElement(new Resource(files[i], src.exists(), | ||||
| src.lastModified(), src.isDirectory())); | src.lastModified(), src.isDirectory())); | ||||
| } | } | ||||
| @@ -112,7 +111,7 @@ public class SourceFileScanner implements ResourceFactory { | |||||
| public File[] restrictAsFiles(String[] files, File srcDir, File destDir, | public File[] restrictAsFiles(String[] files, File srcDir, File destDir, | ||||
| FileNameMapper mapper) { | FileNameMapper mapper) { | ||||
| return restrictAsFiles(files, srcDir, destDir, mapper, | return restrictAsFiles(files, srcDir, destDir, mapper, | ||||
| fileUtils.getFileTimestampGranularity()); | |||||
| FILE_UTILS.getFileTimestampGranularity()); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -140,7 +139,7 @@ public class SourceFileScanner implements ResourceFactory { | |||||
| * @since Ant 1.5.2 | * @since Ant 1.5.2 | ||||
| */ | */ | ||||
| public Resource getResource(String name) { | public Resource getResource(String name) { | ||||
| File src = fileUtils.resolveFile(destDir, name); | |||||
| File src = FILE_UTILS.resolveFile(destDir, name); | |||||
| return new Resource(name, src.exists(), src.lastModified(), | return new Resource(name, src.exists(), src.lastModified(), | ||||
| src.isDirectory()); | src.isDirectory()); | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2004 The Apache Software Foundation | |||||
| * Copyright 2004-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -26,7 +26,6 @@ import java.util.Collections; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.List; | import java.util.List; | ||||
| import junit.framework.TestCase; | import junit.framework.TestCase; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| @@ -37,6 +36,9 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| */ | */ | ||||
| public class AntClassLoaderDelegationTest extends TestCase { | public class AntClassLoaderDelegationTest extends TestCase { | ||||
| /** Instance of a utility class to use for file operations. */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private Project p; | private Project p; | ||||
| public AntClassLoaderDelegationTest(String name) { | public AntClassLoaderDelegationTest(String name) { | ||||
| @@ -64,7 +66,7 @@ public class AntClassLoaderDelegationTest extends TestCase { | |||||
| // An AntClassLoader which is supposed to delegate to the parent and then to the disk path: | // An AntClassLoader which is supposed to delegate to the parent and then to the disk path: | ||||
| ClassLoader acl = new AntClassLoader(parent, p, path, true); | ClassLoader acl = new AntClassLoader(parent, p, path, true); | ||||
| // The intended result URLs: | // The intended result URLs: | ||||
| URL urlFromPath = new URL(FileUtils.newFileUtils().toURI(buildTestcases) + TEST_RESOURCE); | |||||
| URL urlFromPath = new URL(FILE_UTILS.toURI(buildTestcases) + TEST_RESOURCE); | |||||
| URL urlFromParent = new URL("http://ant.apache.org/" + TEST_RESOURCE); | URL urlFromParent = new URL("http://ant.apache.org/" + TEST_RESOURCE); | ||||
| assertEquals("correct resources (regular delegation order)", | assertEquals("correct resources (regular delegation order)", | ||||
| Arrays.asList(new URL[] {urlFromParent, urlFromPath}), | Arrays.asList(new URL[] {urlFromParent, urlFromPath}), | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2003-2004 The Apache Software Foundation | |||||
| * Copyright 2003-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -29,7 +29,7 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| */ | */ | ||||
| public class ConcatFilterTest extends BuildFileTest { | public class ConcatFilterTest extends BuildFileTest { | ||||
| private static FileUtils fu = FileUtils.newFileUtils(); | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private static final String lSep = | private static final String lSep = | ||||
| Os.isFamily("mac") ? "\r" : System.getProperty("line.separator"); | Os.isFamily("mac") ? "\r" : System.getProperty("line.separator"); | ||||
| @@ -82,7 +82,7 @@ public class ConcatFilterTest extends BuildFileTest { | |||||
| executeTarget("testFilterReaderNoArgs"); | executeTarget("testFilterReaderNoArgs"); | ||||
| File expected = getProject().resolveFile("input/concatfilter.test"); | File expected = getProject().resolveFile("input/concatfilter.test"); | ||||
| File result = getProject().resolveFile("result/concat.FilterReaderNoArgs.test"); | File result = getProject().resolveFile("result/concat.FilterReaderNoArgs.test"); | ||||
| assertTrue("testFilterReaderNoArgs: Result not like expected", fu.contentEquals(expected, result)); | |||||
| assertTrue("testFilterReaderNoArgs: Result not like expected", FILE_UTILS.contentEquals(expected, result)); | |||||
| } | } | ||||
| public void testFilterReaderBefore() { | public void testFilterReaderBefore() { | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2003-2004 The Apache Software Foundation | |||||
| * Copyright 2003-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -26,6 +26,8 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| /** | /** | ||||
| */ | */ | ||||
| public class EscapeUnicodeTest extends BuildFileTest { | public class EscapeUnicodeTest extends BuildFileTest { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| public EscapeUnicodeTest(String name) { | public EscapeUnicodeTest(String name) { | ||||
| super(name); | super(name); | ||||
| @@ -43,8 +45,7 @@ public class EscapeUnicodeTest extends BuildFileTest { | |||||
| executeTarget("testEscapeUnicode"); | executeTarget("testEscapeUnicode"); | ||||
| File expected = getProject().resolveFile("expected/escapeunicode.test"); | File expected = getProject().resolveFile("expected/escapeunicode.test"); | ||||
| File result = getProject().resolveFile("result/escapeunicode.test"); | File result = getProject().resolveFile("result/escapeunicode.test"); | ||||
| FileUtils fu = FileUtils.newFileUtils(); | |||||
| assertTrue(fu.contentEquals(expected, result)); | |||||
| assertTrue(FILE_UTILS.contentEquals(expected, result)); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2003-2004 The Apache Software Foundation | |||||
| * Copyright 2003-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -30,6 +30,8 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| */ | */ | ||||
| public class HeadTailTest extends BuildFileTest { | public class HeadTailTest extends BuildFileTest { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| public HeadTailTest(String name) { | public HeadTailTest(String name) { | ||||
| super(name); | super(name); | ||||
| } | } | ||||
| @@ -46,32 +48,28 @@ public class HeadTailTest extends BuildFileTest { | |||||
| executeTarget("testHead"); | executeTarget("testHead"); | ||||
| File expected = getProject().resolveFile("expected/head-tail.head.test"); | File expected = getProject().resolveFile("expected/head-tail.head.test"); | ||||
| File result = getProject().resolveFile("result/head-tail.head.test"); | File result = getProject().resolveFile("result/head-tail.head.test"); | ||||
| FileUtils fu = FileUtils.newFileUtils(); | |||||
| assertTrue("testHead: Result not like expected", fu.contentEquals(expected, result)); | |||||
| assertTrue("testHead: Result not like expected", FILE_UTILS.contentEquals(expected, result)); | |||||
| } | } | ||||
| public void testHeadLines() throws IOException { | public void testHeadLines() throws IOException { | ||||
| executeTarget("testHeadLines"); | executeTarget("testHeadLines"); | ||||
| File expected = getProject().resolveFile("expected/head-tail.headLines.test"); | File expected = getProject().resolveFile("expected/head-tail.headLines.test"); | ||||
| File result = getProject().resolveFile("result/head-tail.headLines.test"); | File result = getProject().resolveFile("result/head-tail.headLines.test"); | ||||
| FileUtils fu = FileUtils.newFileUtils(); | |||||
| assertTrue("testHeadLines: Result not like expected", fu.contentEquals(expected, result)); | |||||
| assertTrue("testHeadLines: Result not like expected", FILE_UTILS.contentEquals(expected, result)); | |||||
| } | } | ||||
| public void testHeadSkip() throws IOException { | public void testHeadSkip() throws IOException { | ||||
| executeTarget("testHeadSkip"); | executeTarget("testHeadSkip"); | ||||
| File expected = getProject().resolveFile("expected/head-tail.headSkip.test"); | File expected = getProject().resolveFile("expected/head-tail.headSkip.test"); | ||||
| File result = getProject().resolveFile("result/head-tail.headSkip.test"); | File result = getProject().resolveFile("result/head-tail.headSkip.test"); | ||||
| FileUtils fu = FileUtils.newFileUtils(); | |||||
| assertTrue("testHeadSkip: Result not like expected", fu.contentEquals(expected, result)); | |||||
| assertTrue("testHeadSkip: Result not like expected", FILE_UTILS.contentEquals(expected, result)); | |||||
| } | } | ||||
| public void testHeadLinesSkip() throws IOException { | public void testHeadLinesSkip() throws IOException { | ||||
| executeTarget("testHeadLinesSkip"); | executeTarget("testHeadLinesSkip"); | ||||
| File expected = getProject().resolveFile("expected/head-tail.headLinesSkip.test"); | File expected = getProject().resolveFile("expected/head-tail.headLinesSkip.test"); | ||||
| File result = getProject().resolveFile("result/head-tail.headLinesSkip.test"); | File result = getProject().resolveFile("result/head-tail.headLinesSkip.test"); | ||||
| FileUtils fu = FileUtils.newFileUtils(); | |||||
| assertTrue("testHeadLinesSkip: Result not like expected", fu.contentEquals(expected, result)); | |||||
| assertTrue("testHeadLinesSkip: Result not like expected", FILE_UTILS.contentEquals(expected, result)); | |||||
| } | } | ||||
| public void testFilterReaderHeadLinesSkip() throws IOException { | public void testFilterReaderHeadLinesSkip() throws IOException { | ||||
| @@ -80,41 +78,36 @@ public class HeadTailTest extends BuildFileTest { | |||||
| "expected/head-tail.headLinesSkip.test"); | "expected/head-tail.headLinesSkip.test"); | ||||
| File result = getProject().resolveFile( | File result = getProject().resolveFile( | ||||
| "result/head-tail.filterReaderHeadLinesSkip.test"); | "result/head-tail.filterReaderHeadLinesSkip.test"); | ||||
| FileUtils fu = FileUtils.newFileUtils(); | |||||
| assertTrue("testFilterReaderHeadLinesSkip: Result not like expected", | assertTrue("testFilterReaderHeadLinesSkip: Result not like expected", | ||||
| fu.contentEquals(expected, result)); | |||||
| FILE_UTILS.contentEquals(expected, result)); | |||||
| } | } | ||||
| public void testTail() throws IOException { | public void testTail() throws IOException { | ||||
| executeTarget("testTail"); | executeTarget("testTail"); | ||||
| File expected = getProject().resolveFile("expected/head-tail.tail.test"); | File expected = getProject().resolveFile("expected/head-tail.tail.test"); | ||||
| File result = getProject().resolveFile("result/head-tail.tail.test"); | File result = getProject().resolveFile("result/head-tail.tail.test"); | ||||
| FileUtils fu = FileUtils.newFileUtils(); | |||||
| assertTrue("testTail: Result not like expected", fu.contentEquals(expected, result)); | |||||
| assertTrue("testTail: Result not like expected", FILE_UTILS.contentEquals(expected, result)); | |||||
| } | } | ||||
| public void testTailLines() throws IOException { | public void testTailLines() throws IOException { | ||||
| executeTarget("testTailLines"); | executeTarget("testTailLines"); | ||||
| File expected = getProject().resolveFile("expected/head-tail.tailLines.test"); | File expected = getProject().resolveFile("expected/head-tail.tailLines.test"); | ||||
| File result = getProject().resolveFile("result/head-tail.tailLines.test"); | File result = getProject().resolveFile("result/head-tail.tailLines.test"); | ||||
| FileUtils fu = FileUtils.newFileUtils(); | |||||
| assertTrue("testTailLines: Result not like expected", fu.contentEquals(expected, result)); | |||||
| assertTrue("testTailLines: Result not like expected", FILE_UTILS.contentEquals(expected, result)); | |||||
| } | } | ||||
| public void testTailSkip() throws IOException { | public void testTailSkip() throws IOException { | ||||
| executeTarget("testTailSkip"); | executeTarget("testTailSkip"); | ||||
| File expected = getProject().resolveFile("expected/head-tail.tailSkip.test"); | File expected = getProject().resolveFile("expected/head-tail.tailSkip.test"); | ||||
| File result = getProject().resolveFile("result/head-tail.tailSkip.test"); | File result = getProject().resolveFile("result/head-tail.tailSkip.test"); | ||||
| FileUtils fu = FileUtils.newFileUtils(); | |||||
| assertTrue("testTailSkip: Result not like expected", fu.contentEquals(expected, result)); | |||||
| assertTrue("testTailSkip: Result not like expected", FILE_UTILS.contentEquals(expected, result)); | |||||
| } | } | ||||
| public void testTailLinesSkip() throws IOException { | public void testTailLinesSkip() throws IOException { | ||||
| executeTarget("testTailLinesSkip"); | executeTarget("testTailLinesSkip"); | ||||
| File expected = getProject().resolveFile("expected/head-tail.tailLinesSkip.test"); | File expected = getProject().resolveFile("expected/head-tail.tailLinesSkip.test"); | ||||
| File result = getProject().resolveFile("result/head-tail.tailLinesSkip.test"); | File result = getProject().resolveFile("result/head-tail.tailLinesSkip.test"); | ||||
| FileUtils fu = FileUtils.newFileUtils(); | |||||
| assertTrue("testTailLinesSkip: Result not like expected", fu.contentEquals(expected, result)); | |||||
| assertTrue("testTailLinesSkip: Result not like expected", FILE_UTILS.contentEquals(expected, result)); | |||||
| } | } | ||||
| public void testFilterReaderTailLinesSkip() throws IOException { | public void testFilterReaderTailLinesSkip() throws IOException { | ||||
| @@ -123,17 +116,15 @@ public class HeadTailTest extends BuildFileTest { | |||||
| "expected/head-tail.tailLinesSkip.test"); | "expected/head-tail.tailLinesSkip.test"); | ||||
| File result = getProject().resolveFile( | File result = getProject().resolveFile( | ||||
| "result/head-tail.filterReaderTailLinesSkip.test"); | "result/head-tail.filterReaderTailLinesSkip.test"); | ||||
| FileUtils fu = FileUtils.newFileUtils(); | |||||
| assertTrue("testFilterReaderTailLinesSkip: Result not like expected", | assertTrue("testFilterReaderTailLinesSkip: Result not like expected", | ||||
| fu.contentEquals(expected, result)); | |||||
| FILE_UTILS.contentEquals(expected, result)); | |||||
| } | } | ||||
| public void testHeadTail() throws IOException { | public void testHeadTail() throws IOException { | ||||
| executeTarget("testHeadTail"); | executeTarget("testHeadTail"); | ||||
| File expected = getProject().resolveFile("expected/head-tail.headtail.test"); | File expected = getProject().resolveFile("expected/head-tail.headtail.test"); | ||||
| File result = getProject().resolveFile("result/head-tail.headtail.test"); | File result = getProject().resolveFile("result/head-tail.headtail.test"); | ||||
| FileUtils fu = FileUtils.newFileUtils(); | |||||
| assertTrue("testHeadTail: Result not like expected", fu.contentEquals(expected, result)); | |||||
| assertTrue("testHeadTail: Result not like expected", FILE_UTILS.contentEquals(expected, result)); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2002-2004 The Apache Software Foundation | |||||
| * Copyright 2002-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -27,6 +27,8 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| */ | */ | ||||
| public class LineContainsTest extends BuildFileTest { | public class LineContainsTest extends BuildFileTest { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| public LineContainsTest(String name) { | public LineContainsTest(String name) { | ||||
| super(name); | super(name); | ||||
| } | } | ||||
| @@ -43,8 +45,7 @@ public class LineContainsTest extends BuildFileTest { | |||||
| executeTarget("testLineContains"); | executeTarget("testLineContains"); | ||||
| File expected = getProject().resolveFile("expected/linecontains.test"); | File expected = getProject().resolveFile("expected/linecontains.test"); | ||||
| File result = getProject().resolveFile("result/linecontains.test"); | File result = getProject().resolveFile("result/linecontains.test"); | ||||
| FileUtils fu = FileUtils.newFileUtils(); | |||||
| assertTrue(fu.contentEquals(expected, result)); | |||||
| assertTrue(FILE_UTILS.contentEquals(expected, result)); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2003-2004 The Apache Software Foundation | |||||
| * Copyright 2003-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -26,6 +26,8 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| /** | /** | ||||
| */ | */ | ||||
| public class ReplaceTokensTest extends BuildFileTest { | public class ReplaceTokensTest extends BuildFileTest { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| public ReplaceTokensTest(String name) { | public ReplaceTokensTest(String name) { | ||||
| super(name); | super(name); | ||||
| @@ -43,8 +45,7 @@ public class ReplaceTokensTest extends BuildFileTest { | |||||
| executeTarget("testReplaceTokens"); | executeTarget("testReplaceTokens"); | ||||
| File expected = getProject().resolveFile("expected/replacetokens.test"); | File expected = getProject().resolveFile("expected/replacetokens.test"); | ||||
| File result = getProject().resolveFile("result/replacetokens.test"); | File result = getProject().resolveFile("result/replacetokens.test"); | ||||
| FileUtils fu = FileUtils.newFileUtils(); | |||||
| assertTrue(fu.contentEquals(expected, result)); | |||||
| assertTrue(FILE_UTILS.contentEquals(expected, result)); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2003-2004 The Apache Software Foundation | |||||
| * Copyright 2003-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -26,6 +26,8 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| /** | /** | ||||
| */ | */ | ||||
| public class StripJavaCommentsTest extends BuildFileTest { | public class StripJavaCommentsTest extends BuildFileTest { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| public StripJavaCommentsTest(String name) { | public StripJavaCommentsTest(String name) { | ||||
| super(name); | super(name); | ||||
| @@ -43,8 +45,7 @@ public class StripJavaCommentsTest extends BuildFileTest { | |||||
| executeTarget("testStripJavaComments"); | executeTarget("testStripJavaComments"); | ||||
| File expected = getProject().resolveFile("expected/stripjavacomments.test"); | File expected = getProject().resolveFile("expected/stripjavacomments.test"); | ||||
| File result = getProject().resolveFile("result/stripjavacomments.test"); | File result = getProject().resolveFile("result/stripjavacomments.test"); | ||||
| FileUtils fu = FileUtils.newFileUtils(); | |||||
| assertTrue(fu.contentEquals(expected, result)); | |||||
| assertTrue(FILE_UTILS.contentEquals(expected, result)); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2001-2004 The Apache Software Foundation | |||||
| * Copyright 2001-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -27,6 +27,9 @@ import java.io.IOException; | |||||
| */ | */ | ||||
| public class BUnzip2Test extends BuildFileTest { | public class BUnzip2Test extends BuildFileTest { | ||||
| /** Utilities used for file operations */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| public BUnzip2Test(String name) { | public BUnzip2Test(String name) { | ||||
| super(name); | super(name); | ||||
| } | } | ||||
| @@ -40,11 +43,10 @@ public class BUnzip2Test extends BuildFileTest { | |||||
| executeTarget("cleanup"); | executeTarget("cleanup"); | ||||
| } | } | ||||
| public void testRealTest() throws java.io.IOException { | |||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| public void testRealTest() throws IOException { | |||||
| executeTarget("realTest"); | executeTarget("realTest"); | ||||
| assertTrue("File content mismatch after bunzip2", | assertTrue("File content mismatch after bunzip2", | ||||
| fileUtils.contentEquals(project.resolveFile("expected/asf-logo-huge.tar"), | |||||
| FILE_UTILS.contentEquals(project.resolveFile("expected/asf-logo-huge.tar"), | |||||
| project.resolveFile("asf-logo-huge.tar"))); | project.resolveFile("asf-logo-huge.tar"))); | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2001-2004 The Apache Software Foundation | |||||
| * Copyright 2001-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -27,6 +27,9 @@ import java.io.IOException; | |||||
| */ | */ | ||||
| public class BZip2Test extends BuildFileTest { | public class BZip2Test extends BuildFileTest { | ||||
| /** Utilities used for file operations */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| public BZip2Test(String name) { | public BZip2Test(String name) { | ||||
| super(name); | super(name); | ||||
| } | } | ||||
| @@ -40,11 +43,10 @@ public class BZip2Test extends BuildFileTest { | |||||
| executeTarget("cleanup"); | executeTarget("cleanup"); | ||||
| } | } | ||||
| public void testRealTest() throws java.io.IOException { | |||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| public void testRealTest() throws IOException { | |||||
| executeTarget("realTest"); | executeTarget("realTest"); | ||||
| assertTrue("File content mismatch", | assertTrue("File content mismatch", | ||||
| fileUtils.contentEquals(project.resolveFile("expected/asf-logo-huge.tar.bz2"), | |||||
| FILE_UTILS.contentEquals(project.resolveFile("expected/asf-logo-huge.tar.bz2"), | |||||
| project.resolveFile("asf-logo-huge.tar.bz2"))); | project.resolveFile("asf-logo-huge.tar.bz2"))); | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2001,2003-2004 The Apache Software Foundation | |||||
| * Copyright 2001,2003-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -18,7 +18,6 @@ | |||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import org.apache.tools.ant.BuildFileTest; | import org.apache.tools.ant.BuildFileTest; | ||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.File; | import java.io.File; | ||||
| @@ -41,22 +40,18 @@ public class ChecksumTest extends BuildFileTest { | |||||
| } | } | ||||
| public void testCreateMd5() throws IOException { | public void testCreateMd5() throws IOException { | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| executeTarget("createMd5"); | executeTarget("createMd5"); | ||||
| } | } | ||||
| public void testCreateMD5SUMformat() throws IOException { | public void testCreateMD5SUMformat() throws IOException { | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| executeTarget("createMD5SUMformat"); | executeTarget("createMD5SUMformat"); | ||||
| } | } | ||||
| public void testCreateSVFformat() throws IOException { | public void testCreateSVFformat() throws IOException { | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| executeTarget("createSVFformat"); | executeTarget("createSVFformat"); | ||||
| } | } | ||||
| public void testCreatePattern() throws IOException { | public void testCreatePattern() throws IOException { | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| executeTarget("createPattern"); | executeTarget("createPattern"); | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2002-2004 The Apache Software Foundation | |||||
| * Copyright 2002-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -43,6 +43,9 @@ public class ConcatTest | |||||
| */ | */ | ||||
| private static final String tempFile2 = "concat.tmp.2"; | private static final String tempFile2 = "concat.tmp.2"; | ||||
| /** Utilities used for file operations */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| /** | /** | ||||
| * Required constructor. | * Required constructor. | ||||
| */ | */ | ||||
| @@ -268,9 +271,8 @@ public class ConcatTest | |||||
| public void testTranscoding() throws IOException { | public void testTranscoding() throws IOException { | ||||
| executeTarget("testTranscoding"); | executeTarget("testTranscoding"); | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| File f1 = getProject().resolveFile("copy/expected/utf-8"); | File f1 = getProject().resolveFile("copy/expected/utf-8"); | ||||
| File f2 = getProject().resolveFile("concat.utf8"); | File f2 = getProject().resolveFile("concat.utf8"); | ||||
| assertTrue(fileUtils.contentEquals(f1, f2)); | |||||
| assertTrue(FILE_UTILS.contentEquals(f1, f2)); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -18,7 +18,6 @@ | |||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import org.apache.tools.ant.BuildFileTest; | import org.apache.tools.ant.BuildFileTest; | ||||
| import org.apache.tools.ant.Project; | |||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| import org.apache.tools.ant.util.JavaEnvUtils; | import org.apache.tools.ant.util.JavaEnvUtils; | ||||
| import java.io.File; | import java.io.File; | ||||
| @@ -30,6 +29,9 @@ import java.io.IOException; | |||||
| */ | */ | ||||
| public class CopyTest extends BuildFileTest { | public class CopyTest extends BuildFileTest { | ||||
| /** Utilities used for file operations */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| public CopyTest(String name) { | public CopyTest(String name) { | ||||
| super(name); | super(name); | ||||
| } | } | ||||
| @@ -100,20 +102,18 @@ public class CopyTest extends BuildFileTest { | |||||
| public void testFilterSet() throws IOException { | public void testFilterSet() throws IOException { | ||||
| executeTarget("testFilterSet"); | executeTarget("testFilterSet"); | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| File tmp = new File(getProjectDir(), "copy.filterset.tmp"); | File tmp = new File(getProjectDir(), "copy.filterset.tmp"); | ||||
| File check = new File(getProjectDir(), "expected/copy.filterset.filtered"); | File check = new File(getProjectDir(), "expected/copy.filterset.filtered"); | ||||
| assertTrue(tmp.exists()); | assertTrue(tmp.exists()); | ||||
| assertTrue(fileUtils.contentEquals(tmp, check)); | |||||
| assertTrue(FILE_UTILS.contentEquals(tmp, check)); | |||||
| } | } | ||||
| public void testFilterChain() throws IOException { | public void testFilterChain() throws IOException { | ||||
| executeTarget("testFilterChain"); | executeTarget("testFilterChain"); | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| File tmp = new File(getProjectDir(), "copy.filterchain.tmp"); | File tmp = new File(getProjectDir(), "copy.filterchain.tmp"); | ||||
| File check = new File(getProjectDir(), "expected/copy.filterset.filtered"); | File check = new File(getProjectDir(), "expected/copy.filterset.filtered"); | ||||
| assertTrue(tmp.exists()); | assertTrue(tmp.exists()); | ||||
| assertTrue(fileUtils.contentEquals(tmp, check)); | |||||
| assertTrue(FILE_UTILS.contentEquals(tmp, check)); | |||||
| } | } | ||||
| public void testSingleFileFileset() { | public void testSingleFileFileset() { | ||||
| @@ -125,10 +125,9 @@ public class CopyTest extends BuildFileTest { | |||||
| public void testTranscoding() throws IOException { | public void testTranscoding() throws IOException { | ||||
| executeTarget("testTranscoding"); | executeTarget("testTranscoding"); | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| File f1 = getProject().resolveFile("copy/expected/utf-8"); | File f1 = getProject().resolveFile("copy/expected/utf-8"); | ||||
| File f2 = getProject().resolveFile("copytest1.tmp"); | File f2 = getProject().resolveFile("copytest1.tmp"); | ||||
| assertTrue(fileUtils.contentEquals(f1, f2)); | |||||
| assertTrue(FILE_UTILS.contentEquals(f1, f2)); | |||||
| } | } | ||||
| public void testMissingFileIgnore() { | public void testMissingFileIgnore() { | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2003-2004 The Apache Software Foundation. | |||||
| * Copyright 2003-2005 The Apache Software Foundation. | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -23,7 +23,6 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileReader; | import java.io.FileReader; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.OutputStream; | |||||
| import java.util.GregorianCalendar; | import java.util.GregorianCalendar; | ||||
| import junit.framework.ComparisonFailure; | import junit.framework.ComparisonFailure; | ||||
| @@ -39,6 +38,10 @@ public class ExecTaskTest extends BuildFileTest { | |||||
| private static final int MAX_BUILD_TIME = 4000; | private static final int MAX_BUILD_TIME = 4000; | ||||
| private static final int SECURITY_MARGIN = 2000; // wait 2 second extras | private static final int SECURITY_MARGIN = 2000; // wait 2 second extras | ||||
| // the test failed with 100 ms of margin on cvs.apache.org on August 1st, 2003 | // the test failed with 100 ms of margin on cvs.apache.org on August 1st, 2003 | ||||
| /** Utilities used for file operations */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private File logFile; | private File logFile; | ||||
| private MonitoredBuild myBuild = null; | private MonitoredBuild myBuild = null; | ||||
| volatile private boolean buildFinished = false; | volatile private boolean buildFinished = false; | ||||
| @@ -316,7 +319,7 @@ public class ExecTaskTest extends BuildFileTest { | |||||
| return; | return; | ||||
| } | } | ||||
| assertTrue("error with transcoding", | assertTrue("error with transcoding", | ||||
| FileUtils.newFileUtils().contentEquals( | |||||
| FILE_UTILS.contentEquals( | |||||
| getProject().resolveFile("expected/utf-8"), | getProject().resolveFile("expected/utf-8"), | ||||
| getProject().resolveFile("redirector.out"))); | getProject().resolveFile("redirector.out"))); | ||||
| } | } | ||||
| @@ -343,8 +346,7 @@ public class ExecTaskTest extends BuildFileTest { | |||||
| return; | return; | ||||
| } | } | ||||
| myBuild = new MonitoredBuild(new File(System.getProperty("root"), BUILD_FILE), "spawn"); | myBuild = new MonitoredBuild(new File(System.getProperty("root"), BUILD_FILE), "spawn"); | ||||
| FileUtils fileutils = FileUtils.newFileUtils(); | |||||
| logFile = fileutils.createTempFile("spawn","log", project.getBaseDir()); | |||||
| logFile = FILE_UTILS.createTempFile("spawn","log", project.getBaseDir()); | |||||
| // this is guaranteed by FileUtils#createTempFile | // this is guaranteed by FileUtils#createTempFile | ||||
| assertTrue("log file not existing", !logFile.exists()); | assertTrue("log file not existing", !logFile.exists()); | ||||
| // make the spawned process run 4 seconds | // make the spawned process run 4 seconds | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2001,2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -16,7 +16,6 @@ | |||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | |||||
| import org.apache.tools.ant.BuildFileTest; | import org.apache.tools.ant.BuildFileTest; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| @@ -25,6 +24,9 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| */ | */ | ||||
| public class GUnzipTest extends BuildFileTest { | public class GUnzipTest extends BuildFileTest { | ||||
| /** Utilities used for file operations */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| public GUnzipTest(String name) { | public GUnzipTest(String name) { | ||||
| super(name); | super(name); | ||||
| } | } | ||||
| @@ -46,16 +48,14 @@ public class GUnzipTest extends BuildFileTest { | |||||
| } | } | ||||
| public void testRealTest() throws java.io.IOException { | public void testRealTest() throws java.io.IOException { | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| executeTarget("realTest"); | executeTarget("realTest"); | ||||
| assertTrue(fileUtils.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| assertTrue(FILE_UTILS.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| project.resolveFile("asf-logo.gif"))); | project.resolveFile("asf-logo.gif"))); | ||||
| } | } | ||||
| public void testTestGzipTask() throws java.io.IOException { | public void testTestGzipTask() throws java.io.IOException { | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| executeTarget("testGzipTask"); | executeTarget("testGzipTask"); | ||||
| assertTrue(fileUtils.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| assertTrue(FILE_UTILS.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| project.resolveFile("asf-logo.gif"))); | project.resolveFile("asf-logo.gif"))); | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2002,2004 The Apache Software Foundation | |||||
| * Copyright 2002-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -21,7 +21,6 @@ import java.io.File; | |||||
| import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import org.apache.tools.ant.Project; | |||||
| import org.apache.tools.ant.BuildFileTest; | import org.apache.tools.ant.BuildFileTest; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| @@ -31,7 +30,10 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| * | * | ||||
| */ | */ | ||||
| public class InitializeClassTest extends BuildFileTest { | public class InitializeClassTest extends BuildFileTest { | ||||
| /** Utilities used for file operations */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private File f1 = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/forkedout"); | private File f1 = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/forkedout"); | ||||
| private File f2 = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/unforkedout"); | private File f2 = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/unforkedout"); | ||||
| @@ -51,8 +53,7 @@ public class InitializeClassTest extends BuildFileTest { | |||||
| project.executeTarget("unforked"); | project.executeTarget("unforked"); | ||||
| System.setOut(ps); | System.setOut(ps); | ||||
| newps.close(); | newps.close(); | ||||
| FileUtils fu = FileUtils.newFileUtils(); | |||||
| assertTrue("Forked - non-forked mismatch", fu.contentEquals(f1, f2)); | |||||
| assertTrue("Forked - non-forked mismatch", FILE_UTILS.contentEquals(f1, f2)); | |||||
| } | } | ||||
| public void tearDown() { | public void tearDown() { | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -24,18 +24,19 @@ import java.io.InputStream; | |||||
| import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.Reader; | import java.io.Reader; | ||||
| import java.util.Date; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.zip.ZipEntry; | import java.util.zip.ZipEntry; | ||||
| import java.util.zip.ZipFile; | import java.util.zip.ZipFile; | ||||
| import org.apache.tools.ant.BuildFileTest; | import org.apache.tools.ant.BuildFileTest; | ||||
| import org.apache.tools.ant.taskdefs.condition.Os; | |||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| /** | /** | ||||
| */ | */ | ||||
| public class JarTest extends BuildFileTest { | public class JarTest extends BuildFileTest { | ||||
| /** Utilities used for file operations */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private static String tempJar = "tmp.jar"; | private static String tempJar = "tmp.jar"; | ||||
| private static String tempDir = "jartmp/"; | private static String tempDir = "jartmp/"; | ||||
| private Reader r1, r2; | private Reader r1, r2; | ||||
| @@ -125,7 +126,7 @@ public class JarTest extends BuildFileTest { | |||||
| private void testRecreate(String firstTarget, String secondTarget) { | private void testRecreate(String firstTarget, String secondTarget) { | ||||
| executeTarget(firstTarget); | executeTarget(firstTarget); | ||||
| long sleeptime = 3000 | long sleeptime = 3000 | ||||
| + FileUtils.newFileUtils().getFileTimestampGranularity(); | |||||
| + FILE_UTILS.getFileTimestampGranularity(); | |||||
| try { | try { | ||||
| Thread.sleep(sleeptime); | Thread.sleep(sleeptime); | ||||
| } catch (InterruptedException e) { | } catch (InterruptedException e) { | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2001-2004 The Apache Software Foundation | |||||
| * Copyright 2001-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -17,9 +17,13 @@ | |||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import junit.framework.*; | |||||
| import java.io.*; | |||||
| import org.apache.tools.ant.*; | |||||
| import java.io.File; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | |||||
| import java.io.OutputStream; | |||||
| import java.io.OutputStreamWriter; | |||||
| import org.apache.tools.ant.BuildFileTest; | |||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| import org.apache.tools.ant.util.TeeOutputStream; | import org.apache.tools.ant.util.TeeOutputStream; | ||||
| @@ -33,6 +37,9 @@ public class JavaTest extends BuildFileTest { | |||||
| // this time was OK on a Win NT machine and on nagoya | // this time was OK on a Win NT machine and on nagoya | ||||
| private static final int SECURITY_MARGIN = 2000; | private static final int SECURITY_MARGIN = 2000; | ||||
| /** Utilities used for file operations */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private boolean runFatalTests=false; | private boolean runFatalTests=false; | ||||
| public JavaTest(String name) { | public JavaTest(String name) { | ||||
| @@ -167,8 +174,7 @@ public class JavaTest extends BuildFileTest { | |||||
| } | } | ||||
| public void testSpawn() { | public void testSpawn() { | ||||
| FileUtils fileutils = FileUtils.newFileUtils(); | |||||
| File logFile = fileutils.createTempFile("spawn","log", project.getBaseDir()); | |||||
| File logFile = FILE_UTILS.createTempFile("spawn","log", project.getBaseDir()); | |||||
| // this is guaranteed by FileUtils#createTempFile | // this is guaranteed by FileUtils#createTempFile | ||||
| assertTrue("log file not existing", !logFile.exists()); | assertTrue("log file not existing", !logFile.exists()); | ||||
| project.setProperty("logFile", logFile.getAbsolutePath()); | project.setProperty("logFile", logFile.getAbsolutePath()); | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -18,7 +18,6 @@ | |||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import org.apache.tools.ant.BuildFileTest; | import org.apache.tools.ant.BuildFileTest; | ||||
| import org.apache.tools.ant.Project; | |||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| @@ -29,6 +28,9 @@ import java.io.IOException; | |||||
| */ | */ | ||||
| public class MoveTest extends BuildFileTest { | public class MoveTest extends BuildFileTest { | ||||
| /** Utilities used for file operations */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| public MoveTest(String name) { | public MoveTest(String name) { | ||||
| super(name); | super(name); | ||||
| } | } | ||||
| @@ -43,20 +45,18 @@ public class MoveTest extends BuildFileTest { | |||||
| public void testFilterSet() throws IOException { | public void testFilterSet() throws IOException { | ||||
| executeTarget("testFilterSet"); | executeTarget("testFilterSet"); | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| File tmp = new File(getProjectDir(), "move.filterset.tmp"); | File tmp = new File(getProjectDir(), "move.filterset.tmp"); | ||||
| File check = new File(getProjectDir(), "expected/copy.filterset.filtered"); | File check = new File(getProjectDir(), "expected/copy.filterset.filtered"); | ||||
| assertTrue(tmp.exists()); | assertTrue(tmp.exists()); | ||||
| assertTrue(fileUtils.contentEquals(tmp, check)); | |||||
| assertTrue(FILE_UTILS.contentEquals(tmp, check)); | |||||
| } | } | ||||
| public void testFilterChain() throws IOException { | public void testFilterChain() throws IOException { | ||||
| executeTarget("testFilterChain"); | executeTarget("testFilterChain"); | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| File tmp = new File(getProjectDir(), "move.filterchain.tmp"); | File tmp = new File(getProjectDir(), "move.filterchain.tmp"); | ||||
| File check = new File(getProjectDir(), "expected/copy.filterset.filtered"); | File check = new File(getProjectDir(), "expected/copy.filterset.filtered"); | ||||
| assertTrue(tmp.exists()); | assertTrue(tmp.exists()); | ||||
| assertTrue(fileUtils.contentEquals(tmp, check)); | |||||
| assertTrue(FILE_UTILS.contentEquals(tmp, check)); | |||||
| } | } | ||||
| /** Bugzilla Report 11732 */ | /** Bugzilla Report 11732 */ | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2001-2004 The Apache Software Foundation | |||||
| * Copyright 2001-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -17,9 +17,6 @@ | |||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.net.URL; | |||||
| import java.io.File; | |||||
| import org.apache.tools.ant.BuildFileTest; | import org.apache.tools.ant.BuildFileTest; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| @@ -28,6 +25,9 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| */ | */ | ||||
| public class PropertyTest extends BuildFileTest { | public class PropertyTest extends BuildFileTest { | ||||
| /** Utilities used for file operations */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| public PropertyTest(String name) { | public PropertyTest(String name) { | ||||
| super(name); | super(name); | ||||
| } | } | ||||
| @@ -64,7 +64,7 @@ public class PropertyTest extends BuildFileTest { | |||||
| public void test5() { | public void test5() { | ||||
| String baseDir = getProject().getProperty("basedir"); | String baseDir = getProject().getProperty("basedir"); | ||||
| try { | try { | ||||
| String uri = FileUtils.newFileUtils().toURI( | |||||
| String uri = FILE_UTILS.toURI( | |||||
| baseDir + "/property3.properties"); | baseDir + "/property3.properties"); | ||||
| getProject().setNewProperty( | getProject().setNewProperty( | ||||
| "test5.url", uri); | "test5.url", uri); | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2004 The Apache Software Foundation | |||||
| * Copyright 2004-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -29,6 +29,9 @@ public class RecorderTest extends BuildFileTest { | |||||
| private static final String REC_DIR = "recorder-out"; | private static final String REC_DIR = "recorder-out"; | ||||
| /** Utilities used for file operations */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| public RecorderTest(String name) { | public RecorderTest(String name) { | ||||
| super(name); | super(name); | ||||
| } | } | ||||
| @@ -43,9 +46,8 @@ public class RecorderTest extends BuildFileTest { | |||||
| } | } | ||||
| public void testNoAppend() throws IOException { | public void testNoAppend() throws IOException { | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| executeTarget("noappend"); | executeTarget("noappend"); | ||||
| assertTrue(fileUtils | |||||
| assertTrue(FILE_UTILS | |||||
| .contentEquals(project.resolveFile(REC_DIR | .contentEquals(project.resolveFile(REC_DIR | ||||
| + "rectest1.result"), | + "rectest1.result"), | ||||
| project.resolveFile(REC_DIR | project.resolveFile(REC_DIR | ||||
| @@ -53,9 +55,8 @@ public class RecorderTest extends BuildFileTest { | |||||
| } | } | ||||
| public void testAppend() throws IOException { | public void testAppend() throws IOException { | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| executeTarget("append"); | executeTarget("append"); | ||||
| assertTrue(fileUtils | |||||
| assertTrue(FILE_UTILS | |||||
| .contentEquals(project.resolveFile(REC_DIR | .contentEquals(project.resolveFile(REC_DIR | ||||
| + "rectest2.result"), | + "rectest2.result"), | ||||
| project.resolveFile(REC_DIR | project.resolveFile(REC_DIR | ||||
| @@ -63,9 +64,8 @@ public class RecorderTest extends BuildFileTest { | |||||
| } | } | ||||
| public void testRestart() throws IOException { | public void testRestart() throws IOException { | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| executeTarget("restart"); | executeTarget("restart"); | ||||
| assertTrue(fileUtils | |||||
| assertTrue(FILE_UTILS | |||||
| .contentEquals(project.resolveFile(REC_DIR | .contentEquals(project.resolveFile(REC_DIR | ||||
| + "rectest3.result"), | + "rectest3.result"), | ||||
| project.resolveFile(REC_DIR | project.resolveFile(REC_DIR | ||||
| @@ -73,9 +73,8 @@ public class RecorderTest extends BuildFileTest { | |||||
| } | } | ||||
| public void testDeleteRestart() throws IOException { | public void testDeleteRestart() throws IOException { | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| executeTarget("deleterestart"); | executeTarget("deleterestart"); | ||||
| assertTrue(fileUtils | |||||
| assertTrue(FILE_UTILS | |||||
| .contentEquals(project.resolveFile(REC_DIR | .contentEquals(project.resolveFile(REC_DIR | ||||
| + "rectest4.result"), | + "rectest4.result"), | ||||
| project.resolveFile(REC_DIR | project.resolveFile(REC_DIR | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2003-2004 The Apache Software Foundation | |||||
| * Copyright 2003-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -27,6 +27,9 @@ public class TouchTest extends BuildFileTest { | |||||
| private static String TOUCH_FILE = "src/etc/testcases/taskdefs/touchtest"; | private static String TOUCH_FILE = "src/etc/testcases/taskdefs/touchtest"; | ||||
| /** Utilities used for file operations */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| public TouchTest(String name) { | public TouchTest(String name) { | ||||
| super(name); | super(name); | ||||
| } | } | ||||
| @@ -155,7 +158,7 @@ public class TouchTest extends BuildFileTest { | |||||
| * @param time | * @param time | ||||
| */ | */ | ||||
| public void assertTimesNearlyMatch(long timestamp,long time) { | public void assertTimesNearlyMatch(long timestamp,long time) { | ||||
| long granularity= FileUtils.newFileUtils().getFileTimestampGranularity(); | |||||
| long granularity= FILE_UTILS.getFileTimestampGranularity(); | |||||
| assertTimesNearlyMatch(timestamp, time, granularity); | assertTimesNearlyMatch(timestamp, time, granularity); | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2001-2004 The Apache Software Foundation | |||||
| * Copyright 2001-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -24,6 +24,9 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| */ | */ | ||||
| public class UntarTest extends BuildFileTest { | public class UntarTest extends BuildFileTest { | ||||
| /** Utilities used for file operations */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| public UntarTest(String name) { | public UntarTest(String name) { | ||||
| super(name); | super(name); | ||||
| } | } | ||||
| @@ -37,44 +40,38 @@ public class UntarTest extends BuildFileTest { | |||||
| } | } | ||||
| public void testRealTest() throws java.io.IOException { | public void testRealTest() throws java.io.IOException { | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| executeTarget("realTest"); | executeTarget("realTest"); | ||||
| assertTrue(fileUtils.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| assertTrue(FILE_UTILS.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| project.resolveFile("asf-logo.gif"))); | project.resolveFile("asf-logo.gif"))); | ||||
| } | } | ||||
| public void testRealGzipTest() throws java.io.IOException { | public void testRealGzipTest() throws java.io.IOException { | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| executeTarget("realGzipTest"); | executeTarget("realGzipTest"); | ||||
| assertTrue(fileUtils.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| assertTrue(FILE_UTILS.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| project.resolveFile("asf-logo.gif"))); | project.resolveFile("asf-logo.gif"))); | ||||
| } | } | ||||
| public void testRealBzip2Test() throws java.io.IOException { | public void testRealBzip2Test() throws java.io.IOException { | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| executeTarget("realBzip2Test"); | executeTarget("realBzip2Test"); | ||||
| assertTrue(fileUtils.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| assertTrue(FILE_UTILS.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| project.resolveFile("asf-logo.gif"))); | project.resolveFile("asf-logo.gif"))); | ||||
| } | } | ||||
| public void testTestTarTask() throws java.io.IOException { | public void testTestTarTask() throws java.io.IOException { | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| executeTarget("testTarTask"); | executeTarget("testTarTask"); | ||||
| assertTrue(fileUtils.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| assertTrue(FILE_UTILS.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| project.resolveFile("asf-logo.gif"))); | project.resolveFile("asf-logo.gif"))); | ||||
| } | } | ||||
| public void testTestGzipTarTask() throws java.io.IOException { | public void testTestGzipTarTask() throws java.io.IOException { | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| executeTarget("testGzipTarTask"); | executeTarget("testGzipTarTask"); | ||||
| assertTrue(fileUtils.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| assertTrue(FILE_UTILS.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| project.resolveFile("asf-logo.gif"))); | project.resolveFile("asf-logo.gif"))); | ||||
| } | } | ||||
| public void testTestBzip2TarTask() throws java.io.IOException { | public void testTestBzip2TarTask() throws java.io.IOException { | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| executeTarget("testBzip2TarTask"); | executeTarget("testBzip2TarTask"); | ||||
| assertTrue(fileUtils.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| assertTrue(FILE_UTILS.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| project.resolveFile("asf-logo.gif"))); | project.resolveFile("asf-logo.gif"))); | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2000-2001,2003-2004 The Apache Software Foundation | |||||
| * Copyright 2000-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -25,6 +25,9 @@ import java.io.IOException; | |||||
| */ | */ | ||||
| public class UnzipTest extends BuildFileTest { | public class UnzipTest extends BuildFileTest { | ||||
| /** Utilities used for file operations */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| public UnzipTest(String name) { | public UnzipTest(String name) { | ||||
| super(name); | super(name); | ||||
| } | } | ||||
| @@ -60,8 +63,7 @@ public class UnzipTest extends BuildFileTest { | |||||
| * @throws IOException | * @throws IOException | ||||
| */ | */ | ||||
| private void assertLogoUncorrupted() throws IOException { | private void assertLogoUncorrupted() throws IOException { | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| assertTrue(fileUtils.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| assertTrue(FILE_UTILS.contentEquals(project.resolveFile("../asf-logo.gif"), | |||||
| project.resolveFile("asf-logo.gif"))); | project.resolveFile("asf-logo.gif"))); | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2002-2004 The Apache Software Foundation | |||||
| * Copyright 2002-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -34,7 +34,7 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| /** | /** | ||||
| */ | */ | ||||
| public class XmlPropertyTest extends BuildFileTest { | public class XmlPropertyTest extends BuildFileTest { | ||||
| private static FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| public XmlPropertyTest(String name) { | public XmlPropertyTest(String name) { | ||||
| super(name); | super(name); | ||||
| @@ -125,7 +125,7 @@ public class XmlPropertyTest extends BuildFileTest { | |||||
| if ( localRoot ) { | if ( localRoot ) { | ||||
| workingDir = inputFile.getParentFile(); | workingDir = inputFile.getParentFile(); | ||||
| } else { | } else { | ||||
| workingDir = fileUtils.resolveFile(new File("."), "."); | |||||
| workingDir = FILE_UTILS.resolveFile(new File("."), "."); | |||||
| } | } | ||||
| try { | try { | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2001,2004 The Apache Software Foundation | |||||
| * Copyright 2001-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -35,6 +35,8 @@ import org.w3c.dom.Document; | |||||
| */ | */ | ||||
| public abstract class AbstractXSLTLiaisonTest extends TestCase { | public abstract class AbstractXSLTLiaisonTest extends TestCase { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| protected XSLTLiaison liaison; | protected XSLTLiaison liaison; | ||||
| protected AbstractXSLTLiaisonTest(String name){ | protected AbstractXSLTLiaisonTest(String name){ | ||||
| @@ -54,7 +56,7 @@ public abstract class AbstractXSLTLiaisonTest extends TestCase { | |||||
| if (url == null){ | if (url == null){ | ||||
| throw new FileNotFoundException("Unable to load '" + name + "' from classpath"); | throw new FileNotFoundException("Unable to load '" + name + "' from classpath"); | ||||
| } | } | ||||
| return new File(FileUtils.newFileUtils().fromURI(url.toExternalForm())); | |||||
| return new File(FILE_UTILS.fromURI(url.toExternalForm())); | |||||
| } | } | ||||
| /** keep it simple stupid */ | /** keep it simple stupid */ | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2001-2004 The Apache Software Foundation | |||||
| * Copyright 2001-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -31,6 +31,8 @@ import java.io.IOException; | |||||
| */ | */ | ||||
| public class ReplaceRegExpTest extends BuildFileTest { | public class ReplaceRegExpTest extends BuildFileTest { | ||||
| private static final String PROJECT_PATH = "src/etc/testcases/taskdefs/optional"; | private static final String PROJECT_PATH = "src/etc/testcases/taskdefs/optional"; | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| public ReplaceRegExpTest(String name) { | public ReplaceRegExpTest(String name) { | ||||
| super(name); | super(name); | ||||
| } | } | ||||
| @@ -87,7 +89,7 @@ public class ReplaceRegExpTest extends BuildFileTest { | |||||
| public void testDontAddNewline1() throws IOException { | public void testDontAddNewline1() throws IOException { | ||||
| executeTarget("testDontAddNewline1"); | executeTarget("testDontAddNewline1"); | ||||
| assertTrue("Files match", | assertTrue("Files match", | ||||
| FileUtils.newFileUtils() | |||||
| FILE_UTILS | |||||
| .contentEquals(new File(System.getProperty("root"), PROJECT_PATH + "/test.properties"), | .contentEquals(new File(System.getProperty("root"), PROJECT_PATH + "/test.properties"), | ||||
| new File(System.getProperty("root"), PROJECT_PATH + "/replaceregexp2.result.properties"))); | new File(System.getProperty("root"), PROJECT_PATH + "/replaceregexp2.result.properties"))); | ||||
| } | } | ||||
| @@ -95,7 +97,7 @@ public class ReplaceRegExpTest extends BuildFileTest { | |||||
| public void testDontAddNewline2() throws IOException { | public void testDontAddNewline2() throws IOException { | ||||
| executeTarget("testDontAddNewline2"); | executeTarget("testDontAddNewline2"); | ||||
| assertTrue("Files match", | assertTrue("Files match", | ||||
| FileUtils.newFileUtils() | |||||
| FILE_UTILS | |||||
| .contentEquals(new File(System.getProperty("root"), PROJECT_PATH + "/test.properties"), | .contentEquals(new File(System.getProperty("root"), PROJECT_PATH + "/test.properties"), | ||||
| new File(System.getProperty("root"), PROJECT_PATH + "/replaceregexp2.result.properties"))); | new File(System.getProperty("root"), PROJECT_PATH + "/replaceregexp2.result.properties"))); | ||||
| } | } | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2002-2004 The Apache Software Foundation | |||||
| * Copyright 2002-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -19,16 +19,9 @@ package org.apache.tools.ant.taskdefs.optional.image; | |||||
| import org.apache.tools.ant.BuildFileTest; | import org.apache.tools.ant.BuildFileTest; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| import org.apache.tools.ant.taskdefs.condition.Os; | |||||
| import java.io.IOException; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.InputStream; | |||||
| import java.io.BufferedInputStream; | |||||
| import java.io.FileInputStream; | |||||
| import java.io.FileReader; | |||||
| import java.io.BufferedReader; | |||||
| import java.util.Properties; | |||||
| /** | /** | ||||
| * Tests the Image task. | * Tests the Image task. | ||||
| @@ -41,6 +34,8 @@ public class ImageTest extends BuildFileTest { | |||||
| "src/etc/testcases/taskdefs/optional/image/"; | "src/etc/testcases/taskdefs/optional/image/"; | ||||
| private final static String LARGEIMAGE = "largeimage.jpg"; | private final static String LARGEIMAGE = "largeimage.jpg"; | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| public ImageTest(String name) { | public ImageTest(String name) { | ||||
| super(name); | super(name); | ||||
| } | } | ||||
| @@ -73,7 +68,7 @@ public class ImageTest extends BuildFileTest { | |||||
| File f = createRelativeFile("/dest/" + LARGEIMAGE); | File f = createRelativeFile("/dest/" + LARGEIMAGE); | ||||
| long lastModified = f.lastModified(); | long lastModified = f.lastModified(); | ||||
| try { | try { | ||||
| Thread.sleep(FileUtils.newFileUtils() | |||||
| Thread.sleep(FILE_UTILS | |||||
| .getFileTimestampGranularity()); | .getFileTimestampGranularity()); | ||||
| } | } | ||||
| catch (InterruptedException e) {} | catch (InterruptedException e) {} | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2001,2003-2004 The Apache Software Foundation | |||||
| * Copyright 2001-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -38,7 +38,7 @@ import org.w3c.dom.NodeList; | |||||
| */ | */ | ||||
| public class XMLReportTest extends TestCase { | public class XMLReportTest extends TestCase { | ||||
| /** helper for some File/URL connversions */ | /** helper for some File/URL connversions */ | ||||
| private static FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| public XMLReportTest(String s) { | public XMLReportTest(String s) { | ||||
| super(s); | super(s); | ||||
| @@ -49,7 +49,7 @@ public class XMLReportTest extends TestCase { | |||||
| if (url == null) { | if (url == null) { | ||||
| throw new FileNotFoundException("Unable to load '" + name + "' from classpath"); | throw new FileNotFoundException("Unable to load '" + name + "' from classpath"); | ||||
| } | } | ||||
| return new File(fileUtils.fromURI(url.toString())); | |||||
| return new File(FILE_UTILS.fromURI(url.toString())); | |||||
| } | } | ||||
| public void testCreateDocument() throws Exception { | public void testCreateDocument() throws Exception { | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2003-2004 The Apache Software Foundation | |||||
| * Copyright 2003-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -20,7 +20,6 @@ package org.apache.tools.ant.types.selectors; | |||||
| // Java | // Java | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileWriter; | |||||
| import java.util.Comparator; | import java.util.Comparator; | ||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import java.text.RuleBasedCollator; | import java.text.RuleBasedCollator; | ||||
| @@ -38,6 +37,7 @@ import org.apache.tools.ant.BuildEvent; | |||||
| // The classes to test | // The classes to test | ||||
| import org.apache.tools.ant.types.selectors.modifiedselector.*; | import org.apache.tools.ant.types.selectors.modifiedselector.*; | ||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| /** | /** | ||||
| @@ -48,6 +48,8 @@ import org.apache.tools.ant.types.selectors.modifiedselector.*; | |||||
| */ | */ | ||||
| public class ModifiedSelectorTest extends BaseSelectorTest { | public class ModifiedSelectorTest extends BaseSelectorTest { | ||||
| /** Utilities used for file operations */ | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| // ===================== attributes ===================== | // ===================== attributes ===================== | ||||
| @@ -388,8 +390,7 @@ public class ModifiedSelectorTest extends BaseSelectorTest { | |||||
| * configure() method of ModifiedSelector. This testcase tests that. | * configure() method of ModifiedSelector. This testcase tests that. | ||||
| */ | */ | ||||
| public void testCreatePropertiesCacheViaCustomSelector() { | public void testCreatePropertiesCacheViaCustomSelector() { | ||||
| File cachefile = org.apache.tools.ant.util.FileUtils.newFileUtils() | |||||
| .createTempFile("tmp-cache-", ".properties", null); | |||||
| File cachefile = FILE_UTILS.createTempFile("tmp-cache-", ".properties", null); | |||||
| try { | try { | ||||
| // initialize test environment (called "bed") | // initialize test environment (called "bed") | ||||
| makeBed(); | makeBed(); | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2001-2004 The Apache Software Foundation | |||||
| * Copyright 2001-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -17,7 +17,9 @@ | |||||
| package org.apache.tools.ant.util; | package org.apache.tools.ant.util; | ||||
| import java.io.*; | |||||
| import java.io.File; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | |||||
| import junit.framework.TestCase; | import junit.framework.TestCase; | ||||
| @@ -30,7 +32,7 @@ import org.apache.tools.ant.taskdefs.condition.Os; | |||||
| */ | */ | ||||
| public class FileUtilsTest extends TestCase { | public class FileUtilsTest extends TestCase { | ||||
| private FileUtils fu; | |||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| private File removeThis; | private File removeThis; | ||||
| private String root; | private String root; | ||||
| @@ -39,7 +41,6 @@ public class FileUtilsTest extends TestCase { | |||||
| } | } | ||||
| public void setUp() { | public void setUp() { | ||||
| fu = FileUtils.newFileUtils(); | |||||
| // Windows adds the drive letter in uppercase, unless you run Cygwin | // Windows adds the drive letter in uppercase, unless you run Cygwin | ||||
| root = new File(File.separator).getAbsolutePath().toUpperCase(); | root = new File(File.separator).getAbsolutePath().toUpperCase(); | ||||
| } | } | ||||
| @@ -79,7 +80,7 @@ public class FileUtilsTest extends TestCase { | |||||
| fail(ie.getMessage()); | fail(ie.getMessage()); | ||||
| } | } | ||||
| fu.setFileLastModified(removeThis, -1); | |||||
| FILE_UTILS.setFileLastModified(removeThis, -1); | |||||
| long secondModTime = removeThis.lastModified(); | long secondModTime = removeThis.lastModified(); | ||||
| assertTrue(secondModTime > modTime); | assertTrue(secondModTime > modTime); | ||||
| @@ -88,7 +89,7 @@ public class FileUtilsTest extends TestCase { | |||||
| // in a previous version, the date of the file was set to 123456 | // in a previous version, the date of the file was set to 123456 | ||||
| // milliseconds since 01.01.1970 | // milliseconds since 01.01.1970 | ||||
| // it did not work on a computer running JDK 1.4.1_02 + Windows 2000 | // it did not work on a computer running JDK 1.4.1_02 + Windows 2000 | ||||
| fu.setFileLastModified(removeThis, secondModTime + millisperday); | |||||
| FILE_UTILS.setFileLastModified(removeThis, secondModTime + millisperday); | |||||
| long thirdModTime = removeThis.lastModified(); | long thirdModTime = removeThis.lastModified(); | ||||
| /* | /* | ||||
| * I would love to compare this with 123456, but depending on | * I would love to compare this with 123456, but depending on | ||||
| @@ -104,30 +105,30 @@ public class FileUtilsTest extends TestCase { | |||||
| * Start with simple absolute file names. | * Start with simple absolute file names. | ||||
| */ | */ | ||||
| assertEquals(File.separator, | assertEquals(File.separator, | ||||
| fu.resolveFile(null, "/").getPath()); | |||||
| FILE_UTILS.resolveFile(null, "/").getPath()); | |||||
| assertEquals(File.separator, | assertEquals(File.separator, | ||||
| fu.resolveFile(null, "\\").getPath()); | |||||
| FILE_UTILS.resolveFile(null, "\\").getPath()); | |||||
| /* | /* | ||||
| * throw in drive letters | * throw in drive letters | ||||
| */ | */ | ||||
| String driveSpec = "C:"; | String driveSpec = "C:"; | ||||
| assertEquals(driveSpec + "\\", | assertEquals(driveSpec + "\\", | ||||
| fu.resolveFile(null, driveSpec + "/").getPath()); | |||||
| FILE_UTILS.resolveFile(null, driveSpec + "/").getPath()); | |||||
| assertEquals(driveSpec + "\\", | assertEquals(driveSpec + "\\", | ||||
| fu.resolveFile(null, driveSpec + "\\").getPath()); | |||||
| FILE_UTILS.resolveFile(null, driveSpec + "\\").getPath()); | |||||
| String driveSpecLower = "c:"; | String driveSpecLower = "c:"; | ||||
| assertEquals(driveSpec + "\\", | assertEquals(driveSpec + "\\", | ||||
| fu.resolveFile(null, driveSpecLower + "/").getPath()); | |||||
| FILE_UTILS.resolveFile(null, driveSpecLower + "/").getPath()); | |||||
| assertEquals(driveSpec + "\\", | assertEquals(driveSpec + "\\", | ||||
| fu.resolveFile(null, driveSpecLower + "\\").getPath()); | |||||
| FILE_UTILS.resolveFile(null, driveSpecLower + "\\").getPath()); | |||||
| /* | /* | ||||
| * promised to eliminate consecutive slashes after drive letter. | * promised to eliminate consecutive slashes after drive letter. | ||||
| */ | */ | ||||
| assertEquals(driveSpec + "\\", | assertEquals(driveSpec + "\\", | ||||
| fu.resolveFile(null, driveSpec + "/////").getPath()); | |||||
| FILE_UTILS.resolveFile(null, driveSpec + "/////").getPath()); | |||||
| assertEquals(driveSpec + "\\", | assertEquals(driveSpec + "\\", | ||||
| fu.resolveFile(null, driveSpec + "\\\\\\\\\\\\").getPath()); | |||||
| FILE_UTILS.resolveFile(null, driveSpec + "\\\\\\\\\\\\").getPath()); | |||||
| if (Os.isFamily("netware")) { | if (Os.isFamily("netware")) { | ||||
| /* | /* | ||||
| @@ -135,45 +136,45 @@ public class FileUtilsTest extends TestCase { | |||||
| */ | */ | ||||
| driveSpec = "SYS:"; | driveSpec = "SYS:"; | ||||
| assertEquals(driveSpec, | assertEquals(driveSpec, | ||||
| fu.resolveFile(null, driveSpec + "/").getPath()); | |||||
| FILE_UTILS.resolveFile(null, driveSpec + "/").getPath()); | |||||
| assertEquals(driveSpec, | assertEquals(driveSpec, | ||||
| fu.resolveFile(null, driveSpec + "\\").getPath()); | |||||
| FILE_UTILS.resolveFile(null, driveSpec + "\\").getPath()); | |||||
| driveSpecLower = "sys:"; | driveSpecLower = "sys:"; | ||||
| assertEquals(driveSpec, | assertEquals(driveSpec, | ||||
| fu.resolveFile(null, driveSpecLower + "/").getPath()); | |||||
| FILE_UTILS.resolveFile(null, driveSpecLower + "/").getPath()); | |||||
| assertEquals(driveSpec, | assertEquals(driveSpec, | ||||
| fu.resolveFile(null, driveSpecLower + "\\").getPath()); | |||||
| FILE_UTILS.resolveFile(null, driveSpecLower + "\\").getPath()); | |||||
| /* | /* | ||||
| * promised to eliminate consecutive slashes after drive letter. | * promised to eliminate consecutive slashes after drive letter. | ||||
| */ | */ | ||||
| assertEquals(driveSpec, | assertEquals(driveSpec, | ||||
| fu.resolveFile(null, driveSpec + "/////").getPath()); | |||||
| FILE_UTILS.resolveFile(null, driveSpec + "/////").getPath()); | |||||
| assertEquals(driveSpec, | assertEquals(driveSpec, | ||||
| fu.resolveFile(null, driveSpec + "\\\\\\\\\\\\").getPath()); | |||||
| FILE_UTILS.resolveFile(null, driveSpec + "\\\\\\\\\\\\").getPath()); | |||||
| } | } | ||||
| /* | /* | ||||
| * Now test some relative file name magic. | * Now test some relative file name magic. | ||||
| */ | */ | ||||
| assertEquals(localize("/1/2/3/4"), | assertEquals(localize("/1/2/3/4"), | ||||
| fu.resolveFile(new File(localize("/1/2/3")), "4").getPath()); | |||||
| FILE_UTILS.resolveFile(new File(localize("/1/2/3")), "4").getPath()); | |||||
| assertEquals(localize("/1/2/3/4"), | assertEquals(localize("/1/2/3/4"), | ||||
| fu.resolveFile(new File(localize("/1/2/3")), "./4").getPath()); | |||||
| FILE_UTILS.resolveFile(new File(localize("/1/2/3")), "./4").getPath()); | |||||
| assertEquals(localize("/1/2/3/4"), | assertEquals(localize("/1/2/3/4"), | ||||
| fu.resolveFile(new File(localize("/1/2/3")), ".\\4").getPath()); | |||||
| FILE_UTILS.resolveFile(new File(localize("/1/2/3")), ".\\4").getPath()); | |||||
| assertEquals(localize("/1/2/3/4"), | assertEquals(localize("/1/2/3/4"), | ||||
| fu.resolveFile(new File(localize("/1/2/3")), "./.\\4").getPath()); | |||||
| FILE_UTILS.resolveFile(new File(localize("/1/2/3")), "./.\\4").getPath()); | |||||
| assertEquals(localize("/1/2/3/4"), | assertEquals(localize("/1/2/3/4"), | ||||
| fu.resolveFile(new File(localize("/1/2/3")), "../3/4").getPath()); | |||||
| FILE_UTILS.resolveFile(new File(localize("/1/2/3")), "../3/4").getPath()); | |||||
| assertEquals(localize("/1/2/3/4"), | assertEquals(localize("/1/2/3/4"), | ||||
| fu.resolveFile(new File(localize("/1/2/3")), "..\\3\\4").getPath()); | |||||
| FILE_UTILS.resolveFile(new File(localize("/1/2/3")), "..\\3\\4").getPath()); | |||||
| assertEquals(localize("/1/2/3/4"), | assertEquals(localize("/1/2/3/4"), | ||||
| fu.resolveFile(new File(localize("/1/2/3")), "../../5/.././2/./3/6/../4").getPath()); | |||||
| FILE_UTILS.resolveFile(new File(localize("/1/2/3")), "../../5/.././2/./3/6/../4").getPath()); | |||||
| assertEquals(localize("/1/2/3/4"), | assertEquals(localize("/1/2/3/4"), | ||||
| fu.resolveFile(new File(localize("/1/2/3")), "..\\../5/..\\./2/./3/6\\../4").getPath()); | |||||
| FILE_UTILS.resolveFile(new File(localize("/1/2/3")), "..\\../5/..\\./2/./3/6\\../4").getPath()); | |||||
| try { | try { | ||||
| fu.resolveFile(new File(localize("/1")), "../../b"); | |||||
| FILE_UTILS.resolveFile(new File(localize("/1")), "../../b"); | |||||
| fail("successfully crawled beyond the filesystem root"); | fail("successfully crawled beyond the filesystem root"); | ||||
| } catch (BuildException e) { | } catch (BuildException e) { | ||||
| // Expected Exception caught | // Expected Exception caught | ||||
| @@ -186,32 +187,32 @@ public class FileUtilsTest extends TestCase { | |||||
| * Start with simple absolute file names. | * Start with simple absolute file names. | ||||
| */ | */ | ||||
| assertEquals(File.separator, | assertEquals(File.separator, | ||||
| fu.normalize("/").getPath()); | |||||
| FILE_UTILS.normalize("/").getPath()); | |||||
| assertEquals(File.separator, | assertEquals(File.separator, | ||||
| fu.normalize("\\").getPath()); | |||||
| FILE_UTILS.normalize("\\").getPath()); | |||||
| /* | /* | ||||
| * throw in drive letters | * throw in drive letters | ||||
| */ | */ | ||||
| String driveSpec = "C:"; | String driveSpec = "C:"; | ||||
| assertEquals(driveSpec, | assertEquals(driveSpec, | ||||
| fu.normalize(driveSpec).getPath()); | |||||
| FILE_UTILS.normalize(driveSpec).getPath()); | |||||
| assertEquals(driveSpec + "\\", | assertEquals(driveSpec + "\\", | ||||
| fu.normalize(driveSpec + "/").getPath()); | |||||
| FILE_UTILS.normalize(driveSpec + "/").getPath()); | |||||
| assertEquals(driveSpec + "\\", | assertEquals(driveSpec + "\\", | ||||
| fu.normalize(driveSpec + "\\").getPath()); | |||||
| FILE_UTILS.normalize(driveSpec + "\\").getPath()); | |||||
| String driveSpecLower = "c:"; | String driveSpecLower = "c:"; | ||||
| assertEquals(driveSpec + "\\", | assertEquals(driveSpec + "\\", | ||||
| fu.normalize(driveSpecLower + "/").getPath()); | |||||
| FILE_UTILS.normalize(driveSpecLower + "/").getPath()); | |||||
| assertEquals(driveSpec + "\\", | assertEquals(driveSpec + "\\", | ||||
| fu.normalize(driveSpecLower + "\\").getPath()); | |||||
| FILE_UTILS.normalize(driveSpecLower + "\\").getPath()); | |||||
| /* | /* | ||||
| * promised to eliminate consecutive slashes after drive letter. | * promised to eliminate consecutive slashes after drive letter. | ||||
| */ | */ | ||||
| assertEquals(driveSpec + "\\", | assertEquals(driveSpec + "\\", | ||||
| fu.normalize(driveSpec + "/////").getPath()); | |||||
| FILE_UTILS.normalize(driveSpec + "/////").getPath()); | |||||
| assertEquals(driveSpec + "\\", | assertEquals(driveSpec + "\\", | ||||
| fu.normalize(driveSpec + "\\\\\\\\\\\\").getPath()); | |||||
| FILE_UTILS.normalize(driveSpec + "\\\\\\\\\\\\").getPath()); | |||||
| if (Os.isFamily("netware")) { | if (Os.isFamily("netware")) { | ||||
| /* | /* | ||||
| @@ -219,58 +220,58 @@ public class FileUtilsTest extends TestCase { | |||||
| */ | */ | ||||
| driveSpec = "SYS:"; | driveSpec = "SYS:"; | ||||
| assertEquals(driveSpec, | assertEquals(driveSpec, | ||||
| fu.normalize(driveSpec).getPath()); | |||||
| FILE_UTILS.normalize(driveSpec).getPath()); | |||||
| assertEquals(driveSpec, | assertEquals(driveSpec, | ||||
| fu.normalize(driveSpec + "/").getPath()); | |||||
| FILE_UTILS.normalize(driveSpec + "/").getPath()); | |||||
| assertEquals(driveSpec, | assertEquals(driveSpec, | ||||
| fu.normalize(driveSpec + "\\").getPath()); | |||||
| FILE_UTILS.normalize(driveSpec + "\\").getPath()); | |||||
| driveSpecLower = "sys:"; | driveSpecLower = "sys:"; | ||||
| assertEquals(driveSpec, | assertEquals(driveSpec, | ||||
| fu.normalize(driveSpecLower).getPath()); | |||||
| FILE_UTILS.normalize(driveSpecLower).getPath()); | |||||
| assertEquals(driveSpec, | assertEquals(driveSpec, | ||||
| fu.normalize(driveSpecLower + "/").getPath()); | |||||
| FILE_UTILS.normalize(driveSpecLower + "/").getPath()); | |||||
| assertEquals(driveSpec, | assertEquals(driveSpec, | ||||
| fu.normalize(driveSpecLower + "\\").getPath()); | |||||
| FILE_UTILS.normalize(driveSpecLower + "\\").getPath()); | |||||
| assertEquals(driveSpec + "\\junk", | assertEquals(driveSpec + "\\junk", | ||||
| fu.normalize(driveSpecLower + "\\junk").getPath()); | |||||
| FILE_UTILS.normalize(driveSpecLower + "\\junk").getPath()); | |||||
| /* | /* | ||||
| * promised to eliminate consecutive slashes after drive letter. | * promised to eliminate consecutive slashes after drive letter. | ||||
| */ | */ | ||||
| assertEquals(driveSpec, | assertEquals(driveSpec, | ||||
| fu.normalize(driveSpec + "/////").getPath()); | |||||
| FILE_UTILS.normalize(driveSpec + "/////").getPath()); | |||||
| assertEquals(driveSpec, | assertEquals(driveSpec, | ||||
| fu.normalize(driveSpec + "\\\\\\\\\\\\").getPath()); | |||||
| FILE_UTILS.normalize(driveSpec + "\\\\\\\\\\\\").getPath()); | |||||
| } | } | ||||
| /* | /* | ||||
| * Now test some relative file name magic. | * Now test some relative file name magic. | ||||
| */ | */ | ||||
| assertEquals(localize("/1/2/3/4"), | assertEquals(localize("/1/2/3/4"), | ||||
| fu.normalize(localize("/1/2/3/4")).getPath()); | |||||
| FILE_UTILS.normalize(localize("/1/2/3/4")).getPath()); | |||||
| assertEquals(localize("/1/2/3/4"), | assertEquals(localize("/1/2/3/4"), | ||||
| fu.normalize(localize("/1/2/3/./4")).getPath()); | |||||
| FILE_UTILS.normalize(localize("/1/2/3/./4")).getPath()); | |||||
| assertEquals(localize("/1/2/3/4"), | assertEquals(localize("/1/2/3/4"), | ||||
| fu.normalize(localize("/1/2/3/.\\4")).getPath()); | |||||
| FILE_UTILS.normalize(localize("/1/2/3/.\\4")).getPath()); | |||||
| assertEquals(localize("/1/2/3/4"), | assertEquals(localize("/1/2/3/4"), | ||||
| fu.normalize(localize("/1/2/3/./.\\4")).getPath()); | |||||
| FILE_UTILS.normalize(localize("/1/2/3/./.\\4")).getPath()); | |||||
| assertEquals(localize("/1/2/3/4"), | assertEquals(localize("/1/2/3/4"), | ||||
| fu.normalize(localize("/1/2/3/../3/4")).getPath()); | |||||
| FILE_UTILS.normalize(localize("/1/2/3/../3/4")).getPath()); | |||||
| assertEquals(localize("/1/2/3/4"), | assertEquals(localize("/1/2/3/4"), | ||||
| fu.normalize(localize("/1/2/3/..\\3\\4")).getPath()); | |||||
| FILE_UTILS.normalize(localize("/1/2/3/..\\3\\4")).getPath()); | |||||
| assertEquals(localize("/1/2/3/4"), | assertEquals(localize("/1/2/3/4"), | ||||
| fu.normalize(localize("/1/2/3/../../5/.././2/./3/6/../4")).getPath()); | |||||
| FILE_UTILS.normalize(localize("/1/2/3/../../5/.././2/./3/6/../4")).getPath()); | |||||
| assertEquals(localize("/1/2/3/4"), | assertEquals(localize("/1/2/3/4"), | ||||
| fu.normalize(localize("/1/2/3/..\\../5/..\\./2/./3/6\\../4")).getPath()); | |||||
| FILE_UTILS.normalize(localize("/1/2/3/..\\../5/..\\./2/./3/6\\../4")).getPath()); | |||||
| try { | try { | ||||
| fu.normalize("foo"); | |||||
| FILE_UTILS.normalize("foo"); | |||||
| fail("foo is not an absolute path"); | fail("foo is not an absolute path"); | ||||
| } catch (BuildException e) { | } catch (BuildException e) { | ||||
| // Expected exception caught | // Expected exception caught | ||||
| } | } | ||||
| try { | try { | ||||
| fu.normalize(localize("/1/../../b")); | |||||
| FILE_UTILS.normalize(localize("/1/../../b")); | |||||
| fail("successfully crawled beyond the filesystem root"); | fail("successfully crawled beyond the filesystem root"); | ||||
| } catch (BuildException e) { | } catch (BuildException e) { | ||||
| // Expected exception caught | // Expected exception caught | ||||
| @@ -282,13 +283,13 @@ public class FileUtilsTest extends TestCase { | |||||
| */ | */ | ||||
| public void testNullArgs() { | public void testNullArgs() { | ||||
| try { | try { | ||||
| fu.normalize(null); | |||||
| FILE_UTILS.normalize(null); | |||||
| fail("successfully normalized a null-file"); | fail("successfully normalized a null-file"); | ||||
| } catch (NullPointerException npe) { | } catch (NullPointerException npe) { | ||||
| // Expected exception caught | // Expected exception caught | ||||
| } | } | ||||
| File f = fu.resolveFile(null, "a"); | |||||
| File f = FILE_UTILS.resolveFile(null, "a"); | |||||
| assertEquals(f, new File("a")); | assertEquals(f, new File("a")); | ||||
| } | } | ||||
| @@ -297,7 +298,7 @@ public class FileUtilsTest extends TestCase { | |||||
| */ | */ | ||||
| public void testCreateTempFile() { | public void testCreateTempFile() { | ||||
| File parent = new File((new File("/tmp")).getAbsolutePath()); | File parent = new File((new File("/tmp")).getAbsolutePath()); | ||||
| File tmp1 = fu.createTempFile("pre", ".suf", parent); | |||||
| File tmp1 = FILE_UTILS.createTempFile("pre", ".suf", parent); | |||||
| assertTrue("new file", !tmp1.exists()); | assertTrue("new file", !tmp1.exists()); | ||||
| String name = tmp1.getName(); | String name = tmp1.getName(); | ||||
| @@ -307,12 +308,12 @@ public class FileUtilsTest extends TestCase { | |||||
| parent.getAbsolutePath(), | parent.getAbsolutePath(), | ||||
| tmp1.getParent()); | tmp1.getParent()); | ||||
| File tmp2 = fu.createTempFile("pre", ".suf", parent); | |||||
| File tmp2 = FILE_UTILS.createTempFile("pre", ".suf", parent); | |||||
| assertTrue("files are different", | assertTrue("files are different", | ||||
| !tmp1.getAbsolutePath().equals(tmp2.getAbsolutePath())); | !tmp1.getAbsolutePath().equals(tmp2.getAbsolutePath())); | ||||
| // null parent dir | // null parent dir | ||||
| File tmp3 = fu.createTempFile("pre", ".suf", null); | |||||
| File tmp3 = FILE_UTILS.createTempFile("pre", ".suf", null); | |||||
| String tmploc = System.getProperty("java.io.tmpdir"); | String tmploc = System.getProperty("java.io.tmpdir"); | ||||
| assertEquals((new File(tmploc, tmp3.getName())).getAbsolutePath(), | assertEquals((new File(tmploc, tmp3.getName())).getAbsolutePath(), | ||||
| tmp3.getAbsolutePath()); | tmp3.getAbsolutePath()); | ||||
| @@ -322,17 +323,17 @@ public class FileUtilsTest extends TestCase { | |||||
| * Test contentEquals | * Test contentEquals | ||||
| */ | */ | ||||
| public void testContentEquals() throws IOException { | public void testContentEquals() throws IOException { | ||||
| assertTrue("Non existing files", fu.contentEquals(new File(System.getProperty("root"), "foo"), | |||||
| assertTrue("Non existing files", FILE_UTILS.contentEquals(new File(System.getProperty("root"), "foo"), | |||||
| new File(System.getProperty("root"), "bar"))); | new File(System.getProperty("root"), "bar"))); | ||||
| assertTrue("One exists, the other one doesn\'t", | assertTrue("One exists, the other one doesn\'t", | ||||
| !fu.contentEquals(new File(System.getProperty("root"), "foo"), new File(System.getProperty("root"), "build.xml"))); | |||||
| !FILE_UTILS.contentEquals(new File(System.getProperty("root"), "foo"), new File(System.getProperty("root"), "build.xml"))); | |||||
| assertTrue("Don\'t compare directories", | assertTrue("Don\'t compare directories", | ||||
| !fu.contentEquals(new File(System.getProperty("root"), "src"), new File(System.getProperty("root"), "src"))); | |||||
| !FILE_UTILS.contentEquals(new File(System.getProperty("root"), "src"), new File(System.getProperty("root"), "src"))); | |||||
| assertTrue("File equals itself", | assertTrue("File equals itself", | ||||
| fu.contentEquals(new File(System.getProperty("root"), "build.xml"), | |||||
| FILE_UTILS.contentEquals(new File(System.getProperty("root"), "build.xml"), | |||||
| new File(System.getProperty("root"), "build.xml"))); | new File(System.getProperty("root"), "build.xml"))); | ||||
| assertTrue("Files are different", | assertTrue("Files are different", | ||||
| !fu.contentEquals(new File(System.getProperty("root"), "build.xml"), | |||||
| !FILE_UTILS.contentEquals(new File(System.getProperty("root"), "build.xml"), | |||||
| new File(System.getProperty("root"), "docs.xml"))); | new File(System.getProperty("root"), "docs.xml"))); | ||||
| } | } | ||||
| @@ -342,7 +343,7 @@ public class FileUtilsTest extends TestCase { | |||||
| public void testCreateNewFile() throws IOException { | public void testCreateNewFile() throws IOException { | ||||
| removeThis = new File("dummy"); | removeThis = new File("dummy"); | ||||
| assertTrue(!removeThis.exists()); | assertTrue(!removeThis.exists()); | ||||
| fu.createNewFile(removeThis); | |||||
| FILE_UTILS.createNewFile(removeThis); | |||||
| assertTrue(removeThis.exists()); | assertTrue(removeThis.exists()); | ||||
| } | } | ||||
| @@ -350,43 +351,43 @@ public class FileUtilsTest extends TestCase { | |||||
| * Test removeLeadingPath. | * Test removeLeadingPath. | ||||
| */ | */ | ||||
| public void testRemoveLeadingPath() { | public void testRemoveLeadingPath() { | ||||
| assertEquals("bar", fu.removeLeadingPath(new File("/foo"), | |||||
| assertEquals("bar", FILE_UTILS.removeLeadingPath(new File("/foo"), | |||||
| new File("/foo/bar"))); | new File("/foo/bar"))); | ||||
| assertEquals("bar", fu.removeLeadingPath(new File("/foo/"), | |||||
| assertEquals("bar", FILE_UTILS.removeLeadingPath(new File("/foo/"), | |||||
| new File("/foo/bar"))); | new File("/foo/bar"))); | ||||
| assertEquals("bar", fu.removeLeadingPath(new File("\\foo"), | |||||
| assertEquals("bar", FILE_UTILS.removeLeadingPath(new File("\\foo"), | |||||
| new File("\\foo\\bar"))); | new File("\\foo\\bar"))); | ||||
| assertEquals("bar", fu.removeLeadingPath(new File("\\foo\\"), | |||||
| assertEquals("bar", FILE_UTILS.removeLeadingPath(new File("\\foo\\"), | |||||
| new File("\\foo\\bar"))); | new File("\\foo\\bar"))); | ||||
| assertEquals("bar", fu.removeLeadingPath(new File("c:/foo"), | |||||
| assertEquals("bar", FILE_UTILS.removeLeadingPath(new File("c:/foo"), | |||||
| new File("c:/foo/bar"))); | new File("c:/foo/bar"))); | ||||
| assertEquals("bar", fu.removeLeadingPath(new File("c:/foo/"), | |||||
| assertEquals("bar", FILE_UTILS.removeLeadingPath(new File("c:/foo/"), | |||||
| new File("c:/foo/bar"))); | new File("c:/foo/bar"))); | ||||
| assertEquals("bar", fu.removeLeadingPath(new File("c:\\foo"), | |||||
| assertEquals("bar", FILE_UTILS.removeLeadingPath(new File("c:\\foo"), | |||||
| new File("c:\\foo\\bar"))); | new File("c:\\foo\\bar"))); | ||||
| assertEquals("bar", fu.removeLeadingPath(new File("c:\\foo\\"), | |||||
| assertEquals("bar", FILE_UTILS.removeLeadingPath(new File("c:\\foo\\"), | |||||
| new File("c:\\foo\\bar"))); | new File("c:\\foo\\bar"))); | ||||
| assertEqualsIgnoreDriveCase(fu.normalize("/bar").getAbsolutePath(), | |||||
| fu.removeLeadingPath(new File("/foo"), new File("/bar"))); | |||||
| assertEqualsIgnoreDriveCase(fu.normalize("/foobar").getAbsolutePath(), | |||||
| fu.removeLeadingPath(new File("/foo"), new File("/foobar"))); | |||||
| assertEqualsIgnoreDriveCase(FILE_UTILS.normalize("/bar").getAbsolutePath(), | |||||
| FILE_UTILS.removeLeadingPath(new File("/foo"), new File("/bar"))); | |||||
| assertEqualsIgnoreDriveCase(FILE_UTILS.normalize("/foobar").getAbsolutePath(), | |||||
| FILE_UTILS.removeLeadingPath(new File("/foo"), new File("/foobar"))); | |||||
| // bugzilla report 19979 | // bugzilla report 19979 | ||||
| assertEquals("", fu.removeLeadingPath(new File("/foo/bar"), | |||||
| assertEquals("", FILE_UTILS.removeLeadingPath(new File("/foo/bar"), | |||||
| new File("/foo/bar"))); | new File("/foo/bar"))); | ||||
| assertEquals("", fu.removeLeadingPath(new File("/foo/bar"), | |||||
| assertEquals("", FILE_UTILS.removeLeadingPath(new File("/foo/bar"), | |||||
| new File("/foo/bar/"))); | new File("/foo/bar/"))); | ||||
| assertEquals("", fu.removeLeadingPath(new File("/foo/bar/"), | |||||
| assertEquals("", FILE_UTILS.removeLeadingPath(new File("/foo/bar/"), | |||||
| new File("/foo/bar/"))); | new File("/foo/bar/"))); | ||||
| assertEquals("", fu.removeLeadingPath(new File("/foo/bar/"), | |||||
| assertEquals("", FILE_UTILS.removeLeadingPath(new File("/foo/bar/"), | |||||
| new File("/foo/bar"))); | new File("/foo/bar"))); | ||||
| String expected = "foo/bar".replace('\\', File.separatorChar) | String expected = "foo/bar".replace('\\', File.separatorChar) | ||||
| .replace('/', File.separatorChar); | .replace('/', File.separatorChar); | ||||
| assertEquals(expected, fu.removeLeadingPath(new File("/"), | |||||
| assertEquals(expected, FILE_UTILS.removeLeadingPath(new File("/"), | |||||
| new File("/foo/bar"))); | new File("/foo/bar"))); | ||||
| assertEquals(expected, fu.removeLeadingPath(new File("c:/"), | |||||
| assertEquals(expected, FILE_UTILS.removeLeadingPath(new File("c:/"), | |||||
| new File("c:/foo/bar"))); | new File("c:/foo/bar"))); | ||||
| assertEquals(expected, fu.removeLeadingPath(new File("c:\\"), | |||||
| assertEquals(expected, FILE_UTILS.removeLeadingPath(new File("c:\\"), | |||||
| new File("c:\\foo\\bar"))); | new File("c:\\foo\\bar"))); | ||||
| } | } | ||||
| @@ -403,24 +404,24 @@ public class FileUtilsTest extends TestCase { | |||||
| dosRoot = ""; | dosRoot = ""; | ||||
| } | } | ||||
| if (Os.isFamily("dos")) { | if (Os.isFamily("dos")) { | ||||
| assertEquals("file:///C:/foo", fu.toURI("c:\\foo")); | |||||
| assertEquals("file:///C:/foo", FILE_UTILS.toURI("c:\\foo")); | |||||
| } | } | ||||
| if (Os.isFamily("netware")) { | if (Os.isFamily("netware")) { | ||||
| assertEquals("file:///SYS:/foo", fu.toURI("sys:\\foo")); | |||||
| assertEquals("file:///SYS:/foo", FILE_UTILS.toURI("sys:\\foo")); | |||||
| } | } | ||||
| assertEquals("file:///" + dosRoot + "foo", fu.toURI("/foo")); | |||||
| assertEquals("file:///" + dosRoot + "foo", FILE_UTILS.toURI("/foo")); | |||||
| /* May fail if the directory ${user.dir}/foo/ exists | /* May fail if the directory ${user.dir}/foo/ exists | ||||
| * (and anyway is the tested behavior actually desirable?): | * (and anyway is the tested behavior actually desirable?): | ||||
| assertEquals("file:./foo", fu.toURI("./foo")); | assertEquals("file:./foo", fu.toURI("./foo")); | ||||
| */ | */ | ||||
| assertEquals("file:///" + dosRoot + "foo", fu.toURI("\\foo")); | |||||
| assertEquals("file:///" + dosRoot + "foo", FILE_UTILS.toURI("\\foo")); | |||||
| /* See above: | /* See above: | ||||
| assertEquals("file:./foo", fu.toURI(".\\foo")); | assertEquals("file:./foo", fu.toURI(".\\foo")); | ||||
| */ | */ | ||||
| assertEquals("file:///" + dosRoot + "foo%20bar", fu.toURI("/foo bar")); | |||||
| assertEquals("file:///" + dosRoot + "foo%20bar", fu.toURI("\\foo bar")); | |||||
| assertEquals("file:///" + dosRoot + "foo%23bar", fu.toURI("/foo#bar")); | |||||
| assertEquals("file:///" + dosRoot + "foo%23bar", fu.toURI("\\foo#bar")); | |||||
| assertEquals("file:///" + dosRoot + "foo%20bar", FILE_UTILS.toURI("/foo bar")); | |||||
| assertEquals("file:///" + dosRoot + "foo%20bar", FILE_UTILS.toURI("\\foo bar")); | |||||
| assertEquals("file:///" + dosRoot + "foo%23bar", FILE_UTILS.toURI("/foo#bar")); | |||||
| assertEquals("file:///" + dosRoot + "foo%23bar", FILE_UTILS.toURI("\\foo#bar")); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -428,16 +429,16 @@ public class FileUtilsTest extends TestCase { | |||||
| */ | */ | ||||
| public void testFromURI() { | public void testFromURI() { | ||||
| if (Os.isFamily("netware")) { | if (Os.isFamily("netware")) { | ||||
| assertEqualsIgnoreDriveCase("SYS:\\foo", fu.fromURI("file:///sys:/foo")); | |||||
| assertEqualsIgnoreDriveCase("SYS:\\foo", FILE_UTILS.fromURI("file:///sys:/foo")); | |||||
| } | } | ||||
| if (Os.isFamily("dos")) { | if (Os.isFamily("dos")) { | ||||
| assertEqualsIgnoreDriveCase("C:\\foo", fu.fromURI("file:///c:/foo")); | |||||
| assertEqualsIgnoreDriveCase("C:\\foo", FILE_UTILS.fromURI("file:///c:/foo")); | |||||
| } | } | ||||
| assertEqualsIgnoreDriveCase(localize("/foo"), fu.fromURI("file:///foo")); | |||||
| assertEqualsIgnoreDriveCase(localize("/foo"), FILE_UTILS.fromURI("file:///foo")); | |||||
| assertEquals("." + File.separator + "foo", | assertEquals("." + File.separator + "foo", | ||||
| fu.fromURI("file:./foo")); | |||||
| assertEqualsIgnoreDriveCase(localize("/foo bar"), fu.fromURI("file:///foo%20bar")); | |||||
| assertEqualsIgnoreDriveCase(localize("/foo#bar"), fu.fromURI("file:///foo%23bar")); | |||||
| FILE_UTILS.fromURI("file:./foo")); | |||||
| assertEqualsIgnoreDriveCase(localize("/foo bar"), FILE_UTILS.fromURI("file:///foo%20bar")); | |||||
| assertEqualsIgnoreDriveCase(localize("/foo#bar"), FILE_UTILS.fromURI("file:///foo%23bar")); | |||||
| } | } | ||||
| public void testModificationTests() { | public void testModificationTests() { | ||||
| @@ -453,13 +454,13 @@ public class FileUtilsTest extends TestCase { | |||||
| //check that older is up to date with a newer dest | //check that older is up to date with a newer dest | ||||
| assertTrue("older source files are up to date", | assertTrue("older source files are up to date", | ||||
| fu.isUpToDate(firstTime,secondTime)); | |||||
| FILE_UTILS.isUpToDate(firstTime,secondTime)); | |||||
| //check that older is up to date with a newer dest | //check that older is up to date with a newer dest | ||||
| assertFalse("newer source files are no up to date", | assertFalse("newer source files are no up to date", | ||||
| fu.isUpToDate(secondTime, firstTime)); | |||||
| FILE_UTILS.isUpToDate(secondTime, firstTime)); | |||||
| assertTrue("-1 dest timestamp implies nonexistence", | assertTrue("-1 dest timestamp implies nonexistence", | ||||
| !fu.isUpToDate(firstTime,-1L)); | |||||
| !FILE_UTILS.isUpToDate(firstTime,-1L)); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -1,5 +1,5 @@ | |||||
| /* | /* | ||||
| * Copyright 2002,2004 The Apache Software Foundation | |||||
| * Copyright 2002-2005 The Apache Software Foundation | |||||
| * | * | ||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| * you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
| @@ -28,6 +28,9 @@ import org.apache.tools.ant.taskdefs.condition.Os; | |||||
| * | * | ||||
| */ | */ | ||||
| public class JavaEnvUtilsTest extends TestCase { | public class JavaEnvUtilsTest extends TestCase { | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||||
| public JavaEnvUtilsTest(String s) { | public JavaEnvUtilsTest(String s) { | ||||
| super(s); | super(s); | ||||
| } | } | ||||
| @@ -43,9 +46,8 @@ public class JavaEnvUtilsTest extends TestCase { | |||||
| public void testGetExecutableWindows() { | public void testGetExecutableWindows() { | ||||
| if (Os.isFamily("windows")) { | if (Os.isFamily("windows")) { | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| String javaHome = | String javaHome = | ||||
| fileUtils.normalize(System.getProperty("java.home")) | |||||
| FILE_UTILS.normalize(System.getProperty("java.home")) | |||||
| .getAbsolutePath(); | .getAbsolutePath(); | ||||
| String j = JavaEnvUtils.getJreExecutable("java"); | String j = JavaEnvUtils.getJreExecutable("java"); | ||||
| @@ -64,7 +66,7 @@ public class JavaEnvUtilsTest extends TestCase { | |||||
| try { | try { | ||||
| assertTrue(j+" is absolute", (new File(j)).isAbsolute()); | assertTrue(j+" is absolute", (new File(j)).isAbsolute()); | ||||
| String javaHomeParent = | String javaHomeParent = | ||||
| fileUtils.normalize(javaHome+"/..").getAbsolutePath(); | |||||
| FILE_UTILS.normalize(javaHome+"/..").getAbsolutePath(); | |||||
| assertTrue(j+" is normalized and in the JDK dir", | assertTrue(j+" is normalized and in the JDK dir", | ||||
| j.startsWith(javaHomeParent)); | j.startsWith(javaHomeParent)); | ||||
| @@ -89,9 +91,8 @@ public class JavaEnvUtilsTest extends TestCase { | |||||
| public void testGetExecutableMostPlatforms() { | public void testGetExecutableMostPlatforms() { | ||||
| if (!Os.isName("netware") && !Os.isFamily("windows")) { | if (!Os.isName("netware") && !Os.isFamily("windows")) { | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||||
| String javaHome = | String javaHome = | ||||
| fileUtils.normalize(System.getProperty("java.home")) | |||||
| FILE_UTILS.normalize(System.getProperty("java.home")) | |||||
| .getAbsolutePath(); | .getAbsolutePath(); | ||||
| // could still be OS/2 | // could still be OS/2 | ||||
| @@ -112,7 +113,7 @@ public class JavaEnvUtilsTest extends TestCase { | |||||
| assertTrue(j+" is absolute", (new File(j)).isAbsolute()); | assertTrue(j+" is absolute", (new File(j)).isAbsolute()); | ||||
| String javaHomeParent = | String javaHomeParent = | ||||
| fileUtils.normalize(javaHome+"/..").getAbsolutePath(); | |||||
| FILE_UTILS.normalize(javaHome+"/..").getAbsolutePath(); | |||||
| assertTrue(j+" is normalized and in the JDK dir", | assertTrue(j+" is normalized and in the JDK dir", | ||||
| j.startsWith(javaHomeParent)); | j.startsWith(javaHomeParent)); | ||||