You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2016/07/31 08:17:05 UTC

[1/4] ant git commit: fix the patterns used by touch and date selectors

Repository: ant
Updated Branches:
  refs/heads/master 047844b24 -> c50b683cf


fix the patterns used by touch and date selectors

https://bz.apache.org/bugzilla/show_bug.cgi?id=59909


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/77fbe378
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/77fbe378
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/77fbe378

Branch: refs/heads/master
Commit: 77fbe3782fbca6b7cc0af5a381207c32d34d9bd5
Parents: ee85859
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun Jul 31 09:29:41 2016 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun Jul 31 09:29:41 2016 +0200

----------------------------------------------------------------------
 WHATSNEW                                        |  9 ++++++
 manual/Tasks/touch.html                         |  6 ++--
 manual/Types/resources.html                     |  5 +--
 manual/Types/selectors.html                     |  9 +++---
 .../org/apache/tools/ant/taskdefs/Touch.java    | 34 ++++++++++++--------
 .../ant/types/resources/selectors/Date.java     | 13 ++++----
 .../tools/ant/types/selectors/BaseSelector.java | 17 ++++++++--
 .../tools/ant/types/selectors/DateSelector.java | 14 ++++----
 .../ant/types/selectors/DateSelectorTest.java   |  2 +-
 9 files changed, 69 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/77fbe378/WHATSNEW
----------------------------------------------------------------------
diff --git a/WHATSNEW b/WHATSNEW
index 9a36711..50128b8 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -40,6 +40,15 @@ Fixed bugs:
    worked on OSes where sed is GNU sed.
    Bugzilla Report 59898
 
+ * <touch>'s default pattern as well as the default patterns used by
+   the <date> (resource) selectors depended on the JDK being used - or
+   rather the locale provider being used and the default locale
+   provider changed with Java 9.
+   They are now fixed and the documentation has been updated to
+   reflect the real patterns used rather than a non-formal description
+   of the expected format.
+   Bugzilla Report 59909
+
 Other changes:
 --------------
 

http://git-wip-us.apache.org/repos/asf/ant/blob/77fbe378/manual/Tasks/touch.html
----------------------------------------------------------------------
diff --git a/manual/Tasks/touch.html b/manual/Tasks/touch.html
index 263ea70..8adee38 100644
--- a/manual/Tasks/touch.html
+++ b/manual/Tasks/touch.html
@@ -74,8 +74,10 @@ resource collections (which also includes directories).  Prior to Apache Ant
   </tr>
   <tr>
     <td valign="top">pattern</td>
-    <td valign="top">SimpleDateFormat-compatible pattern string.
-       Defaults to MM/DD/YYYY HH:MM AM_or_PM or MM/DD/YYYY HH:MM:SS AM_or_PM.
+    <td valign="top">SimpleDateFormat-compatible pattern string using
+       the current locale.
+       Defaults to "MM/dd/YYYY hh:mm a" or "MM/dd/yyyy hh:mm:ss a"
+       using the US locale.
        <b>Since Ant 1.6.3</b></td>
     <td valign="top" align="center">No</td>
   </tr>

http://git-wip-us.apache.org/repos/asf/ant/blob/77fbe378/manual/Types/resources.html
----------------------------------------------------------------------
diff --git a/manual/Types/resources.html b/manual/Types/resources.html
index 58cefde..8ba77aa 100644
--- a/manual/Types/resources.html
+++ b/manual/Types/resources.html
@@ -641,9 +641,10 @@ platforms.
     <tr>
       <td valign="top">pattern</td>
       <td valign="top">SimpleDateFormat-compatible pattern
-        for use with the <code>datetime</code> attribute</td>
+        for use with the <code>datetime</code> attribute using the
+        current locale</td>
       <td align="center" valign="top">
-        No, default is "MM/DD/YYYY HH:MM AM_or_PM"</td>
+        No, default is "MM/dd/yyyy hh:mm a" using the US locale</td>
     </tr>
     <tr>
       <td valign="top">granularity</td>

http://git-wip-us.apache.org/repos/asf/ant/blob/77fbe378/manual/Types/selectors.html
----------------------------------------------------------------------
diff --git a/manual/Types/selectors.html b/manual/Types/selectors.html
index 560b416..402c711 100644
--- a/manual/Types/selectors.html
+++ b/manual/Types/selectors.html
@@ -173,9 +173,9 @@
       <tr>
         <td valign="top">datetime</td>
         <td valign="top">Specifies the date and time to test for.
-          Should be in the format MM/DD/YYYY HH:MM AM_or_PM, or
-          an alternative pattern specified via the <i>pattern</i>
-          attribute.
+          Should be in the format "MM/dd/yyyy hh:mm a" using the US
+          locale, or an alternative pattern specified via
+          the <i>pattern</i> attribute.
         </td>
         <td valign="top" align="center" rowspan="2">At least one of the two.</td>
       </tr>
@@ -212,7 +212,8 @@
       <tr>
         <td valign="top">pattern</td>
         <td valign="top">The <CODE>SimpleDateFormat</CODE>-compatible pattern
-          to use when interpreting the <i>datetime</i> attribute.
+          to use when interpreting the <i>datetime</i> attribute using
+          the current locale.
           <i>Since Ant 1.6.2</i>
         </td>
         <td valign="top" align="center">No</td>

http://git-wip-us.apache.org/repos/asf/ant/blob/77fbe378/src/main/org/apache/tools/ant/taskdefs/Touch.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Touch.java b/src/main/org/apache/tools/ant/taskdefs/Touch.java
index 4a4118c..c6d79b7 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Touch.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Touch.java
@@ -61,23 +61,29 @@ public class Touch extends Task {
 
     public static final DateFormatFactory DEFAULT_DF_FACTORY
         = new DateFormatFactory() {
-        /*
-         * The initial version used DateFormat.SHORT for the
-         * time format, which ignores seconds.  If we want
-         * seconds as well, we need DateFormat.MEDIUM, which
-         * in turn would break all old build files.
-         *
-         * First try to parse with DateFormat.SHORT and if
-         * that fails with MEDIUM - throw an exception if both
-         * fail.
-         */
+
+        private ThreadLocal<DateFormat> primary =
+            new ThreadLocal<DateFormat>() {
+                @Override
+                protected DateFormat initialValue() {
+                    return new SimpleDateFormat("MM/dd/yyyy hh:mm a",
+                                                Locale.US);
+                }
+            };
+        private ThreadLocal<DateFormat> fallback =
+            new ThreadLocal<DateFormat>() {
+                @Override
+                protected DateFormat initialValue() {
+                    return new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a",
+                                                Locale.US);
+                }
+            };
+
         public DateFormat getPrimaryFormat() {
-            return DateFormat.getDateTimeInstance(DateFormat.SHORT,
-                DateFormat.SHORT, Locale.US);
+            return primary.get();
         }
         public DateFormat getFallbackFormat() {
-            return DateFormat.getDateTimeInstance(DateFormat.SHORT,
-                DateFormat.MEDIUM, Locale.US);
+            return fallback.get();
         }
     };
     private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();

http://git-wip-us.apache.org/repos/asf/ant/blob/77fbe378/src/main/org/apache/tools/ant/types/resources/selectors/Date.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/resources/selectors/Date.java b/src/main/org/apache/tools/ant/types/resources/selectors/Date.java
index 8541e85..0719a18 100644
--- a/src/main/org/apache/tools/ant/types/resources/selectors/Date.java
+++ b/src/main/org/apache/tools/ant/types/resources/selectors/Date.java
@@ -137,10 +137,10 @@ public class Date implements ResourceSelector {
             throw new BuildException(MILLIS_OR_DATETIME);
         }
         if (millis == null) {
-            DateFormat df = ((pattern == null)
-                ? DateFormat.getDateTimeInstance(
-                    DateFormat.SHORT, DateFormat.SHORT, Locale.US)
-                : new SimpleDateFormat(pattern));
+            String p = pattern == null ? "MM/dd/yyyy hh:mm a" : pattern;
+            DateFormat df = pattern == null
+                ? new SimpleDateFormat(p, Locale.US)
+                : new SimpleDateFormat(p);
             try {
                 long m = df.parse(dateTime).getTime();
                 if (m < 0) {
@@ -151,9 +151,8 @@ public class Date implements ResourceSelector {
                 setMillis(m);
             } catch (ParseException pe) {
                 throw new BuildException("Date of " + dateTime
-                        + " Cannot be parsed correctly. It should be in"
-                        + (pattern == null
-                        ? " MM/DD/YYYY HH:MM AM_PM" : pattern) + " format.");
+                        + " Cannot be parsed correctly. It should be in '"
+                        + p + "' format.");
             }
         }
         return when.evaluate(r.getLastModified(), millis.longValue(), granularity);

http://git-wip-us.apache.org/repos/asf/ant/blob/77fbe378/src/main/org/apache/tools/ant/types/selectors/BaseSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/BaseSelector.java b/src/main/org/apache/tools/ant/types/selectors/BaseSelector.java
index 61d7a1a..414390e 100644
--- a/src/main/org/apache/tools/ant/types/selectors/BaseSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/BaseSelector.java
@@ -34,7 +34,7 @@ import org.apache.tools.ant.types.DataType;
 public abstract class BaseSelector extends DataType implements FileSelector {
 
     private String errmsg = null;
-
+    private Throwable cause;
 
     /**
      * Do nothing constructor.
@@ -55,6 +55,19 @@ public abstract class BaseSelector extends DataType implements FileSelector {
     }
 
     /**
+     * Allows all selectors to indicate a setup error. Note that only
+     * the first error message is recorded.
+     *
+     * @param msg The error message any BuildException should throw.
+     */
+    public void setError(String msg, Throwable cause) {
+        if (errmsg == null) {
+            errmsg = msg;
+            this.cause = cause;
+        }
+    }
+
+    /**
      * Returns any error messages that have been set.
      *
      * @return the error condition
@@ -87,7 +100,7 @@ public abstract class BaseSelector extends DataType implements FileSelector {
             verifySettings();
         }
         if (getError() != null) {
-            throw new BuildException(errmsg);
+            throw new BuildException(errmsg, cause);
         }
         if (!isReference()) {
             dieOnCircularReference();

http://git-wip-us.apache.org/repos/asf/ant/blob/77fbe378/src/main/org/apache/tools/ant/types/selectors/DateSelector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/selectors/DateSelector.java b/src/main/org/apache/tools/ant/types/selectors/DateSelector.java
index aea94a8..8232e45 100644
--- a/src/main/org/apache/tools/ant/types/selectors/DateSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/DateSelector.java
@@ -209,11 +209,10 @@ public class DateSelector extends BaseExtendSelector {
             setError("You must provide a datetime or the number of "
                     + "milliseconds.");
         } else if (millis < 0 && dateTime != null) {
-            // check millis and only set it once.
-            DateFormat df = ((pattern == null)
-                ? DateFormat.getDateTimeInstance(
-                    DateFormat.SHORT, DateFormat.SHORT, Locale.US)
-                : new SimpleDateFormat(pattern));
+            String p = pattern == null ? "MM/dd/yyyy hh:mm a" : pattern;
+            DateFormat df = pattern == null
+                ? new SimpleDateFormat(p, Locale.US)
+                : new SimpleDateFormat(p);
 
             try {
                 setMillis(df.parse(dateTime).getTime());
@@ -224,9 +223,8 @@ public class DateSelector extends BaseExtendSelector {
                 }
             } catch (ParseException pe) {
                 setError("Date of " + dateTime
-                        + " Cannot be parsed correctly. It should be in"
-                        + ((pattern == null)
-                        ? " MM/DD/YYYY HH:MM AM_PM" : pattern) + " format.");
+                        + " Cannot be parsed correctly. It should be in '"
+                         + p + "' format.", pe);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/77fbe378/src/tests/junit/org/apache/tools/ant/types/selectors/DateSelectorTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/DateSelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/selectors/DateSelectorTest.java
index 43278f4..7eb9501 100644
--- a/src/tests/junit/org/apache/tools/ant/types/selectors/DateSelectorTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/selectors/DateSelectorTest.java
@@ -73,7 +73,7 @@ public class DateSelectorTest {
         } catch (BuildException be3) {
             assertEquals("Date of this is not a date"
                         + " Cannot be parsed correctly. It should be in"
-                        + " MM/DD/YYYY HH:MM AM_PM format.", be3.getMessage());
+                        + " 'MM/dd/yyyy hh:mm a' format.", be3.getMessage());
         }
 
         s = new DateSelector();


[3/4] ant git commit: formatting

Posted by bo...@apache.org.
formatting


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/a62d5f9f
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/a62d5f9f
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/a62d5f9f

Branch: refs/heads/master
Commit: a62d5f9f2a9e329c9b5d233b15b658b4e25f4018
Parents: 2df1771
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun Jul 31 09:36:41 2016 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun Jul 31 09:36:41 2016 +0200

----------------------------------------------------------------------
 .../ant/taskdefs/optional/TraXLiaisonTest.java  | 258 +++++++++----------
 1 file changed, 129 insertions(+), 129 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/a62d5f9f/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java
index 1444141..52605b4 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java
@@ -1,129 +1,129 @@
-package org.apache.tools.ant.taskdefs.optional;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.InputStream;
-import java.security.Permission;
-
-import junit.framework.AssertionFailedError;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.taskdefs.XSLTLiaison;
-import org.apache.tools.ant.taskdefs.XSLTLogger;
-import org.apache.tools.ant.util.JAXPUtils;
-import org.junit.After;
-import org.junit.Assume;
-import org.junit.Test;
-
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-
-/**
- * TraX XSLTLiaison testcase
- */
-public class TraXLiaisonTest extends AbstractXSLTLiaisonTest
-    implements XSLTLogger {
-
-
-	@After
-    public void tearDown() {
-        File f = new File("xalan2-redirect-out.tmp");
-        if (f.exists()) {
-            f.delete();
-        }
-    }
-
-    public XSLTLiaison createLiaison() throws Exception {
-        TraXLiaison l = new TraXLiaison();
-        l.setLogger(this);
-        return l;
-    }
-
-    @Test
-    public void testXalan2Redirect() throws Exception {
-    	try {
-    		getClass().getClassLoader().loadClass("org.apache.xalan.lib.Redirect");
-    	} catch (Exception exc) {
-    		Assume.assumeNoException("xalan redirect is not on the classpath", exc);
-    	}
-        File xsl = getFile("/taskdefs/optional/xalan-redirect-in.xsl");
-        liaison.setStylesheet(xsl);
-        File out = new File("xalan2-redirect-out-dummy.tmp");
-        File in = getFile("/taskdefs/optional/xsltliaison-in.xsl");
-        ClassLoader orig = Thread.currentThread().getContextClassLoader();
-        try {
-            liaison.addParam("xalan-version", "2");
-            // Use the JRE's Xerces, not lib/optional/xerces.jar:
-            Thread.currentThread().setContextClassLoader(new ClassLoader(ClassLoader.getSystemClassLoader().getParent()) {
-                public InputStream getResourceAsStream(String name) {
-                    if (name.startsWith("META-INF/services/")) {
-                        // work around JAXP #6723276 in JDK 6
-                        return new ByteArrayInputStream(new byte[0]);
-                    }
-                    return super.getResourceAsStream(name);
-                }
-            });
-            // Tickle #52382:
-            System.setSecurityManager(new SecurityManager() {public void checkPermission(Permission perm) {}});
-            liaison.transform(in, out);
-        } finally {
-            out.delete();
-            Thread.currentThread().setContextClassLoader(orig);
-            System.setSecurityManager(null);
-        }
-    }
-
-    @Test
-    public void testMultipleTransform() throws Exception {
-        File xsl = getFile("/taskdefs/optional/xsltliaison-in.xsl");
-        liaison.setStylesheet(xsl);
-        liaison.addParam("param", "value");
-        File in = getFile("/taskdefs/optional/xsltliaison-in.xml");
-        // test for 10 consecutives transform
-        for (int i = 0; i < 50; i++){
-            File out = new File("xsltliaison" + i + ".tmp");
-            try {
-                liaison.transform(in, out);
-            } catch (Exception e){
-                throw new BuildException("failed in transform " + i, e);
-            } finally {
-                out.delete();
-            }
-        }
-    }
-
-    @Test
-    public void testSystemId(){
-        File file = null;
-        if ( File.separatorChar == '\\' ){
-            file = new File("d:\\jdk");
-        } else {
-            file = new File("/user/local/bin");
-        }
-        String systemid = JAXPUtils.getSystemId(file);
-        assertTrue("SystemIDs should start by file:/", systemid.startsWith("file:/"));
-        assertTrue("SystemIDs should not start with file:////", !systemid.startsWith("file:////"));
-    }
-
-    public void log(String message) {
-        throw new AssertionFailedError("Liaison sent message: "+message);
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.tools.ant.taskdefs.optional;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.security.Permission;
+
+import junit.framework.AssertionFailedError;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.taskdefs.XSLTLiaison;
+import org.apache.tools.ant.taskdefs.XSLTLogger;
+import org.apache.tools.ant.util.JAXPUtils;
+import org.junit.After;
+import org.junit.Assume;
+import org.junit.Test;
+
+/**
+ * TraX XSLTLiaison testcase
+ */
+public class TraXLiaisonTest extends AbstractXSLTLiaisonTest
+    implements XSLTLogger {
+
+
+    @After
+    public void tearDown() {
+        File f = new File("xalan2-redirect-out.tmp");
+        if (f.exists()) {
+            f.delete();
+        }
+    }
+
+    public XSLTLiaison createLiaison() throws Exception {
+        TraXLiaison l = new TraXLiaison();
+        l.setLogger(this);
+        return l;
+    }
+
+    @Test
+    public void testXalan2Redirect() throws Exception {
+        try {
+            getClass().getClassLoader().loadClass("org.apache.xalan.lib.Redirect");
+        } catch (Exception exc) {
+            Assume.assumeNoException("xalan redirect is not on the classpath", exc);
+        }
+        File xsl = getFile("/taskdefs/optional/xalan-redirect-in.xsl");
+        liaison.setStylesheet(xsl);
+        File out = new File("xalan2-redirect-out-dummy.tmp");
+        File in = getFile("/taskdefs/optional/xsltliaison-in.xsl");
+        ClassLoader orig = Thread.currentThread().getContextClassLoader();
+        try {
+            liaison.addParam("xalan-version", "2");
+            // Use the JRE's Xerces, not lib/optional/xerces.jar:
+            Thread.currentThread().setContextClassLoader(new ClassLoader(ClassLoader.getSystemClassLoader().getParent()) {
+                public InputStream getResourceAsStream(String name) {
+                    if (name.startsWith("META-INF/services/")) {
+                        // work around JAXP #6723276 in JDK 6
+                        return new ByteArrayInputStream(new byte[0]);
+                    }
+                    return super.getResourceAsStream(name);
+                }
+            });
+            // Tickle #52382:
+            System.setSecurityManager(new SecurityManager() {public void checkPermission(Permission perm) {}});
+            liaison.transform(in, out);
+        } finally {
+            out.delete();
+            Thread.currentThread().setContextClassLoader(orig);
+            System.setSecurityManager(null);
+        }
+    }
+
+    @Test
+    public void testMultipleTransform() throws Exception {
+        File xsl = getFile("/taskdefs/optional/xsltliaison-in.xsl");
+        liaison.setStylesheet(xsl);
+        liaison.addParam("param", "value");
+        File in = getFile("/taskdefs/optional/xsltliaison-in.xml");
+        // test for 10 consecutives transform
+        for (int i = 0; i < 50; i++){
+            File out = new File("xsltliaison" + i + ".tmp");
+            try {
+                liaison.transform(in, out);
+            } catch (Exception e){
+                throw new BuildException("failed in transform " + i, e);
+            } finally {
+                out.delete();
+            }
+        }
+    }
+
+    @Test
+    public void testSystemId(){
+        File file = null;
+        if ( File.separatorChar == '\\' ){
+            file = new File("d:\\jdk");
+        } else {
+            file = new File("/user/local/bin");
+        }
+        String systemid = JAXPUtils.getSystemId(file);
+        assertTrue("SystemIDs should start by file:/", systemid.startsWith("file:/"));
+        assertTrue("SystemIDs should not start with file:////", !systemid.startsWith("file:////"));
+    }
+
+    public void log(String message) {
+        throw new AssertionFailedError("Liaison sent message: "+message);
+    }
+
+}


[4/4] ant git commit: Merge branch '1.9.x'

Posted by bo...@apache.org.
Merge branch '1.9.x'


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/c50b683c
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/c50b683c
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/c50b683c

Branch: refs/heads/master
Commit: c50b683cfb9c2ae3a1929c38648ec2e492718f34
Parents: 047844b a62d5f9
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun Jul 31 10:16:52 2016 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun Jul 31 10:16:52 2016 +0200

----------------------------------------------------------------------
 WHATSNEW                                        |   9 +
 manual/Tasks/touch.html                         |   6 +-
 manual/Types/resources.html                     |   5 +-
 manual/Types/selectors.html                     |   9 +-
 .../org/apache/tools/ant/taskdefs/Touch.java    |  34 +-
 .../ant/types/resources/selectors/Date.java     |  13 +-
 .../tools/ant/types/selectors/BaseSelector.java |  17 +-
 .../tools/ant/types/selectors/DateSelector.java |  14 +-
 .../ant/taskdefs/optional/TraXLiaisonTest.java  | 258 +++++------
 .../ant/types/selectors/DateSelectorTest.java   | 458 +++++++++----------
 10 files changed, 426 insertions(+), 397 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/c50b683c/WHATSNEW
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ant/blob/c50b683c/manual/Types/selectors.html
----------------------------------------------------------------------


[2/4] ant git commit: line-ends

Posted by bo...@apache.org.
line-ends


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/2df17719
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/2df17719
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/2df17719

Branch: refs/heads/master
Commit: 2df17719cb24d34a73f884526aae939effa916d4
Parents: 77fbe37
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun Jul 31 09:30:37 2016 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun Jul 31 09:30:37 2016 +0200

----------------------------------------------------------------------
 .../ant/types/selectors/DateSelectorTest.java   | 458 +++++++++----------
 1 file changed, 229 insertions(+), 229 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/2df17719/src/tests/junit/org/apache/tools/ant/types/selectors/DateSelectorTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/DateSelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/selectors/DateSelectorTest.java
index 7eb9501..e622be1 100644
--- a/src/tests/junit/org/apache/tools/ant/types/selectors/DateSelectorTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/selectors/DateSelectorTest.java
@@ -1,229 +1,229 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-
-package org.apache.tools.ant.types.selectors;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.types.Parameter;
-import org.junit.Assume;
-import org.junit.Rule;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-
-/**
- * Tests Date Selectors.
- *
- */
-public class DateSelectorTest {
-
-    @Rule
-    public final BaseSelectorRule selectorRule = new BaseSelectorRule();
-
-
-    /**
-     * Test the code that validates the selector.
-     */
-    @Test
-    public void testValidate() {
-        DateSelector s = new DateSelector();
-        try {
-            s.isSelected(selectorRule.getProject().getBaseDir(),selectorRule.getFilenames()[0],selectorRule.getFiles()[0]);
-            fail("DateSelector did not check for required fields");
-        } catch (BuildException be1) {
-            assertEquals("You must provide a datetime or the number of "
-                    + "milliseconds.", be1.getMessage());
-        }
-
-        s = new DateSelector();
-        s.setDatetime("01/01/1969 01:01 AM");
-        try {
-            s.isSelected(selectorRule.getProject().getBaseDir(),selectorRule.getFilenames()[0],selectorRule.getFiles()[0]);
-            fail("DateSelector did not check for Datetime being in the "
-                    + "allowable range");
-        } catch (BuildException be2) {
-            assertEquals("Date of 01/01/1969 01:01 AM results in negative "
-                    + "milliseconds value relative to epoch (January 1, "
-                    + "1970, 00:00:00 GMT).", be2.getMessage());
-        }
-
-        s = new DateSelector();
-        s.setDatetime("this is not a date");
-        try {
-            s.isSelected(selectorRule.getProject().getBaseDir(),selectorRule.getFilenames()[0],selectorRule.getFiles()[0]);
-            fail("DateSelector did not check for Datetime being in a "
-                    + "valid format");
-        } catch (BuildException be3) {
-            assertEquals("Date of this is not a date"
-                        + " Cannot be parsed correctly. It should be in"
-                        + " 'MM/dd/yyyy hh:mm a' format.", be3.getMessage());
-        }
-
-        s = new DateSelector();
-        Parameter param = new Parameter();
-        param.setName("garbage in");
-        param.setValue("garbage out");
-        Parameter[] params = new Parameter[1];
-        params[0] = param;
-        s.setParameters(params);
-        try {
-            s.isSelected(selectorRule.getProject().getBaseDir(),selectorRule.getFilenames()[0],selectorRule.getFiles()[0]);
-            fail("DateSelector did not check for valid parameter element");
-        } catch (BuildException be4) {
-            assertEquals("Invalid parameter garbage in", be4.getMessage());
-        }
-
-        s = new DateSelector();
-        param = new Parameter();
-        param.setName("millis");
-        param.setValue("garbage out");
-        params[0] = param;
-        s.setParameters(params);
-        try {
-            s.isSelected(selectorRule.getProject().getBaseDir(),selectorRule.getFilenames()[0],selectorRule.getFiles()[0]);
-            fail("DateSelector did not check for valid millis parameter");
-        } catch (BuildException be5) {
-            assertEquals("Invalid millisecond setting garbage out",
-                    be5.getMessage());
-        }
-
-        s = new DateSelector();
-        param = new Parameter();
-        param.setName("granularity");
-        param.setValue("garbage out");
-        params[0] = param;
-        s.setParameters(params);
-        try {
-            s.isSelected(selectorRule.getProject().getBaseDir(),selectorRule.getFilenames()[0],selectorRule.getFiles()[0]);
-            fail("DateSelector did not check for valid granularity parameter");
-        } catch (BuildException be6) {
-            assertEquals("Invalid granularity setting garbage out",
-                    be6.getMessage());
-        }
-
-    }
-
-    /**
-     * Tests to make sure that the selector is selecting files correctly.
-     */
-    @Test
-    public void testSelectionBehaviour() {
-        DateSelector s;
-        String results;
-
-        DateSelector.TimeComparisons before = new
-                DateSelector.TimeComparisons();
-        before.setValue("before");
-        DateSelector.TimeComparisons equal = new
-                DateSelector.TimeComparisons();
-        equal.setValue("equal");
-        DateSelector.TimeComparisons after = new
-                DateSelector.TimeComparisons();
-        after.setValue("after");
-
-
-        s = new DateSelector();
-        s.setDatetime("10/10/1999 1:45 PM");
-        s.setWhen(before);
-        results = selectorRule.selectionString(s);
-        assertEquals("TFFFFFFFFFFT", results);
-
-        s = new DateSelector();
-        s.setDatetime("10/10/1999 1:45 PM");
-        s.setWhen(before);
-        s.setCheckdirs(true);
-        results = selectorRule.selectionString(s);
-        assertEquals("FFFFFFFFFFFF", results);
-
-        s = new DateSelector();
-        s.setDatetime("10/10/1999 1:45 PM");
-        s.setWhen(after);
-        results = selectorRule.selectionString(s);
-        assertEquals("TTTTTTTTTTTT", results);
-
-        s = new DateSelector();
-        s.setDatetime("11/21/2001 4:54 AM");
-        s.setWhen(before);
-        results = selectorRule.selectionString(s);
-        assertEquals("TFTFFFFFFFFT", results);
-
-        s = new DateSelector();
-        s.setDatetime("11/21/2001 4:55 AM");
-
-        long milliseconds = s.getMillis();
-        s.setWhen(equal);
-        results = selectorRule.selectionString(s);
-        assertEquals("TTFFTFFFTTTT", results);
-
-        s = new DateSelector();
-        s.setMillis(milliseconds);
-        s.setWhen(equal);
-        results = selectorRule.selectionString(s);
-        assertEquals("TTFFTFFFTTTT", results);
-
-        s = new DateSelector();
-        s.setDatetime("11/21/2001 4:56 AM");
-        s.setWhen(after);
-        results = selectorRule.selectionString(s);
-        assertEquals("TFFTFTTTFFFT", results);
-
-        s = new DateSelector();
-        Parameter param1 = new Parameter();
-        Parameter param2 = new Parameter();
-        param1.setName("datetime");
-        param1.setValue("11/21/2001 4:56 AM");
-        param2.setName("when");
-        param2.setValue("after");
-        Parameter[] params = {param1,param2};
-        s.setParameters(params);
-        results = selectorRule.selectionString(s);
-        assertEquals("TFFTFTTTFFFT", results);
-
-        s = new DateSelector();
-        long testtime = selectorRule.getMirrorFiles()[5].lastModified();
-        s.setMillis(testtime);
-        s.setWhen(after);
-        s.setGranularity(2);
-
-        // setup the modified timestamp to match what the test needs, although be aware that the 3rd and 4th
-        // files don't exist so can't be changed, so don't try and loop over them
-        for (int i = 1; i <=2; i++) {
-            Assume.assumeTrue("Cannot setup file times for test", selectorRule.getMirrorFiles()[i].setLastModified(testtime - (3*60*60*100)));
-        }
-
-
-        results = selectorRule.mirrorSelectionString(s);
-        assertEquals("TFFFFTTTTTTT", results);
-
-        s = new DateSelector();
-        testtime = selectorRule.getMirrorFiles()[6].lastModified();
-        s.setMillis(testtime);
-        s.setWhen(before);
-        s.setGranularity(2);
-        for (int i = 7; i <= 10; i++) {
-            Assume.assumeTrue("Cannot setup file times for test", selectorRule.getMirrorFiles()[i].setLastModified(testtime + (3*60*60*100)));
-        }
-
-        results = selectorRule.mirrorSelectionString(s);
-        assertEquals("TTTTTTTFFFFT", results);
-
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.tools.ant.types.selectors;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Parameter;
+import org.junit.Assume;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+
+/**
+ * Tests Date Selectors.
+ *
+ */
+public class DateSelectorTest {
+
+    @Rule
+    public final BaseSelectorRule selectorRule = new BaseSelectorRule();
+
+
+    /**
+     * Test the code that validates the selector.
+     */
+    @Test
+    public void testValidate() {
+        DateSelector s = new DateSelector();
+        try {
+            s.isSelected(selectorRule.getProject().getBaseDir(),selectorRule.getFilenames()[0],selectorRule.getFiles()[0]);
+            fail("DateSelector did not check for required fields");
+        } catch (BuildException be1) {
+            assertEquals("You must provide a datetime or the number of "
+                    + "milliseconds.", be1.getMessage());
+        }
+
+        s = new DateSelector();
+        s.setDatetime("01/01/1969 01:01 AM");
+        try {
+            s.isSelected(selectorRule.getProject().getBaseDir(),selectorRule.getFilenames()[0],selectorRule.getFiles()[0]);
+            fail("DateSelector did not check for Datetime being in the "
+                    + "allowable range");
+        } catch (BuildException be2) {
+            assertEquals("Date of 01/01/1969 01:01 AM results in negative "
+                    + "milliseconds value relative to epoch (January 1, "
+                    + "1970, 00:00:00 GMT).", be2.getMessage());
+        }
+
+        s = new DateSelector();
+        s.setDatetime("this is not a date");
+        try {
+            s.isSelected(selectorRule.getProject().getBaseDir(),selectorRule.getFilenames()[0],selectorRule.getFiles()[0]);
+            fail("DateSelector did not check for Datetime being in a "
+                    + "valid format");
+        } catch (BuildException be3) {
+            assertEquals("Date of this is not a date"
+                        + " Cannot be parsed correctly. It should be in"
+                        + " 'MM/dd/yyyy hh:mm a' format.", be3.getMessage());
+        }
+
+        s = new DateSelector();
+        Parameter param = new Parameter();
+        param.setName("garbage in");
+        param.setValue("garbage out");
+        Parameter[] params = new Parameter[1];
+        params[0] = param;
+        s.setParameters(params);
+        try {
+            s.isSelected(selectorRule.getProject().getBaseDir(),selectorRule.getFilenames()[0],selectorRule.getFiles()[0]);
+            fail("DateSelector did not check for valid parameter element");
+        } catch (BuildException be4) {
+            assertEquals("Invalid parameter garbage in", be4.getMessage());
+        }
+
+        s = new DateSelector();
+        param = new Parameter();
+        param.setName("millis");
+        param.setValue("garbage out");
+        params[0] = param;
+        s.setParameters(params);
+        try {
+            s.isSelected(selectorRule.getProject().getBaseDir(),selectorRule.getFilenames()[0],selectorRule.getFiles()[0]);
+            fail("DateSelector did not check for valid millis parameter");
+        } catch (BuildException be5) {
+            assertEquals("Invalid millisecond setting garbage out",
+                    be5.getMessage());
+        }
+
+        s = new DateSelector();
+        param = new Parameter();
+        param.setName("granularity");
+        param.setValue("garbage out");
+        params[0] = param;
+        s.setParameters(params);
+        try {
+            s.isSelected(selectorRule.getProject().getBaseDir(),selectorRule.getFilenames()[0],selectorRule.getFiles()[0]);
+            fail("DateSelector did not check for valid granularity parameter");
+        } catch (BuildException be6) {
+            assertEquals("Invalid granularity setting garbage out",
+                    be6.getMessage());
+        }
+
+    }
+
+    /**
+     * Tests to make sure that the selector is selecting files correctly.
+     */
+    @Test
+    public void testSelectionBehaviour() {
+        DateSelector s;
+        String results;
+
+        DateSelector.TimeComparisons before = new
+                DateSelector.TimeComparisons();
+        before.setValue("before");
+        DateSelector.TimeComparisons equal = new
+                DateSelector.TimeComparisons();
+        equal.setValue("equal");
+        DateSelector.TimeComparisons after = new
+                DateSelector.TimeComparisons();
+        after.setValue("after");
+
+
+        s = new DateSelector();
+        s.setDatetime("10/10/1999 1:45 PM");
+        s.setWhen(before);
+        results = selectorRule.selectionString(s);
+        assertEquals("TFFFFFFFFFFT", results);
+
+        s = new DateSelector();
+        s.setDatetime("10/10/1999 1:45 PM");
+        s.setWhen(before);
+        s.setCheckdirs(true);
+        results = selectorRule.selectionString(s);
+        assertEquals("FFFFFFFFFFFF", results);
+
+        s = new DateSelector();
+        s.setDatetime("10/10/1999 1:45 PM");
+        s.setWhen(after);
+        results = selectorRule.selectionString(s);
+        assertEquals("TTTTTTTTTTTT", results);
+
+        s = new DateSelector();
+        s.setDatetime("11/21/2001 4:54 AM");
+        s.setWhen(before);
+        results = selectorRule.selectionString(s);
+        assertEquals("TFTFFFFFFFFT", results);
+
+        s = new DateSelector();
+        s.setDatetime("11/21/2001 4:55 AM");
+
+        long milliseconds = s.getMillis();
+        s.setWhen(equal);
+        results = selectorRule.selectionString(s);
+        assertEquals("TTFFTFFFTTTT", results);
+
+        s = new DateSelector();
+        s.setMillis(milliseconds);
+        s.setWhen(equal);
+        results = selectorRule.selectionString(s);
+        assertEquals("TTFFTFFFTTTT", results);
+
+        s = new DateSelector();
+        s.setDatetime("11/21/2001 4:56 AM");
+        s.setWhen(after);
+        results = selectorRule.selectionString(s);
+        assertEquals("TFFTFTTTFFFT", results);
+
+        s = new DateSelector();
+        Parameter param1 = new Parameter();
+        Parameter param2 = new Parameter();
+        param1.setName("datetime");
+        param1.setValue("11/21/2001 4:56 AM");
+        param2.setName("when");
+        param2.setValue("after");
+        Parameter[] params = {param1,param2};
+        s.setParameters(params);
+        results = selectorRule.selectionString(s);
+        assertEquals("TFFTFTTTFFFT", results);
+
+        s = new DateSelector();
+        long testtime = selectorRule.getMirrorFiles()[5].lastModified();
+        s.setMillis(testtime);
+        s.setWhen(after);
+        s.setGranularity(2);
+
+        // setup the modified timestamp to match what the test needs, although be aware that the 3rd and 4th
+        // files don't exist so can't be changed, so don't try and loop over them
+        for (int i = 1; i <=2; i++) {
+            Assume.assumeTrue("Cannot setup file times for test", selectorRule.getMirrorFiles()[i].setLastModified(testtime - (3*60*60*100)));
+        }
+
+
+        results = selectorRule.mirrorSelectionString(s);
+        assertEquals("TFFFFTTTTTTT", results);
+
+        s = new DateSelector();
+        testtime = selectorRule.getMirrorFiles()[6].lastModified();
+        s.setMillis(testtime);
+        s.setWhen(before);
+        s.setGranularity(2);
+        for (int i = 7; i <= 10; i++) {
+            Assume.assumeTrue("Cannot setup file times for test", selectorRule.getMirrorFiles()[i].setLastModified(testtime + (3*60*60*100)));
+        }
+
+        results = selectorRule.mirrorSelectionString(s);
+        assertEquals("TTTTTTTFFFFT", results);
+
+    }
+
+}