Modified: ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java URL: http://svn.apache.org/viewvc/ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java?rev=953741&r1=953740&r2=953741&view=diff ============================================================================== --- ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java (original) +++ ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/taskdefs/email/MimeMailer.java Fri Jun 11 15:50:09 2010 @@ -157,6 +157,10 @@ public class MimeMailer extends Mailer { // SMTP provider props.put("mail.smtp.socketFactory.class", SSL_FACTORY); props.put("mail.smtp.socketFactory.fallback", "false"); + if (isPortExplicitlySpecified()) { + props.put("mail.smtp.socketFactory.port", + String.valueOf(port)); + } } if (user != null || password != null) { props.put("mail.smtp.auth", "true");
Modified: ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java URL: http://svn.apache.org/viewvc/ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java?rev=953741&r1=953740&r2=953741&view=diff ============================================================================== --- ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java (original) +++ ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java Fri Jun 11 15:50:09 2010 @@ -887,7 +887,7 @@ public class JUnitTask extends Task { FILE_UTILS.close(writer); try { - casesFile.delete(); + FILE_UTILS.tryHardToDelete(casesFile); } catch (Exception e) { log(e.toString(), Project.MSG_ERR); } @@ -988,7 +988,7 @@ public class JUnitTask extends Task { props.store(outstream, "Ant JUnitTask generated properties file"); outstream.close(); } catch (java.io.IOException e) { - propsFile.delete(); + FILE_UTILS.tryHardToDelete(propsFile); throw new BuildException("Error creating temporary properties " + "file.", e, getLocation()); } @@ -1043,7 +1043,7 @@ public class JUnitTask extends Task { } finally { FileUtils.close(br); if (vmWatcher.exists()) { - vmWatcher.delete(); + FILE_UTILS.tryHardToDelete(vmWatcher); } } @@ -1062,9 +1062,10 @@ public class JUnitTask extends Task { logVmCrash(feArray, test, vmCrashString); } - if (!propsFile.delete()) { + if (!FILE_UTILS.tryHardToDelete(propsFile)) { throw new BuildException("Could not delete temporary " - + "properties file."); + + "properties file '" + + propsFile.getAbsolutePath() + "'."); } } Modified: ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java URL: http://svn.apache.org/viewvc/ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java?rev=953741&r1=953740&r2=953741&view=diff ============================================================================== --- ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java (original) +++ ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java Fri Jun 11 15:50:09 2010 @@ -834,7 +834,7 @@ public class FTP extends Task implements } else if (!result) { return; } - this.curpwd = this.curpwd + remoteFileSep + this.curpwd = getCurpwdPlusFileSep() + currentPathElement; } catch (IOException ioe) { throw new BuildException("could not change working dir to " @@ -895,7 +895,7 @@ public class FTP extends Task implements * @return absolute path as string */ public String getAbsolutePath() { - return curpwd + remoteFileSep + ftpFile.getName(); + return getCurpwdPlusFileSep() + ftpFile.getName(); } /** * find out the relative path assuming that the path used to construct @@ -1037,6 +1037,17 @@ public class FTP extends Task implements return curpwd; } /** + * returns the path of the directory containing the AntFTPFile. + * of the full path of the file itself in case of AntFTPRootFile + * and appends the remote file separator if necessary. + * @return parent directory of the AntFTPFile + * @since Ant 1.8.2 + */ + public String getCurpwdPlusFileSep() { + return curpwd.endsWith(remoteFileSep) ? curpwd + : curpwd + remoteFileSep; + } + /** * find out if a symbolic link is encountered in the relative path of this file * from rootPath. * @return <code>true</code> if a symbolic link is encountered in the relative path. Modified: ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java URL: http://svn.apache.org/viewvc/ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java?rev=953741&r1=953740&r2=953741&view=diff ============================================================================== --- ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java (original) +++ ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java Fri Jun 11 15:50:09 2010 @@ -736,7 +736,7 @@ public class FTPTaskMirrorImpl implement } else if (!result) { return; } - this.curpwd = this.curpwd + task.getSeparator() + this.curpwd = getCurpwdPlusFileSep() + currentPathElement; } catch (IOException ioe) { throw new BuildException("could not change working dir to " @@ -797,7 +797,7 @@ public class FTPTaskMirrorImpl implement * @return absolute path as string */ public String getAbsolutePath() { - return curpwd + task.getSeparator() + ftpFile.getName(); + return getCurpwdPlusFileSep() + ftpFile.getName(); } /** * find out the relative path assuming that the path used to construct @@ -943,6 +943,17 @@ public class FTPTaskMirrorImpl implement return curpwd; } /** + * returns the path of the directory containing the AntFTPFile. + * of the full path of the file itself in case of AntFTPRootFile + * and appends the remote file separator if necessary. + * @return parent directory of the AntFTPFile + * @since Ant 1.8.2 + */ + public String getCurpwdPlusFileSep() { + String sep = task.getSeparator(); + return curpwd.endsWith(sep) ? curpwd : curpwd + sep; + } + /** * find out if a symbolic link is encountered in the relative path of this file * from rootPath. * @return <code>true</code> if a symbolic link is encountered in the relative path. Propchange: ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java ------------------------------------------------------------------------------ --- svn:mergeinfo (added) +++ svn:mergeinfo Fri Jun 11 15:50:09 2010 @@ -0,0 +1 @@ +/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java:945039 Modified: ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/util/FileUtils.java URL: http://svn.apache.org/viewvc/ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/util/FileUtils.java?rev=953741&r1=953740&r2=953741&view=diff ============================================================================== --- ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/util/FileUtils.java (original) +++ ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/util/FileUtils.java Fri Jun 11 15:50:09 2010 @@ -513,12 +513,55 @@ public class FileUtils { */ public void copyFile(File sourceFile, File destFile, FilterSetCollection filters, Vector filterChains, - boolean overwrite, boolean preserveLastModified, boolean append, + boolean overwrite, boolean preserveLastModified, + boolean append, String inputEncoding, String outputEncoding, Project project) throws IOException { - ResourceUtils.copyResource(new FileResource(sourceFile), new FileResource(destFile), - filters, filterChains, overwrite, preserveLastModified, append, inputEncoding, - outputEncoding, project); + copyFile(sourceFile, destFile, filters, filterChains, overwrite, + preserveLastModified, append, inputEncoding, outputEncoding, + project, /* force: */ false); + } + + /** + * Convenience method to copy a file from a source to a + * destination specifying if token filtering must be used, if + * filter chains must be used, if source files may overwrite + * newer destination files and the last modified time of + * <code>destFile</code> file should be made equal + * to the last modified time of <code>sourceFile</code>. + * + * @param sourceFile the file to copy from. + * Must not be <code>null</code>. + * @param destFile the file to copy to. + * Must not be <code>null</code>. + * @param filters the collection of filters to apply to this copy. + * @param filterChains filterChains to apply during the copy. + * @param overwrite Whether or not the destination file should be + * overwritten if it already exists. + * @param preserveLastModified Whether or not the last modified time of + * the resulting file should be set to that + * of the source file. + * @param append whether to append to the destination file. + * @param inputEncoding the encoding used to read the files. + * @param outputEncoding the encoding used to write the files. + * @param project the project instance. + * @param force whether to overwrite read-only destination files. + * + * @throws IOException if the copying fails. + * + * @since Ant 1.8.2 + */ + public void copyFile(File sourceFile, File destFile, + FilterSetCollection filters, Vector filterChains, + boolean overwrite, boolean preserveLastModified, + boolean append, + String inputEncoding, String outputEncoding, + Project project, boolean force) throws IOException { + ResourceUtils.copyResource(new FileResource(sourceFile), + new FileResource(destFile), + filters, filterChains, overwrite, + preserveLastModified, append, inputEncoding, + outputEncoding, project, force); } // CheckStyle:ParameterNumberCheck ON Modified: ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/util/ResourceUtils.java URL: http://svn.apache.org/viewvc/ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/util/ResourceUtils.java?rev=953741&r1=953740&r2=953741&view=diff ============================================================================== --- ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/util/ResourceUtils.java (original) +++ ant/core/branches/run-single-test-method/src/main/org/apache/tools/ant/util/ResourceUtils.java Fri Jun 11 15:50:09 2010 @@ -72,6 +72,8 @@ public class ResourceUtils { */ public static final String ISO_8859_1 = "ISO-8859-1"; + private static final long MAX_IO_CHUNK_SIZE = 16*1024*1024; // 16 MB + /** * Tells which source files should be reprocessed based on the * last modification date of target files. @@ -339,10 +341,51 @@ public class ResourceUtils { */ public static void copyResource(Resource source, Resource dest, FilterSetCollection filters, Vector filterChains, - boolean overwrite, boolean preserveLastModified, boolean append, + boolean overwrite, boolean preserveLastModified, + boolean append, String inputEncoding, String outputEncoding, Project project) throws IOException { + copyResource(source, dest, filters, filterChains, overwrite, + preserveLastModified, append, inputEncoding, + outputEncoding, project, /* force: */ false); + } + + /** + * Convenience method to copy content from one Resource to another + * specifying whether token filtering must be used, whether filter chains + * must be used, whether newer destination files may be overwritten and + * whether the last modified time of <code>dest</code> file should be made + * equal to the last modified time of <code>source</code>. + * + * @param source the Resource to copy from. + * Must not be <code>null</code>. + * @param dest the Resource to copy to. + * Must not be <code>null</code>. + * @param filters the collection of filters to apply to this copy. + * @param filterChains filterChains to apply during the copy. + * @param overwrite Whether or not the destination Resource should be + * overwritten if it already exists. + * @param preserveLastModified Whether or not the last modified time of + * the destination Resource should be set to that + * of the source. + * @param append Whether to append to an Appendable Resource. + * @param inputEncoding the encoding used to read the files. + * @param outputEncoding the encoding used to write the files. + * @param project the project instance. + * @param force whether read-only taret files will be overwritten + * + * @throws IOException if the copying fails. + * + * @since Ant 1.8.2 + */ + public static void copyResource(Resource source, Resource dest, + FilterSetCollection filters, Vector filterChains, + boolean overwrite, boolean preserveLastModified, + boolean append, + String inputEncoding, String outputEncoding, + Project project, boolean force) + throws IOException { if (!(overwrite || SelectorUtils.isOutOfDate(source, dest, FileUtils.getFileUtils() .getFileTimestampGranularity()))) { return; @@ -351,6 +394,21 @@ public class ResourceUtils { && filters.hasFilters()); final boolean filterChainsAvailable = (filterChains != null && filterChains.size() > 0); + + File destFile = null; + if (dest.as(FileProvider.class) != null) { + destFile = ((FileProvider) dest.as(FileProvider.class)).getFile(); + } + if (destFile != null && destFile.isFile() && !destFile.canWrite()) { + if (!force) { + throw new IOException("can't write to read-only destination " + + "file " + destFile); + } else if (!FILE_UTILS.tryHardToDelete(destFile)) { + throw new IOException("failed to delete read-only " + + "destination file " + destFile); + } + } + if (filterSetsAvailable) { BufferedReader in = null; BufferedWriter out = null; @@ -444,11 +502,9 @@ public class ResourceUtils { FileUtils.close(in); } } else if (source.as(FileProvider.class) != null - && dest.as(FileProvider.class) != null) { + && destFile != null) { File sourceFile = ((FileProvider) source.as(FileProvider.class)).getFile(); - File destFile = - ((FileProvider) dest.as(FileProvider.class)).getFile(); File parent = destFile.getParentFile(); if (parent != null && !parent.isDirectory() @@ -472,8 +528,9 @@ public class ResourceUtils { long position = 0; long count = srcChannel.size(); while (position < count) { + long chunk = Math.min(MAX_IO_CHUNK_SIZE, count - position); position += - srcChannel.transferTo(position, count - position, + srcChannel.transferTo(position, chunk, destChannel); } } finally { Propchange: ant/core/branches/run-single-test-method/src/main/org/apache/tools/zip/AbstractUnicodeExtraField.java ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Fri Jun 11 15:50:09 2010 @@ -1,3 +1,3 @@ /ant/core/tags/ANT_181/src/main/org/apache/tools/zip/AbstractUnicodeExtraField.java:939905-940517 -/ant/core/trunk/src/main/org/apache/tools/zip/AbstractUnicodeExtraField.java:738844,739300,741089,905481-939904 +/ant/core/trunk/src/main/org/apache/tools/zip/AbstractUnicodeExtraField.java:738844,739300,741089,905481-953737 /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java:746933,748063,748133,748288,749342,749524,749855,749859 Propchange: ant/core/branches/run-single-test-method/src/main/org/apache/tools/zip/FallbackZipEncoding.java ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Fri Jun 11 15:50:09 2010 @@ -1,3 +1,3 @@ /ant/core/tags/ANT_181/src/main/org/apache/tools/zip/FallbackZipEncoding.java:939905-940517 -/ant/core/trunk/src/main/org/apache/tools/zip/FallbackZipEncoding.java:738844,739300,741089,905481-939904 +/ant/core/trunk/src/main/org/apache/tools/zip/FallbackZipEncoding.java:738844,739300,741089,905481-953737 /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/FallbackZipEncoding.java:749524,749855,749859 Propchange: ant/core/branches/run-single-test-method/src/main/org/apache/tools/zip/NioZipEncoding.java ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Fri Jun 11 15:50:09 2010 @@ -1,3 +1,3 @@ /ant/core/tags/ANT_181/src/main/org/apache/tools/zip/NioZipEncoding.java:939905-940517 -/ant/core/trunk/src/main/org/apache/tools/zip/NioZipEncoding.java:738844,739300,741089,905481-939904 +/ant/core/trunk/src/main/org/apache/tools/zip/NioZipEncoding.java:738844,739300,741089,905481-953737 /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/NioZipEncoding.java:749524,749855,749859 Propchange: ant/core/branches/run-single-test-method/src/main/org/apache/tools/zip/UnicodeCommentExtraField.java ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Fri Jun 11 15:50:09 2010 @@ -1,3 +1,3 @@ /ant/core/tags/ANT_181/src/main/org/apache/tools/zip/UnicodeCommentExtraField.java:939905-940517 -/ant/core/trunk/src/main/org/apache/tools/zip/UnicodeCommentExtraField.java:738844,739300,741089,905481-939904 +/ant/core/trunk/src/main/org/apache/tools/zip/UnicodeCommentExtraField.java:738844,739300,741089,905481-953737 /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodeCommentExtraField.java:746933,748063,748133,749342,749524,749855,749859 Propchange: ant/core/branches/run-single-test-method/src/main/org/apache/tools/zip/UnicodePathExtraField.java ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Fri Jun 11 15:50:09 2010 @@ -1,3 +1,3 @@ /ant/core/tags/ANT_181/src/main/org/apache/tools/zip/UnicodePathExtraField.java:939905-940517 -/ant/core/trunk/src/main/org/apache/tools/zip/UnicodePathExtraField.java:738844,739300,741089,905481-939904 +/ant/core/trunk/src/main/org/apache/tools/zip/UnicodePathExtraField.java:738844,739300,741089,905481-953737 /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodePathExtraField.java:746933,748063,748133,749342,749524,749855,749859 Propchange: ant/core/branches/run-single-test-method/src/main/org/apache/tools/zip/ZipEncoding.java ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Fri Jun 11 15:50:09 2010 @@ -1,3 +1,3 @@ /ant/core/tags/ANT_181/src/main/org/apache/tools/zip/ZipEncoding.java:939905-940517 -/ant/core/trunk/src/main/org/apache/tools/zip/ZipEncoding.java:738844,739300,741089,905481-939904 +/ant/core/trunk/src/main/org/apache/tools/zip/ZipEncoding.java:738844,739300,741089,905481-953737 /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncoding.java:749524,749855,749859 Propchange: ant/core/branches/run-single-test-method/src/main/org/apache/tools/zip/ZipEncodingHelper.java ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Fri Jun 11 15:50:09 2010 @@ -1,4 +1,4 @@ /ant/core/tags/ANT_181/src/main/org/apache/tools/zip/ZipEncodingHelper.java:939905-940517 -/ant/core/trunk/src/main/org/apache/tools/zip/ZipEncodingHelper.java:738844,739300,741089,905481-939904 +/ant/core/trunk/src/main/org/apache/tools/zip/ZipEncodingHelper.java:738844,739300,741089,905481-953737 /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java:909456 /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java:746933,747841,748133,749342-749344,749524,749855,749859 Modified: ant/core/branches/run-single-test-method/src/tests/antunit/taskdefs/checksum-test.xml URL: http://svn.apache.org/viewvc/ant/core/branches/run-single-test-method/src/tests/antunit/taskdefs/checksum-test.xml?rev=953741&r1=953740&r2=953741&view=diff ============================================================================== --- ant/core/branches/run-single-test-method/src/tests/antunit/taskdefs/checksum-test.xml (original) +++ ant/core/branches/run-single-test-method/src/tests/antunit/taskdefs/checksum-test.xml Fri Jun 11 15:50:09 2010 @@ -36,12 +36,13 @@ https://issues.apache.org/bugzilla/show_bug.cgi?id=36748"> <mkdir dir="${input}"/> <echo file="${input}/a.txt">abc</echo> + <echo file="${input}/subdir/A.txt">def</echo> <echo file="${input}/B.txt">xyz</echo> <checksum totalproperty="total"> <fileset dir="${input}"/> </checksum> <au:assertPropertyEquals name="total" - value="709a9cf15c8834c59c7eeb07522cdf56"/> + value="f4d688789d32e6ca6bc93c504dbc6b46"/> </target> </project> Modified: ant/core/branches/run-single-test-method/src/tests/antunit/taskdefs/copy-test.xml URL: http://svn.apache.org/viewvc/ant/core/branches/run-single-test-method/src/tests/antunit/taskdefs/copy-test.xml?rev=953741&r1=953740&r2=953741&view=diff ============================================================================== --- ant/core/branches/run-single-test-method/src/tests/antunit/taskdefs/copy-test.xml (original) +++ ant/core/branches/run-single-test-method/src/tests/antunit/taskdefs/copy-test.xml Fri Jun 11 15:50:09 2010 @@ -295,4 +295,112 @@ public class NullByteStreamResource exte </copy> </target> + <!-- stolen from ../types/readwrite-test.xml - create a read-only file --> + <property name="file" value="testfile"/> + <condition property="unix"> + <os family="unix"/> + </condition> + <target name="createTestdir"> + <mkdir dir="${output}"/> + <mkdir dir="${input}"/> + <touch file="${output}/${file}"/> + </target> + <target name="makeFileUnwritable" + depends="createTestdir,makeFileUnwritable-Unix,makeFileUnwritable-Windows"/> + <target name="makeFileUnwritable-Unix" id="unix"> + <chmod file="${output}/${file}" perm="444"/> + </target> + <target name="makeFileUnwritable-Windows" unless="unix"> + <attrib file="${output}/${file}" readonly="true"/> + </target> + + <target name="testCopyOverReadOnlyFile" depends="makeFileUnwritable"> + <sleep seconds="2"/> + <touch file="${input}/${file}"/> + <au:expectfailure + expectedMessage="can't write to read-only destination file "> + <copy toDir="${output}"> + <fileset dir="${input}"/> + </copy> + </au:expectfailure> + </target> + + <target name="testFilteredCopyOverReadOnlyFile" depends="makeFileUnwritable"> + <sleep seconds="2"/> + <touch file="${input}/${file}"/> + <au:expectfailure + expectedMessage="can't write to read-only destination file "> + <copy toDir="${output}"> + <fileset dir="${input}"/> + <filterset> + <filter token="foo" value="bar"/> + </filterset> + </copy> + </au:expectfailure> + </target> + + <target name="testCopyOverReadOnlyFileWithOverwrite" + depends="makeFileUnwritable"> + <touch file="${input}/${file}"/> + <au:expectfailure + expectedMessage="can't write to read-only destination file "> + <copy toDir="${output}" overwrite="true"> + <fileset dir="${input}"/> + </copy> + </au:expectfailure> + </target> + + <target name="testFilteredCopyOverReadOnlyFileWithOverwrite" + depends="makeFileUnwritable"> + <touch file="${input}/${file}"/> + <au:expectfailure + expectedMessage="can't write to read-only destination file "> + <copy toDir="${output}" overwrite="true"> + <fileset dir="${input}"/> + <filterset> + <filter token="foo" value="bar"/> + </filterset> + </copy> + </au:expectfailure> + </target> + + <target name="testForcedCopyOverReadOnlyFile" depends="makeFileUnwritable"> + <sleep seconds="2"/> + <touch file="${input}/${file}"/> + <copy toDir="${output}" force="true"> + <fileset dir="${input}"/> + </copy> + </target> + + <target name="testForcedFilteredCopyOverReadOnlyFile" + depends="makeFileUnwritable"> + <sleep seconds="2"/> + <touch file="${input}/${file}"/> + <copy toDir="${output}" force="true"> + <fileset dir="${input}"/> + <filterset> + <filter token="foo" value="bar"/> + </filterset> + </copy> + </target> + + <target name="testForcedCopyOverReadOnlyFileWithOverwrite" + depends="makeFileUnwritable"> + <touch file="${input}/${file}"/> + <copy toDir="${output}" overwrite="true" force="true"> + <fileset dir="${input}"/> + </copy> + </target> + + <target name="testForcedFilteredCopyOverReadOnlyFileWithOverwrite" + depends="makeFileUnwritable"> + <touch file="${input}/${file}"/> + <copy toDir="${output}" overwrite="true" force="true"> + <fileset dir="${input}"/> + <filterset> + <filter token="foo" value="bar"/> + </filterset> + </copy> + </target> + </project> Modified: ant/core/branches/run-single-test-method/src/tests/antunit/taskdefs/move-test.xml URL: http://svn.apache.org/viewvc/ant/core/branches/run-single-test-method/src/tests/antunit/taskdefs/move-test.xml?rev=953741&r1=953740&r2=953741&view=diff ============================================================================== --- ant/core/branches/run-single-test-method/src/tests/antunit/taskdefs/move-test.xml (original) +++ ant/core/branches/run-single-test-method/src/tests/antunit/taskdefs/move-test.xml Fri Jun 11 15:50:09 2010 @@ -124,4 +124,111 @@ value="Y"/> </target> + <!-- stolen from ../types/readwrite-test.xml - create a read-only file --> + <property name="file" value="testfile"/> + <condition property="unix"> + <os family="unix"/> + </condition> + <target name="createTestdir"> + <mkdir dir="${output}"/> + <mkdir dir="${input}"/> + <touch file="${output}/${file}"/> + </target> + <target name="makeFileUnwritable" + depends="createTestdir,makeFileUnwritable-Unix,makeFileUnwritable-Windows"/> + <target name="makeFileUnwritable-Unix" id="unix"> + <chmod file="${output}/${file}" perm="444"/> + </target> + <target name="makeFileUnwritable-Windows" unless="unix"> + <attrib file="${output}/${file}" readonly="true"/> + </target> + + <target name="testMoveOverReadOnlyFile" depends="makeFileUnwritable"> + <sleep seconds="2"/> + <touch file="${input}/${file}"/> + <au:expectfailure + expectedMessage="can't replace read-only destination file "> + <move toDir="${output}"> + <fileset dir="${input}"/> + </move> + </au:expectfailure> + </target> + + <target name="testFilteredMoveOverReadOnlyFile" depends="makeFileUnwritable"> + <sleep seconds="2"/> + <touch file="${input}/${file}"/> + <au:expectfailure + expectedMessage="can't write to read-only destination file "> + <move toDir="${output}"> + <fileset dir="${input}"/> + <filterset> + <filter token="foo" value="bar"/> + </filterset> + </move> + </au:expectfailure> + </target> + + <target name="testMoveOverReadOnlyFileWithOverwrite" + depends="makeFileUnwritable"> + <touch file="${input}/${file}"/> + <au:expectfailure + expectedMessage="can't replace read-only destination file "> + <move toDir="${output}" overwrite="true"> + <fileset dir="${input}"/> + </move> + </au:expectfailure> + </target> + + <target name="testFilteredMoveOverReadOnlyFileWithOverwrite" + depends="makeFileUnwritable"> + <touch file="${input}/${file}"/> + <au:expectfailure + expectedMessage="can't write to read-only destination file "> + <move toDir="${output}" overwrite="true"> + <fileset dir="${input}"/> + <filterset> + <filter token="foo" value="bar"/> + </filterset> + </move> + </au:expectfailure> + </target> + + <target name="testForcedMoveOverReadOnlyFile" depends="makeFileUnwritable"> + <sleep seconds="2"/> + <touch file="${input}/${file}"/> + <move toDir="${output}" force="true"> + <fileset dir="${input}"/> + </move> + </target> + + <target name="testForcedFilteredMoveOverReadOnlyFile" + depends="makeFileUnwritable"> + <sleep seconds="2"/> + <touch file="${input}/${file}"/> + <move toDir="${output}" force="true"> + <fileset dir="${input}"/> + <filterset> + <filter token="foo" value="bar"/> + </filterset> + </move> + </target> + + <target name="testForcedMoveOverReadOnlyFileWithOverwrite" + depends="makeFileUnwritable"> + <touch file="${input}/${file}"/> + <move toDir="${output}" overwrite="true" force="true"> + <fileset dir="${input}"/> + </move> + </target> + + <target name="testForcedFilteredMoveOverReadOnlyFileWithOverwrite" + depends="makeFileUnwritable"> + <touch file="${input}/${file}"/> + <move toDir="${output}" overwrite="true" force="true"> + <fileset dir="${input}"/> + <filterset> + <filter token="foo" value="bar"/> + </filterset> + </move> + </target> </project> Modified: ant/core/branches/run-single-test-method/src/tests/antunit/taskdefs/optional/junit/xmlformatter-test.xml URL: http://svn.apache.org/viewvc/ant/core/branches/run-single-test-method/src/tests/antunit/taskdefs/optional/junit/xmlformatter-test.xml?rev=953741&r1=953740&r2=953741&view=diff ============================================================================== --- ant/core/branches/run-single-test-method/src/tests/antunit/taskdefs/optional/junit/xmlformatter-test.xml (original) +++ ant/core/branches/run-single-test-method/src/tests/antunit/taskdefs/optional/junit/xmlformatter-test.xml Fri Jun 11 15:50:09 2010 @@ -50,4 +50,43 @@ public class A extends TestCase { <xmlvalidate file="${output}/TEST-org.example.A.xml" lenient="true"/> </target> + + <target name="testEntities" + description="https://issues.apache.org/bugzilla/show_bug.cgi?id=49404"> + <mkdir dir="${input}/org/example"/> + <echo file="${input}/org/example/A.java"><![CDATA[ +package org.example; +import junit.framework.TestCase; +public class A extends TestCase { + public void testX() { + assertTrue("&&", false); + } +} +]]></echo> + <mkdir dir="${output}"/> + <javac srcdir="${input}" destdir="${output}"> + <classpath refid="junit"/> + </javac> + <junit fork="true"> + <classpath refid="junit"/> + <classpath location="${output}"/> + <batchtest todir="${output}"> + <fileset dir="${output}"> + <include name="**/A.class" /> + </fileset> + </batchtest> + <formatter type="xml"/> + </junit> + <xmlvalidate file="${output}/TEST-org.example.A.xml" + lenient="true"/> + <!-- + <au:assertResourceContains + resource="${output}/TEST-org.example.A.xml" + value="message="&amp;amp;&amp;"/> + <au:assertResourceContains + resource="${output}/TEST-org.example.A.xml" + value="message=AssertionFailedError: &amp;&"/> + --> + </target> + </project> Modified: ant/core/branches/run-single-test-method/src/tests/junit/org/apache/tools/ant/DefaultLoggerTest.java URL: http://svn.apache.org/viewvc/ant/core/branches/run-single-test-method/src/tests/junit/org/apache/tools/ant/DefaultLoggerTest.java?rev=953741&r1=953740&r2=953741&view=diff ============================================================================== --- ant/core/branches/run-single-test-method/src/tests/junit/org/apache/tools/ant/DefaultLoggerTest.java (original) +++ ant/core/branches/run-single-test-method/src/tests/junit/org/apache/tools/ant/DefaultLoggerTest.java Fri Jun 11 15:50:09 2010 @@ -31,24 +31,24 @@ public class DefaultLoggerTest extends T private static String msg(Throwable error, boolean verbose) { StringBuffer m = new StringBuffer(); DefaultLogger.throwableMessage(m, error, verbose); - return m.toString().replace(StringUtils.LINE_SEP.charAt(0), '\n'); + return m.toString(); } public void testThrowableMessage() throws Exception { // #43398 BuildException be = new BuildException("oops", new Location("build.xml", 1, 0)); assertEquals( - "build.xml:1: oops\n", + "build.xml:1: oops" + StringUtils.LINE_SEP, msg(be, false)); be = ProjectHelper.addLocationToBuildException(be, new Location("build.xml", 2, 0)); assertEquals( - "build.xml:2: The following error occurred while executing this line:\n" + - "build.xml:1: oops\n", + "build.xml:2: The following error occurred while executing this line:" + StringUtils.LINE_SEP + + "build.xml:1: oops" + StringUtils.LINE_SEP, msg(be, false)); be = ProjectHelper.addLocationToBuildException(be, new Location("build.xml", 3, 0)); assertEquals( - "build.xml:3: The following error occurred while executing this line:\n" + - "build.xml:2: The following error occurred while executing this line:\n" + - "build.xml:1: oops\n", + "build.xml:3: The following error occurred while executing this line:" + StringUtils.LINE_SEP + + "build.xml:2: The following error occurred while executing this line:" + StringUtils.LINE_SEP + + "build.xml:1: oops" + StringUtils.LINE_SEP, msg(be, false)); Exception x = new Exception("problem") { public void printStackTrace(PrintWriter w) { @@ -57,19 +57,19 @@ public class DefaultLoggerTest extends T } }; assertEquals( - "problem\n" + - " at p.C.m\n", + "problem" + StringUtils.LINE_SEP + + " at p.C.m" + StringUtils.LINE_SEP, msg(x, false)); be = new BuildException(x, new Location("build.xml", 1, 0)); assertEquals( - "build.xml:1: problem\n" + - " at p.C.m\n", + "build.xml:1: problem" + StringUtils.LINE_SEP + + " at p.C.m" + StringUtils.LINE_SEP, msg(be, false)); be = ProjectHelper.addLocationToBuildException(be, new Location("build.xml", 2, 0)); assertEquals( - "build.xml:2: The following error occurred while executing this line:\n" + - "build.xml:1: problem\n" + - " at p.C.m\n", + "build.xml:2: The following error occurred while executing this line:" + StringUtils.LINE_SEP + + "build.xml:1: problem" + StringUtils.LINE_SEP + + " at p.C.m" + StringUtils.LINE_SEP, msg(be, false)); } Modified: ant/core/branches/run-single-test-method/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java URL: http://svn.apache.org/viewvc/ant/core/branches/run-single-test-method/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java?rev=953741&r1=953740&r2=953741&view=diff ============================================================================== --- ant/core/branches/run-single-test-method/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java (original) +++ ant/core/branches/run-single-test-method/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java Fri Jun 11 15:50:09 2010 @@ -19,10 +19,10 @@ package org.apache.tools.ant; import org.apache.tools.ant.taskdefs.condition.Os; +import org.apache.tools.ant.types.selectors.TokenizedPath; import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.util.SymbolicLinkUtils; - import java.io.File; import java.io.IOException; import java.util.Arrays; @@ -555,4 +555,15 @@ public class DirectoryScannerTest extend files.contains("alpha/beta/gamma/gamma.xml" .replace('/', File.separatorChar))); } + + public void testContentsExcluded() { + DirectoryScanner ds = new DirectoryScanner(); + ds.setBasedir(new File(".")); + ds.setIncludes(new String[] {"**"}); + ds.addDefaultExcludes(); + ds.ensureNonPatternSetsReady(); + File f = new File(".svn"); + TokenizedPath p = new TokenizedPath(f.getAbsolutePath()); + assertTrue(ds.contentsExcluded(p)); + } } Modified: ant/core/branches/run-single-test-method/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java URL: http://svn.apache.org/viewvc/ant/core/branches/run-single-test-method/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java?rev=953741&r1=953740&r2=953741&view=diff ============================================================================== --- ant/core/branches/run-single-test-method/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java (original) +++ ant/core/branches/run-single-test-method/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java Fri Jun 11 15:50:09 2010 @@ -137,7 +137,9 @@ public class LocatorTest extends TestCas */ public void testAntOnRemoteShare() throws Throwable { String resolved=Locator.fromJarURI(SHARED_JAR_URI); - assertResolved(SHARED_JAR_URI, LAUNCHER_JAR,resolved,true); + assertResolved(SHARED_JAR_URI, LAUNCHER_JAR, resolved, unix); + assertResolved(SHARED_JAR_URI, LAUNCHER_JAR.replace('/', '\\'), + resolved, windows); } /** @@ -147,8 +149,7 @@ public class LocatorTest extends TestCas */ public void testFileFromRemoteShare() throws Throwable { String resolved = Locator.fromJarURI(SHARED_JAR_URI); - assertResolved(SHARED_JAR_URI, LAUNCHER_JAR, resolved, true); - File f=new File(resolved); + File f = new File(resolved); String path = f.getAbsolutePath(); if (windows) { assertEquals(0, path.indexOf("\\\\")); Modified: ant/core/branches/run-single-test-method/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java URL: http://svn.apache.org/viewvc/ant/core/branches/run-single-test-method/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java?rev=953741&r1=953740&r2=953741&view=diff ============================================================================== --- ant/core/branches/run-single-test-method/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java (original) +++ ant/core/branches/run-single-test-method/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java Fri Jun 11 15:50:09 2010 @@ -178,6 +178,13 @@ public class ConcatTest assertEquals(size, 0); } + public void testOverwrite() { + executeTarget("testoverwrite"); + File file2 = new File(getProjectDir(), tempFile2); + long size = file2.length(); + assertTrue(size > 0); + } + public void testheaderfooter() { test3(); expectLog("testheaderfooter", "headerHello, World!footer"); Propchange: ant/core/branches/run-single-test-method/src/tests/junit/org/apache/tools/zip/ExtraFieldUtilsTest.java ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Fri Jun 11 15:50:09 2010 @@ -1,4 +1,4 @@ /ant/core/tags/ANT_181/src/tests/junit/org/apache/tools/zip/ExtraFieldUtilsTest.java:939905-940517 -/ant/core/trunk/src/tests/junit/org/apache/tools/zip/ExtraFieldUtilsTest.java:905481-939904 +/ant/core/trunk/src/tests/junit/org/apache/tools/zip/ExtraFieldUtilsTest.java:905481-953737 /commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java:910483-910521 /commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java:749906-749907 Modified: ant/core/branches/run-single-test-method/xdocs/antlibs/svn/index.xml URL: http://svn.apache.org/viewvc/ant/core/branches/run-single-test-method/xdocs/antlibs/svn/index.xml?rev=953741&r1=953740&r2=953741&view=diff ============================================================================== --- ant/core/branches/run-single-test-method/xdocs/antlibs/svn/index.xml (original) +++ ant/core/branches/run-single-test-method/xdocs/antlibs/svn/index.xml Fri Jun 11 15:50:09 2010 @@ -42,14 +42,14 @@ <subsection name="svn"> <p>A very thin layer on top of the command line executable, comparable to <a - href="http://ant.apache.org/manual/CoreTasks/cvs.html">the CVS + href="http://ant.apache.org/manual/Tasks/cvs.html">the CVS task</a>.</p> </subsection> <subsection name="changelog"> <p>Creates a log of change comments between two revisions, comparable to <a - href="http://ant.apache.org/manual/CoreTasks/changelog.html">CvsChangeLog</a>.</p> + href="http://ant.apache.org/manual/Tasks/changelog.html">CvsChangeLog</a>.</p> </subsection> <subsection name="*diff"> @@ -60,7 +60,7 @@ for the changes between two revisions.</p> <p>Together comparable to <a - href="http://ant.apache.org/manual/CoreTasks/cvstagdiff.html">CvsTagDiff</a>.</p> + href="http://ant.apache.org/manual/Tasks/cvstagdiff.html">CvsTagDiff</a>.</p> </subsection> </section> Modified: ant/core/branches/run-single-test-method/xdocs/antnews.xml URL: http://svn.apache.org/viewvc/ant/core/branches/run-single-test-method/xdocs/antnews.xml?rev=953741&r1=953740&r2=953741&view=diff ============================================================================== --- ant/core/branches/run-single-test-method/xdocs/antnews.xml (original) +++ ant/core/branches/run-single-test-method/xdocs/antnews.xml Fri Jun 11 15:50:09 2010 @@ -27,7 +27,7 @@ <body> <section name="Ant1.8.1"> - <h3>May 6th, 2010 - Ant 1.8.1 Released</h3> + <h3>May 7th, 2010 - Ant 1.8.1 Released</h3> <p>Apache Ant 1.8.1 is now available for download as source or binary (with and without dependencies) from <a href="http://ant.apache.org/bindownload.cgi">http://ant.apache.org/bindownload.cgi</a>.</p> Modified: ant/core/branches/run-single-test-method/xdocs/bindownload.xml URL: http://svn.apache.org/viewvc/ant/core/branches/run-single-test-method/xdocs/bindownload.xml?rev=953741&r1=953740&r2=953741&view=diff ============================================================================== --- ant/core/branches/run-single-test-method/xdocs/bindownload.xml (original) +++ ant/core/branches/run-single-test-method/xdocs/bindownload.xml Fri Jun 11 15:50:09 2010 @@ -80,7 +80,7 @@ Other mirrors: <select name="Preferred"> <div class="warning"> <div class="label">Note</div> -<div class="content">Ant 1.8.1 was released on 6-May-2010 and +<div class="content">Ant 1.8.1 was released on 7-May-2010 and may not be available on all mirrors for a few days.</div> </div> <br></br> Modified: ant/core/branches/run-single-test-method/xdocs/faq.xml URL: http://svn.apache.org/viewvc/ant/core/branches/run-single-test-method/xdocs/faq.xml?rev=953741&r1=953740&r2=953741&view=diff ============================================================================== --- ant/core/branches/run-single-test-method/xdocs/faq.xml (original) +++ ant/core/branches/run-single-test-method/xdocs/faq.xml Fri Jun 11 15:50:09 2010 @@ -228,7 +228,7 @@ </tr> <tr> <td>1.8.1</td> - <td>6 May 2010</td> + <td>7 May 2010</td> </tr> </table> </answer> @@ -335,7 +335,7 @@ Apache Ant version 1.6.2 compiled on Jul <faq id="precompile-jsps"> <question>How to I precompile Java Server Pages (JSPs)?</question> <answer> - <p>Ant has a built in optional task <a href="/manual/OptionalTasks/jspc.html"><jspc></a> + <p>Ant has a built in optional task <a href="/manual/Tasks/jspc.html"><jspc></a> which was intended for that. <b>But this task is deprecated.</b> Here the alternative suggested by the manual:</p> <p><i>Instead of relying on container specific JSP-compilers we suggest deploying @@ -682,7 +682,7 @@ shell-prompt> m4 foo.m4 > foo course, comes with the overhead of adding JAR files to support the language, to say nothing of the added maintenance in requiring two languages to implement a single system. See the - <a href="manual/OptionalTasks/script.html"> + <a href="manual/Tasks/script.html"> <code><script></code> task documentation</a> for more details.</p> </answer> Modified: ant/core/branches/run-single-test-method/xdocs/index.xml URL: http://svn.apache.org/viewvc/ant/core/branches/run-single-test-method/xdocs/index.xml?rev=953741&r1=953740&r2=953741&view=diff ============================================================================== --- ant/core/branches/run-single-test-method/xdocs/index.xml (original) +++ ant/core/branches/run-single-test-method/xdocs/index.xml Fri Jun 11 15:50:09 2010 @@ -25,7 +25,7 @@ <body> <section name="Ant1.8.1"> - <h3>May 6th, 2010 - Ant 1.8.1 Released</h3> + <h3>May 7th, 2010 - Ant 1.8.1 Released</h3> <p>Apache Ant 1.8.1 is now available for download as source or binary (with and without dependencies) from <a href="http://ant.apache.org/bindownload.cgi">http://ant.apache.org/bindownload.cgi</a>.</p> Modified: ant/core/branches/run-single-test-method/xdocs/resources.xml URL: http://svn.apache.org/viewvc/ant/core/branches/run-single-test-method/xdocs/resources.xml?rev=953741&r1=953740&r2=953741&view=diff ============================================================================== --- ant/core/branches/run-single-test-method/xdocs/resources.xml (original) +++ ant/core/branches/run-single-test-method/xdocs/resources.xml Fri Jun 11 15:50:09 2010 @@ -56,7 +56,7 @@ <subsection name="FAQ about Borland Application Server tasks"> <p>Benoit Moussaud, the original author of the Borland Application Server specific <a - href="manual/OptionalTasks/ejb.html#ejbtasks">EJB tasks</a> has put + href="manual/Tasks/ejb.html#ejbtasks">EJB tasks</a> has put together a FAQ for this specific subtask.</p> <table class="externals"> Modified: ant/core/branches/run-single-test-method/xdocs/srcdownload.xml URL: http://svn.apache.org/viewvc/ant/core/branches/run-single-test-method/xdocs/srcdownload.xml?rev=953741&r1=953740&r2=953741&view=diff ============================================================================== --- ant/core/branches/run-single-test-method/xdocs/srcdownload.xml (original) +++ ant/core/branches/run-single-test-method/xdocs/srcdownload.xml Fri Jun 11 15:50:09 2010 @@ -77,7 +77,7 @@ Other mirrors: <select name="Preferred"> <div class="warning"> <div class="label">Note</div> -<div class="content">Ant 1.8.1 was released on 6-May-2010 and +<div class="content">Ant 1.8.1 was released on 7-May-2010 and may not be available on all mirrors for a few days.</div> </div> <br></br>
