ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gin...@apache.org
Subject [14/22] ant git commit: Normalise tabulation and line breaks (cf master)
Date Wed, 29 Nov 2017 22:06:10 GMT
http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/types/CommandlineJavaTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/CommandlineJavaTest.java b/src/tests/junit/org/apache/tools/ant/types/CommandlineJavaTest.java
index b8ce90f..abfb70f 100644
--- a/src/tests/junit/org/apache/tools/ant/types/CommandlineJavaTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/CommandlineJavaTest.java
@@ -1,191 +1,191 @@
-/*
- *  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;
-
-
-import org.apache.tools.ant.MagicNames;
-import org.apache.tools.ant.Project;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-/**
- * JUnit testcases for org.apache.tools.ant.CommandlineJava
- *
- */
-public class CommandlineJavaTest {
-
-    private String cloneVm;
-
-
-    private Project project;
-
-    @Before
-    public void setUp() {
-        project = new Project();
-        project.setBasedir(System.getProperty("root"));
-        project.setProperty("build.sysclasspath", "ignore");
-        cloneVm = System.getProperty("ant.build.clonevm");
-        if (cloneVm != null) {
-            System.setProperty("ant.build.clonevm", "false");
-        }
-    }
-
-    @After
-    public void tearDown() {
-        if (cloneVm != null) {
-            System.setProperty("ant.build.clonevm", cloneVm);
-        }
-    }
-
-    @Test
-    public void testGetCommandline() throws Exception {
-        CommandlineJava c = new CommandlineJava();
-        c.createArgument().setValue("org.apache.tools.ant.CommandlineJavaTest");
-        c.setClassname("junit.textui.TestRunner");
-        c.createVmArgument().setValue("-Djava.compiler=NONE");
-        String[] s = c.getCommandline();
-        assertEquals("no classpath", 4, s.length);
-        /*
-         * After changing CommandlineJava to search for the java
-         * executable, I don't know, how to tests the value returned
-         * here without using the same logic as applied in the class
-         * itself.
-         *
-         * assertTrue("no classpath", "java", s[0]);
-         */
-        assertEquals("no classpath", "-Djava.compiler=NONE", s[1]);
-        assertEquals("no classpath", "junit.textui.TestRunner", s[2]);
-        assertEquals("no classpath",
-                     "org.apache.tools.ant.CommandlineJavaTest", s[3]);
-        try {
-            c.clone();
-        } catch (NullPointerException ex) {
-            fail("cloning should work without classpath specified");
-        }
-
-        c.createClasspath(project).setLocation(project.resolveFile("build.xml"));
-        c.createClasspath(project).setLocation(project.resolveFile(
-            System.getProperty(MagicNames.ANT_HOME)+"/lib/ant.jar"));
-        s = c.getCommandline();
-        assertEquals("with classpath", 6, s.length);
-        //        assertEquals("with classpath", "java", s[0]);
-        assertEquals("with classpath", "-Djava.compiler=NONE", s[1]);
-        assertEquals("with classpath", "-classpath", s[2]);
-        assertTrue("build.xml contained",
-               s[3].indexOf("build.xml"+java.io.File.pathSeparator) >= 0);
-        assertTrue("ant.jar contained", s[3].endsWith("ant.jar"));
-        assertEquals("with classpath", "junit.textui.TestRunner", s[4]);
-        assertEquals("with classpath",
-                     "org.apache.tools.ant.CommandlineJavaTest", s[5]);
-    }
-
-    @Test
-    public void testJarOption() throws Exception {
-        CommandlineJava c = new CommandlineJava();
-        c.createArgument().setValue("arg1");
-        c.setJar("myfile.jar");
-        c.createVmArgument().setValue("-classic");
-        c.createVmArgument().setValue("-Dx=y");
-        String[] s = c.getCommandline();
-        assertEquals("-classic", s[1]);
-        assertEquals("-Dx=y", s[2]);
-        assertEquals("-jar", s[3]);
-        assertEquals("myfile.jar", s[4]);
-        assertEquals("arg1", s[5]);
-    }
-
-    @Test
-    public void testSysproperties() {
-        String currentClasspath = System.getProperty("java.class.path");
-        assertNotNull(currentClasspath);
-        assertNull(System.getProperty("key"));
-        CommandlineJava c = new CommandlineJava();
-        Environment.Variable v = new Environment.Variable();
-        v.setKey("key");
-        v.setValue("value");
-        c.addSysproperty(v);
-
-        project.setProperty("key2", "value2");
-        PropertySet ps = new PropertySet();
-        ps.setProject(project);
-        ps.appendName("key2");
-        c.addSyspropertyset(ps);
-
-        try {
-            c.setSystemProperties();
-            String newClasspath = System.getProperty("java.class.path");
-            assertNotNull(newClasspath);
-            assertEquals(currentClasspath, newClasspath);
-            assertNotNull(System.getProperty("key"));
-            assertEquals("value", System.getProperty("key"));
-            assertTrue(System.getProperties().containsKey("java.class.path"));
-            assertNotNull(System.getProperty("key2"));
-            assertEquals("value2", System.getProperty("key2"));
-        } finally {
-            c.restoreSystemProperties();
-        }
-        assertNull(System.getProperty("key"));
-        assertNull(System.getProperty("key2"));
-    }
-
-    @Test
-    public void testAssertions() throws Exception {
-        CommandlineJava c = new CommandlineJava();
-        c.createArgument().setValue("org.apache.tools.ant.CommandlineJavaTest");
-        c.setClassname("junit.textui.TestRunner");
-        c.createVmArgument().setValue("-Djava.compiler=NONE");
-        Assertions a = new Assertions();
-        a.setProject(project);
-        Assertions.EnabledAssertion ea = new Assertions.EnabledAssertion();
-        ea.setClass("junit.textui.TestRunner");
-        a.addEnable(ea);
-        c.setAssertions(a);
-
-        String[] expected = new String[] {
-            null,
-            "-Djava.compiler=NONE",
-            "-ea:junit.textui.TestRunner",
-            "junit.textui.TestRunner",
-            "org.apache.tools.ant.CommandlineJavaTest",
-        };
-            
-        // only the second iteration would pass because of PR 27218
-        for (int i = 0; i < 3; i++) {
-            String[] s = c.getCommandline();
-            assertEquals(expected.length, s.length);
-            for (int j = 1; j < expected.length; j++) {
-                assertEquals(expected[j], s[j]);
-            }
-        }
-        CommandlineJava c2 = (CommandlineJava) c.clone();
-        String[] s = c2.getCommandline();
-        assertEquals(expected.length, s.length);
-        for (int j = 1; j < expected.length; j++) {
-            assertEquals(expected[j], s[j]);
-        }
-    }
-
-}
+/*
+ *  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;
+
+
+import org.apache.tools.ant.MagicNames;
+import org.apache.tools.ant.Project;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+/**
+ * JUnit testcases for org.apache.tools.ant.CommandlineJava
+ *
+ */
+public class CommandlineJavaTest {
+
+    private String cloneVm;
+
+
+    private Project project;
+
+    @Before
+    public void setUp() {
+        project = new Project();
+        project.setBasedir(System.getProperty("root"));
+        project.setProperty("build.sysclasspath", "ignore");
+        cloneVm = System.getProperty("ant.build.clonevm");
+        if (cloneVm != null) {
+            System.setProperty("ant.build.clonevm", "false");
+        }
+    }
+
+    @After
+    public void tearDown() {
+        if (cloneVm != null) {
+            System.setProperty("ant.build.clonevm", cloneVm);
+        }
+    }
+
+    @Test
+    public void testGetCommandline() throws Exception {
+        CommandlineJava c = new CommandlineJava();
+        c.createArgument().setValue("org.apache.tools.ant.CommandlineJavaTest");
+        c.setClassname("junit.textui.TestRunner");
+        c.createVmArgument().setValue("-Djava.compiler=NONE");
+        String[] s = c.getCommandline();
+        assertEquals("no classpath", 4, s.length);
+        /*
+         * After changing CommandlineJava to search for the java
+         * executable, I don't know, how to tests the value returned
+         * here without using the same logic as applied in the class
+         * itself.
+         *
+         * assertTrue("no classpath", "java", s[0]);
+         */
+        assertEquals("no classpath", "-Djava.compiler=NONE", s[1]);
+        assertEquals("no classpath", "junit.textui.TestRunner", s[2]);
+        assertEquals("no classpath",
+                     "org.apache.tools.ant.CommandlineJavaTest", s[3]);
+        try {
+            c.clone();
+        } catch (NullPointerException ex) {
+            fail("cloning should work without classpath specified");
+        }
+
+        c.createClasspath(project).setLocation(project.resolveFile("build.xml"));
+        c.createClasspath(project).setLocation(project.resolveFile(
+            System.getProperty(MagicNames.ANT_HOME)+"/lib/ant.jar"));
+        s = c.getCommandline();
+        assertEquals("with classpath", 6, s.length);
+        //        assertEquals("with classpath", "java", s[0]);
+        assertEquals("with classpath", "-Djava.compiler=NONE", s[1]);
+        assertEquals("with classpath", "-classpath", s[2]);
+        assertTrue("build.xml contained",
+               s[3].indexOf("build.xml"+java.io.File.pathSeparator) >= 0);
+        assertTrue("ant.jar contained", s[3].endsWith("ant.jar"));
+        assertEquals("with classpath", "junit.textui.TestRunner", s[4]);
+        assertEquals("with classpath",
+                     "org.apache.tools.ant.CommandlineJavaTest", s[5]);
+    }
+
+    @Test
+    public void testJarOption() throws Exception {
+        CommandlineJava c = new CommandlineJava();
+        c.createArgument().setValue("arg1");
+        c.setJar("myfile.jar");
+        c.createVmArgument().setValue("-classic");
+        c.createVmArgument().setValue("-Dx=y");
+        String[] s = c.getCommandline();
+        assertEquals("-classic", s[1]);
+        assertEquals("-Dx=y", s[2]);
+        assertEquals("-jar", s[3]);
+        assertEquals("myfile.jar", s[4]);
+        assertEquals("arg1", s[5]);
+    }
+
+    @Test
+    public void testSysproperties() {
+        String currentClasspath = System.getProperty("java.class.path");
+        assertNotNull(currentClasspath);
+        assertNull(System.getProperty("key"));
+        CommandlineJava c = new CommandlineJava();
+        Environment.Variable v = new Environment.Variable();
+        v.setKey("key");
+        v.setValue("value");
+        c.addSysproperty(v);
+
+        project.setProperty("key2", "value2");
+        PropertySet ps = new PropertySet();
+        ps.setProject(project);
+        ps.appendName("key2");
+        c.addSyspropertyset(ps);
+
+        try {
+            c.setSystemProperties();
+            String newClasspath = System.getProperty("java.class.path");
+            assertNotNull(newClasspath);
+            assertEquals(currentClasspath, newClasspath);
+            assertNotNull(System.getProperty("key"));
+            assertEquals("value", System.getProperty("key"));
+            assertTrue(System.getProperties().containsKey("java.class.path"));
+            assertNotNull(System.getProperty("key2"));
+            assertEquals("value2", System.getProperty("key2"));
+        } finally {
+            c.restoreSystemProperties();
+        }
+        assertNull(System.getProperty("key"));
+        assertNull(System.getProperty("key2"));
+    }
+
+    @Test
+    public void testAssertions() throws Exception {
+        CommandlineJava c = new CommandlineJava();
+        c.createArgument().setValue("org.apache.tools.ant.CommandlineJavaTest");
+        c.setClassname("junit.textui.TestRunner");
+        c.createVmArgument().setValue("-Djava.compiler=NONE");
+        Assertions a = new Assertions();
+        a.setProject(project);
+        Assertions.EnabledAssertion ea = new Assertions.EnabledAssertion();
+        ea.setClass("junit.textui.TestRunner");
+        a.addEnable(ea);
+        c.setAssertions(a);
+
+        String[] expected = new String[] {
+            null,
+            "-Djava.compiler=NONE",
+            "-ea:junit.textui.TestRunner",
+            "junit.textui.TestRunner",
+            "org.apache.tools.ant.CommandlineJavaTest",
+        };
+
+        // only the second iteration would pass because of PR 27218
+        for (int i = 0; i < 3; i++) {
+            String[] s = c.getCommandline();
+            assertEquals(expected.length, s.length);
+            for (int j = 1; j < expected.length; j++) {
+                assertEquals(expected[j], s[j]);
+            }
+        }
+        CommandlineJava c2 = (CommandlineJava) c.clone();
+        String[] s = c2.getCommandline();
+        assertEquals(expected.length, s.length);
+        for (int j = 1; j < expected.length; j++) {
+            assertEquals(expected[j], s[j]);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java b/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java
index ca5fef2..e8e4442 100644
--- a/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java
@@ -1,180 +1,180 @@
-/*
- *  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;
-
-import org.apache.tools.ant.BuildException;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-import static org.junit.Assert.assertNotNull;
-
-/**
- * JUnit 3 testcases for org.apache.tools.ant.CommandLine
- *
- */
-public class CommandlineTest {
-
-    @Test
-    public void testTokenizer() {
-        String[] s = Commandline.translateCommandline("1 2 3");
-        assertEquals("Simple case", 3, s.length);
-        for (int i=0; i<3; i++) {
-            assertEquals(""+(i+1), s[i]);
-        }
-
-        s = Commandline.translateCommandline("");
-        assertEquals("empty string", 0, s.length);
-
-        s = Commandline.translateCommandline(null);
-        assertEquals("null", 0, s.length);
-
-        s = Commandline.translateCommandline("1 \'2\' 3");
-        assertEquals("Simple case with single quotes", 3, s.length);
-        assertEquals("Single quotes have been stripped", "2", s[1]);
-
-        s = Commandline.translateCommandline("1 \"2\" 3");
-        assertEquals("Simple case with double quotes", 3, s.length);
-        assertEquals("Double quotes have been stripped", "2", s[1]);
-
-        s = Commandline.translateCommandline("1 \"2 3\" 4");
-        assertEquals("Case with double quotes and whitespace", 3, s.length);
-        assertEquals("Double quotes stripped, space included", "2 3", s[1]);
-
-        s = Commandline.translateCommandline("1 \"2\'3\" 4");
-        assertEquals("Case with double quotes around single quote", 3, s.length);
-        assertEquals("Double quotes stripped, single quote included", "2\'3",
-                     s[1]);
-
-        s = Commandline.translateCommandline("1 \'2 3\' 4");
-        assertEquals("Case with single quotes and whitespace", 3, s.length);
-        assertEquals("Single quotes stripped, space included", "2 3", s[1]);
-
-        s = Commandline.translateCommandline("1 \'2\"3\' 4");
-        assertEquals("Case with single quotes around double quote", 3, s.length);
-        assertEquals("Single quotes stripped, double quote included", "2\"3",
-                     s[1]);
-
-        // \ doesn't have a special meaning anymore - this is different from
-        // what the Unix sh does but causes a lot of problems on DOS
-        // based platforms otherwise
-        s = Commandline.translateCommandline("1 2\\ 3 4");
-        assertEquals("case with quoted whitespace", 4, s.length);
-        assertEquals("backslash included", "2\\", s[1]);
-
-        // "" should become a single empty argument, same for ''
-        // PR 5906
-        s = Commandline.translateCommandline("\"\" a");
-        assertEquals("Doublequoted null arg prepend", 2, s.length);
-        assertEquals("Doublequoted null arg prepend", "", s[0]);
-        assertEquals("Doublequoted null arg prepend", "a", s[1]);
-        s = Commandline.translateCommandline("a \"\"");
-        assertEquals("Doublequoted null arg append", 2, s.length);
-        assertEquals("Doublequoted null arg append", "a", s[0]);
-        assertEquals("Doublequoted null arg append", "", s[1]);
-        s = Commandline.translateCommandline("\"\"");
-        assertEquals("Doublequoted null arg", 1, s.length);
-        assertEquals("Doublequoted null arg", "", s[0]);
-
-        s = Commandline.translateCommandline("\'\' a");
-        assertEquals("Singlequoted null arg prepend", 2, s.length);
-        assertEquals("Singlequoted null arg prepend", "", s[0]);
-        assertEquals("Singlequoted null arg prepend", "a", s[1]);
-        s = Commandline.translateCommandline("a \'\'");
-        assertEquals("Singlequoted null arg append", 2, s.length);
-        assertEquals("Singlequoted null arg append", "a", s[0]);
-        assertEquals("Singlequoted null arg append", "", s[1]);
-        s = Commandline.translateCommandline("\'\'");
-        assertEquals("Singlequoted null arg", 1, s.length);
-        assertEquals("Singlequoted null arg", "", s[0]);
-
-        // now to the expected failures
-
-        try {
-            Commandline.translateCommandline("a \'b c");
-            fail("unbalanced single quotes undetected");
-        } catch (BuildException be) {
-            assertEquals("unbalanced quotes in a \'b c", be.getMessage());
-        }
-
-        try {
-            Commandline.translateCommandline("a \"b c");
-            fail("unbalanced double quotes undetected");
-        } catch (BuildException be) {
-            assertEquals("unbalanced quotes in a \"b c", be.getMessage());
-        }
-    }
-
-    @Test
-    public void testToString() {
-        assertEquals("", Commandline.toString(new String[0]));
-        assertEquals("", Commandline.toString(null));
-        assertEquals("1 2 3", Commandline.toString(new String[] {"1", "2", "3"}));
-        assertEquals("1 \"2 3\"", Commandline.toString(new String[] {"1", "2 3"}));
-        assertEquals("1 \"2\'3\"", Commandline.toString(new String[] {"1", "2\'3"}));
-        assertEquals("1 \'2\"3\'", Commandline.toString(new String[] {"1", "2\"3"}));
-    }
-
-    @Test
-    public void testAwkCommand() {
-        Commandline c = new Commandline();
-        c.setExecutable("awk");
-        c.createArgument().setValue("'NR == 2 { print $NF }'");
-        String[] s = c.getCommandline();
-        assertNotNull(s);
-        assertEquals(2, s.length);
-        assertEquals("awk", s[0]);
-        assertEquals("'NR == 2 { print $NF }'", s[1]);
-    }
-
-    @Test
-    public void testPrefix() {
-        Commandline c = new Commandline();
-        Commandline.Argument a = c.createArgument();
-        a.setValue("foo");
-        a.setPrefix("-f=");
-        String[] s = c.getCommandline();
-        assertEquals(1, s.length);
-        assertEquals("-f=foo", s[0]);
-    }
-
-    @Test
-    public void testSuffix() {
-        Commandline c = new Commandline();
-        Commandline.Argument a = c.createArgument();
-        a.setValue("foo");
-        a.setSuffix(",1");
-        String[] s = c.getCommandline();
-        assertEquals(1, s.length);
-        assertEquals("foo,1", s[0]);
-    }
-
-    @Test
-    public void testPrefixSuffixLine() {
-        Commandline c = new Commandline();
-        Commandline.Argument a = c.createArgument();
-        a.setLine("one two");
-        a.setPrefix("number ");
-        a.setSuffix(".");
-        String[] s = c.getCommandline();
-        assertEquals(2, s.length);
-        assertEquals("number one.", s[0]);
-        assertEquals("number two.", s[1]);
-    }
-}
+/*
+ *  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;
+
+import org.apache.tools.ant.BuildException;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * JUnit 3 testcases for org.apache.tools.ant.CommandLine
+ *
+ */
+public class CommandlineTest {
+
+    @Test
+    public void testTokenizer() {
+        String[] s = Commandline.translateCommandline("1 2 3");
+        assertEquals("Simple case", 3, s.length);
+        for (int i=0; i<3; i++) {
+            assertEquals(""+(i+1), s[i]);
+        }
+
+        s = Commandline.translateCommandline("");
+        assertEquals("empty string", 0, s.length);
+
+        s = Commandline.translateCommandline(null);
+        assertEquals("null", 0, s.length);
+
+        s = Commandline.translateCommandline("1 \'2\' 3");
+        assertEquals("Simple case with single quotes", 3, s.length);
+        assertEquals("Single quotes have been stripped", "2", s[1]);
+
+        s = Commandline.translateCommandline("1 \"2\" 3");
+        assertEquals("Simple case with double quotes", 3, s.length);
+        assertEquals("Double quotes have been stripped", "2", s[1]);
+
+        s = Commandline.translateCommandline("1 \"2 3\" 4");
+        assertEquals("Case with double quotes and whitespace", 3, s.length);
+        assertEquals("Double quotes stripped, space included", "2 3", s[1]);
+
+        s = Commandline.translateCommandline("1 \"2\'3\" 4");
+        assertEquals("Case with double quotes around single quote", 3, s.length);
+        assertEquals("Double quotes stripped, single quote included", "2\'3",
+                     s[1]);
+
+        s = Commandline.translateCommandline("1 \'2 3\' 4");
+        assertEquals("Case with single quotes and whitespace", 3, s.length);
+        assertEquals("Single quotes stripped, space included", "2 3", s[1]);
+
+        s = Commandline.translateCommandline("1 \'2\"3\' 4");
+        assertEquals("Case with single quotes around double quote", 3, s.length);
+        assertEquals("Single quotes stripped, double quote included", "2\"3",
+                     s[1]);
+
+        // \ doesn't have a special meaning anymore - this is different from
+        // what the Unix sh does but causes a lot of problems on DOS
+        // based platforms otherwise
+        s = Commandline.translateCommandline("1 2\\ 3 4");
+        assertEquals("case with quoted whitespace", 4, s.length);
+        assertEquals("backslash included", "2\\", s[1]);
+
+        // "" should become a single empty argument, same for ''
+        // PR 5906
+        s = Commandline.translateCommandline("\"\" a");
+        assertEquals("Doublequoted null arg prepend", 2, s.length);
+        assertEquals("Doublequoted null arg prepend", "", s[0]);
+        assertEquals("Doublequoted null arg prepend", "a", s[1]);
+        s = Commandline.translateCommandline("a \"\"");
+        assertEquals("Doublequoted null arg append", 2, s.length);
+        assertEquals("Doublequoted null arg append", "a", s[0]);
+        assertEquals("Doublequoted null arg append", "", s[1]);
+        s = Commandline.translateCommandline("\"\"");
+        assertEquals("Doublequoted null arg", 1, s.length);
+        assertEquals("Doublequoted null arg", "", s[0]);
+
+        s = Commandline.translateCommandline("\'\' a");
+        assertEquals("Singlequoted null arg prepend", 2, s.length);
+        assertEquals("Singlequoted null arg prepend", "", s[0]);
+        assertEquals("Singlequoted null arg prepend", "a", s[1]);
+        s = Commandline.translateCommandline("a \'\'");
+        assertEquals("Singlequoted null arg append", 2, s.length);
+        assertEquals("Singlequoted null arg append", "a", s[0]);
+        assertEquals("Singlequoted null arg append", "", s[1]);
+        s = Commandline.translateCommandline("\'\'");
+        assertEquals("Singlequoted null arg", 1, s.length);
+        assertEquals("Singlequoted null arg", "", s[0]);
+
+        // now to the expected failures
+
+        try {
+            Commandline.translateCommandline("a \'b c");
+            fail("unbalanced single quotes undetected");
+        } catch (BuildException be) {
+            assertEquals("unbalanced quotes in a \'b c", be.getMessage());
+        }
+
+        try {
+            Commandline.translateCommandline("a \"b c");
+            fail("unbalanced double quotes undetected");
+        } catch (BuildException be) {
+            assertEquals("unbalanced quotes in a \"b c", be.getMessage());
+        }
+    }
+
+    @Test
+    public void testToString() {
+        assertEquals("", Commandline.toString(new String[0]));
+        assertEquals("", Commandline.toString(null));
+        assertEquals("1 2 3", Commandline.toString(new String[] {"1", "2", "3"}));
+        assertEquals("1 \"2 3\"", Commandline.toString(new String[] {"1", "2 3"}));
+        assertEquals("1 \"2\'3\"", Commandline.toString(new String[] {"1", "2\'3"}));
+        assertEquals("1 \'2\"3\'", Commandline.toString(new String[] {"1", "2\"3"}));
+    }
+
+    @Test
+    public void testAwkCommand() {
+        Commandline c = new Commandline();
+        c.setExecutable("awk");
+        c.createArgument().setValue("'NR == 2 { print $NF }'");
+        String[] s = c.getCommandline();
+        assertNotNull(s);
+        assertEquals(2, s.length);
+        assertEquals("awk", s[0]);
+        assertEquals("'NR == 2 { print $NF }'", s[1]);
+    }
+
+    @Test
+    public void testPrefix() {
+        Commandline c = new Commandline();
+        Commandline.Argument a = c.createArgument();
+        a.setValue("foo");
+        a.setPrefix("-f=");
+        String[] s = c.getCommandline();
+        assertEquals(1, s.length);
+        assertEquals("-f=foo", s[0]);
+    }
+
+    @Test
+    public void testSuffix() {
+        Commandline c = new Commandline();
+        Commandline.Argument a = c.createArgument();
+        a.setValue("foo");
+        a.setSuffix(",1");
+        String[] s = c.getCommandline();
+        assertEquals(1, s.length);
+        assertEquals("foo,1", s[0]);
+    }
+
+    @Test
+    public void testPrefixSuffixLine() {
+        Commandline c = new Commandline();
+        Commandline.Argument a = c.createArgument();
+        a.setLine("one two");
+        a.setPrefix("number ");
+        a.setSuffix(".");
+        String[] s = c.getCommandline();
+        assertEquals(2, s.length);
+        assertEquals("number one.", s[0]);
+        assertEquals("number two.", s[1]);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/types/DescriptionTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/DescriptionTest.java b/src/tests/junit/org/apache/tools/ant/types/DescriptionTest.java
index f021228..31b56f9 100644
--- a/src/tests/junit/org/apache/tools/ant/types/DescriptionTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/DescriptionTest.java
@@ -1,59 +1,59 @@
-/*
- *  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;
-
-import org.apache.tools.ant.BuildFileRule;
-import org.junit.Rule;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * FilterSet testing
- *
- */
-public class DescriptionTest {
-
-    @Rule
-    public BuildFileRule buildRule = new BuildFileRule();
-    
-    @Test
-    public void test1() {
-        buildRule.configureProject("src/etc/testcases/types/description1.xml");
-        assertEquals("Single description failed", "Test Project Description", buildRule.getProject().getDescription());
-    }
-
-    @Test
-    public void test2() {
-        buildRule.configureProject("src/etc/testcases/types/description2.xml");
-        assertEquals("Multi line description failed", "Multi Line\nProject Description", buildRule.getProject().getDescription());
-    }
-
-    @Test
-    public void test3() {
-        buildRule.configureProject("src/etc/testcases/types/description3.xml");
-        assertEquals("Multi instance description failed", "Multi Instance Project Description", buildRule.getProject().getDescription());
-    }
-
-    @Test
-    public void test4() {
-        buildRule.configureProject("src/etc/testcases/types/description4.xml");
-        assertEquals("Multi instance nested description failed", "Multi Instance Nested Project Description", buildRule.getProject().getDescription());
-    }
-}
+/*
+ *  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;
+
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * FilterSet testing
+ *
+ */
+public class DescriptionTest {
+
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
+
+    @Test
+    public void test1() {
+        buildRule.configureProject("src/etc/testcases/types/description1.xml");
+        assertEquals("Single description failed", "Test Project Description", buildRule.getProject().getDescription());
+    }
+
+    @Test
+    public void test2() {
+        buildRule.configureProject("src/etc/testcases/types/description2.xml");
+        assertEquals("Multi line description failed", "Multi Line\nProject Description", buildRule.getProject().getDescription());
+    }
+
+    @Test
+    public void test3() {
+        buildRule.configureProject("src/etc/testcases/types/description3.xml");
+        assertEquals("Multi instance description failed", "Multi Instance Project Description", buildRule.getProject().getDescription());
+    }
+
+    @Test
+    public void test4() {
+        buildRule.configureProject("src/etc/testcases/types/description4.xml");
+        assertEquals("Multi instance nested description failed", "Multi Instance Nested Project Description", buildRule.getProject().getDescription());
+    }
+}

http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/types/DirSetTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/DirSetTest.java b/src/tests/junit/org/apache/tools/ant/types/DirSetTest.java
index 4fd2b5a..8c659ba 100644
--- a/src/tests/junit/org/apache/tools/ant/types/DirSetTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/DirSetTest.java
@@ -1,94 +1,94 @@
-/*
- *  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;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import org.apache.tools.ant.BuildException;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-/**
- * JUnit 3 testcases for org.apache.tools.ant.types.DirSet.
- *
- */
-public class DirSetTest extends AbstractFileSetTest {
-
-    protected AbstractFileSet getInstance() {
-        return new DirSet();
-    }
-
-    @Test
-    public void testFileSetIsNoDirSet() {
-        DirSet ds = (DirSet) getInstance();
-        ds.setProject(getProject());
-        FileSet fs = new FileSet();
-        fs.setProject(getProject());
-        getProject().addReference("dummy", fs);
-        ds.setRefid(new Reference(getProject(), "dummy"));
-        try {
-            ds.getDir(getProject());
-            fail("DirSet created from FileSet reference");
-        } catch (BuildException e) {
-            assertEquals("dummy doesn\'t denote a DirSet", e.getMessage());
-        }
-
-        ds = (DirSet) getInstance();
-        ds.setProject(getProject());
-        getProject().addReference("dummy2", ds);
-        fs.setRefid(new Reference(getProject(), "dummy2"));
-        try {
-            fs.getDir(getProject());
-            fail("FileSet created from DirSet reference");
-        } catch (BuildException e) {
-            assertEquals("dummy2 doesn\'t denote a FileSet", e.getMessage());
-        }
-    }
-
-    public void testToString() throws Exception {
-        File tmp = File.createTempFile("DirSetTest", "");
-        try {
-            tmp.delete();
-            File a = new File(tmp, "a");
-            a.mkdirs();
-            File b = new File(tmp, "b");
-            File bc = new File(b, "c");
-            bc.mkdirs();
-            new FileOutputStream(new File(a, "x")).close();
-            new FileOutputStream(new File(b, "x")).close();
-            new FileOutputStream(new File(bc, "x")).close();
-            DirSet ds = new DirSet();
-            ds.setProject(getProject());
-            ds.setDir(tmp);
-            ds.setIncludes("b/");
-            assertEquals("b;b" + File.separator + "c", ds.toString());
-        } finally {
-            new File(tmp, "a/x").delete();
-            new File(tmp, "a").delete();
-            new File(tmp, "b/c/x").delete();
-            new File(tmp, "b/c").delete();
-            new File(tmp, "b/x").delete();
-            new File(tmp, "b").delete();
-            tmp.delete();
-        }
-    }
-
-}
+/*
+ *  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;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import org.apache.tools.ant.BuildException;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * JUnit 3 testcases for org.apache.tools.ant.types.DirSet.
+ *
+ */
+public class DirSetTest extends AbstractFileSetTest {
+
+    protected AbstractFileSet getInstance() {
+        return new DirSet();
+    }
+
+    @Test
+    public void testFileSetIsNoDirSet() {
+        DirSet ds = (DirSet) getInstance();
+        ds.setProject(getProject());
+        FileSet fs = new FileSet();
+        fs.setProject(getProject());
+        getProject().addReference("dummy", fs);
+        ds.setRefid(new Reference(getProject(), "dummy"));
+        try {
+            ds.getDir(getProject());
+            fail("DirSet created from FileSet reference");
+        } catch (BuildException e) {
+            assertEquals("dummy doesn\'t denote a DirSet", e.getMessage());
+        }
+
+        ds = (DirSet) getInstance();
+        ds.setProject(getProject());
+        getProject().addReference("dummy2", ds);
+        fs.setRefid(new Reference(getProject(), "dummy2"));
+        try {
+            fs.getDir(getProject());
+            fail("FileSet created from DirSet reference");
+        } catch (BuildException e) {
+            assertEquals("dummy2 doesn\'t denote a FileSet", e.getMessage());
+        }
+    }
+
+    public void testToString() throws Exception {
+        File tmp = File.createTempFile("DirSetTest", "");
+        try {
+            tmp.delete();
+            File a = new File(tmp, "a");
+            a.mkdirs();
+            File b = new File(tmp, "b");
+            File bc = new File(b, "c");
+            bc.mkdirs();
+            new FileOutputStream(new File(a, "x")).close();
+            new FileOutputStream(new File(b, "x")).close();
+            new FileOutputStream(new File(bc, "x")).close();
+            DirSet ds = new DirSet();
+            ds.setProject(getProject());
+            ds.setDir(tmp);
+            ds.setIncludes("b/");
+            assertEquals("b;b" + File.separator + "c", ds.toString());
+        } finally {
+            new File(tmp, "a/x").delete();
+            new File(tmp, "a").delete();
+            new File(tmp, "b/c/x").delete();
+            new File(tmp, "b/c").delete();
+            new File(tmp, "b/x").delete();
+            new File(tmp, "b").delete();
+            tmp.delete();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/types/EnumeratedAttributeTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/EnumeratedAttributeTest.java b/src/tests/junit/org/apache/tools/ant/types/EnumeratedAttributeTest.java
index 7961b72..dcb8a78 100644
--- a/src/tests/junit/org/apache/tools/ant/types/EnumeratedAttributeTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/EnumeratedAttributeTest.java
@@ -1,106 +1,106 @@
-/*
- *  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;
-
-
-import org.apache.tools.ant.BuildException;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-/**
- * JUnit testcases for org.apache.tools.ant.EnumeratedAttribute.
- */
-public class EnumeratedAttributeTest {
-
-    private static String[] expected = {"a", "b", "c"};
-
-    @Test
-    public void testContains() {
-        EnumeratedAttribute t1 = new TestNormal();
-        for (int i=0; i<expected.length; i++) {
-            assertTrue(expected[i]+" is in TestNormal",
-                   t1.containsValue(expected[i]));
-            assertTrue(expected[i].toUpperCase()+" is in TestNormal",
-                   !t1.containsValue(expected[i].toUpperCase()));
-        }
-        assertTrue("TestNormal doesn\'t have \"d\" attribute",
-               !t1.containsValue("d"));
-        assertTrue("TestNull doesn\'t have \"d\" attribute and doesn\'t die",
-               !(new TestNull()).containsValue("d"));
-    }
-
-    @Test
-    public void testFactory() {
-		Factory ea = (Factory)EnumeratedAttribute.getInstance(Factory.class, "one");
-		assertEquals("Factory did not set the right value.", ea.getValue(), "one");
-		try {
-	    	EnumeratedAttribute.getInstance(Factory.class, "illegal");
-	    	fail("Factory should fail when trying to set an illegal value.");
-		} catch (BuildException be) {
-			// was expected
-            //TODO assert exception message
-		}
-	}
-
-    @Test
-	public void testExceptions() {
-        EnumeratedAttribute t1 = new TestNormal();
-        for (int i=0; i<expected.length; i++) {
-            try {
-                t1.setValue(expected[i]);
-            } catch (BuildException be) {
-                fail("unexpected exception for value "+expected[i]);
-            }
-        }
-        try {
-            t1.setValue("d");
-            fail("expected exception for value \"d\"");
-        } catch (BuildException be) {
-         //TODO assert build exception
-        }
-        try {
-            (new TestNull()).setValue("d");
-            fail("expected exception for value \"d\" in TestNull");
-        } catch (BuildException be) {
-            //TODO assert exception message
-        }
-    }
-
-    public static class TestNormal extends EnumeratedAttribute {
-        public String[] getValues() {
-            return expected;
-        }
-    }
-
-    public static class TestNull extends EnumeratedAttribute {
-        public String[] getValues() {
-            return null;
-        }
-    }
-
-    public static class Factory extends EnumeratedAttribute {
-    	public String[] getValues() {
-    		return new String[] { "one", "two", "three" };
-    	}
-    }
-    
-}
+/*
+ *  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;
+
+
+import org.apache.tools.ant.BuildException;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * JUnit testcases for org.apache.tools.ant.EnumeratedAttribute.
+ */
+public class EnumeratedAttributeTest {
+
+    private static String[] expected = {"a", "b", "c"};
+
+    @Test
+    public void testContains() {
+        EnumeratedAttribute t1 = new TestNormal();
+        for (int i=0; i<expected.length; i++) {
+            assertTrue(expected[i]+" is in TestNormal",
+                   t1.containsValue(expected[i]));
+            assertTrue(expected[i].toUpperCase()+" is in TestNormal",
+                   !t1.containsValue(expected[i].toUpperCase()));
+        }
+        assertTrue("TestNormal doesn\'t have \"d\" attribute",
+               !t1.containsValue("d"));
+        assertTrue("TestNull doesn\'t have \"d\" attribute and doesn\'t die",
+               !(new TestNull()).containsValue("d"));
+    }
+
+    @Test
+    public void testFactory() {
+        Factory ea = (Factory)EnumeratedAttribute.getInstance(Factory.class, "one");
+        assertEquals("Factory did not set the right value.", ea.getValue(), "one");
+        try {
+            EnumeratedAttribute.getInstance(Factory.class, "illegal");
+            fail("Factory should fail when trying to set an illegal value.");
+        } catch (BuildException be) {
+            // was expected
+            //TODO assert exception message
+        }
+    }
+
+    @Test
+    public void testExceptions() {
+        EnumeratedAttribute t1 = new TestNormal();
+        for (int i=0; i<expected.length; i++) {
+            try {
+                t1.setValue(expected[i]);
+            } catch (BuildException be) {
+                fail("unexpected exception for value "+expected[i]);
+            }
+        }
+        try {
+            t1.setValue("d");
+            fail("expected exception for value \"d\"");
+        } catch (BuildException be) {
+         //TODO assert build exception
+        }
+        try {
+            (new TestNull()).setValue("d");
+            fail("expected exception for value \"d\" in TestNull");
+        } catch (BuildException be) {
+            //TODO assert exception message
+        }
+    }
+
+    public static class TestNormal extends EnumeratedAttribute {
+        public String[] getValues() {
+            return expected;
+        }
+    }
+
+    public static class TestNull extends EnumeratedAttribute {
+        public String[] getValues() {
+            return null;
+        }
+    }
+
+    public static class Factory extends EnumeratedAttribute {
+        public String[] getValues() {
+            return new String[] { "one", "two", "three" };
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/types/FileListTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/FileListTest.java b/src/tests/junit/org/apache/tools/ant/types/FileListTest.java
index 1393b00..0fe59f7 100644
--- a/src/tests/junit/org/apache/tools/ant/types/FileListTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/FileListTest.java
@@ -1,163 +1,163 @@
-/*
- *  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;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.BuildFileRule;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import java.io.File;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-/**
- * Some tests for filelist.
- */
-
-public class FileListTest {
-
-    @Rule
-    public BuildFileRule buildRule = new BuildFileRule();
-    
-    @Before
-    public void setUp() {
-        buildRule.configureProject("src/etc/testcases/types/filelist.xml");
-    }
-    
-    @Test
-    public void testEmptyElementIfIsReference() {
-        FileList f = new FileList();
-        f.setDir(buildRule.getProject().resolveFile("."));
-        try {
-            f.setRefid(new Reference(buildRule.getProject(), "dummyref"));
-            fail("Can add reference to FileList with directory attribute set.");
-        } catch (BuildException be) {
-            assertEquals("You must not specify more than one attribute when using refid",
-                         be.getMessage());
-        }
-
-        f = new FileList();
-        f.setFiles("foo.xml,c/d/bar.xml");
-        try {
-            f.setRefid(new Reference(buildRule.getProject(), "dummyref"));
-            fail("Can add reference to FileList with file attribute set.");
-        } catch (BuildException be) {
-            assertEquals("You must not specify more than one attribute when using refid",
-                         be.getMessage());
-        }
-
-        f = new FileList();
-        f.setRefid(new Reference(buildRule.getProject(), "dummyref"));
-        try {
-            f.setFiles("a/b/foo.java");
-            fail("Can set files in FileList that is a reference.");
-        } catch (BuildException be) {
-            assertEquals("You must not specify more than one attribute when using refid",
-                         be.getMessage());
-        }
-        try {
-            f.setDir(buildRule.getProject().resolveFile("."));
-            fail("Can set dir in FileList that is a reference.");
-        } catch (BuildException be) {
-            assertEquals("You must not specify more than one attribute when using refid",
-                         be.getMessage());
-        }
-    }
-
-    @Test
-    public void testCircularReferenceCheck() {
-        FileList f = new FileList();
-        buildRule.getProject().addReference("dummy", f);
-        f.setRefid(new Reference(buildRule.getProject(), "dummy"));
-        try {
-            f.getDir(buildRule.getProject());
-            fail("Can make FileList a Reference to itself.");
-        } catch (BuildException be) {
-            assertEquals("This data type contains a circular reference.",
-                         be.getMessage());
-        }
-        try {
-            f.getFiles(buildRule.getProject());
-            fail("Can make FileList a Reference to itself.");
-        } catch (BuildException be) {
-            assertEquals("This data type contains a circular reference.",
-                         be.getMessage());
-        }
-
-        // dummy1 --> dummy2 --> dummy3 --> dummy1
-        FileList f1 = new FileList();
-        buildRule.getProject().addReference("dummy1", f1);
-        f1.setRefid(new Reference(buildRule.getProject(), "dummy2"));
-        FileList f2 = new FileList();
-        buildRule.getProject().addReference("dummy2", f2);
-        f2.setRefid(new Reference(buildRule.getProject(), "dummy3"));
-        FileList f3 = new FileList();
-        buildRule.getProject().addReference("dummy3", f3);
-        f3.setRefid(new Reference(buildRule.getProject(), "dummy1"));
-        try {
-            f1.getDir(buildRule.getProject());
-            fail("Can make circular reference.");
-        } catch (BuildException be) {
-            assertEquals("This data type contains a circular reference.",
-                         be.getMessage());
-        }
-        try {
-            f1.getFiles(buildRule.getProject());
-            fail("Can make circular reference.");
-        } catch (BuildException be) {
-            assertEquals("This data type contains a circular reference.",
-                         be.getMessage());
-        }
-
-        // dummy1 --> dummy2 --> dummy3
-        // (which has the Project's basedir as root).
-        f1 = new FileList();
-        buildRule.getProject().addReference("dummy1", f1);
-        f1.setRefid(new Reference(buildRule.getProject(), "dummy2"));
-        f2 = new FileList();
-        buildRule.getProject().addReference("dummy2", f2);
-        f2.setRefid(new Reference(buildRule.getProject(), "dummy3"));
-        f3 = new FileList();
-        buildRule.getProject().addReference("dummy3", f3);
-        f3.setDir(buildRule.getProject().resolveFile("."));
-        File dir = f1.getDir(buildRule.getProject());
-        assertEquals("Dir is basedir", dir, buildRule.getProject().getBaseDir());
-    }
-
-    @Test
-    public void testSimple() {
-        buildRule.executeTarget("simple");
-        assertEquals("/abc/a", buildRule.getLog());
-    }
-
-    @Test
-    public void testDouble() {
-        buildRule.executeTarget("double");
-        assertEquals("/abc/a:/abc/b", buildRule.getLog());
-    }
-
-    @Test
-    public void testNested() {
-        buildRule.executeTarget("nested");
-        assertEquals("/abc/a:/abc/b", buildRule.getLog());
-    }
-}
+/*
+ *  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;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import java.io.File;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Some tests for filelist.
+ */
+
+public class FileListTest {
+
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
+
+    @Before
+    public void setUp() {
+        buildRule.configureProject("src/etc/testcases/types/filelist.xml");
+    }
+
+    @Test
+    public void testEmptyElementIfIsReference() {
+        FileList f = new FileList();
+        f.setDir(buildRule.getProject().resolveFile("."));
+        try {
+            f.setRefid(new Reference(buildRule.getProject(), "dummyref"));
+            fail("Can add reference to FileList with directory attribute set.");
+        } catch (BuildException be) {
+            assertEquals("You must not specify more than one attribute when using refid",
+                         be.getMessage());
+        }
+
+        f = new FileList();
+        f.setFiles("foo.xml,c/d/bar.xml");
+        try {
+            f.setRefid(new Reference(buildRule.getProject(), "dummyref"));
+            fail("Can add reference to FileList with file attribute set.");
+        } catch (BuildException be) {
+            assertEquals("You must not specify more than one attribute when using refid",
+                         be.getMessage());
+        }
+
+        f = new FileList();
+        f.setRefid(new Reference(buildRule.getProject(), "dummyref"));
+        try {
+            f.setFiles("a/b/foo.java");
+            fail("Can set files in FileList that is a reference.");
+        } catch (BuildException be) {
+            assertEquals("You must not specify more than one attribute when using refid",
+                         be.getMessage());
+        }
+        try {
+            f.setDir(buildRule.getProject().resolveFile("."));
+            fail("Can set dir in FileList that is a reference.");
+        } catch (BuildException be) {
+            assertEquals("You must not specify more than one attribute when using refid",
+                         be.getMessage());
+        }
+    }
+
+    @Test
+    public void testCircularReferenceCheck() {
+        FileList f = new FileList();
+        buildRule.getProject().addReference("dummy", f);
+        f.setRefid(new Reference(buildRule.getProject(), "dummy"));
+        try {
+            f.getDir(buildRule.getProject());
+            fail("Can make FileList a Reference to itself.");
+        } catch (BuildException be) {
+            assertEquals("This data type contains a circular reference.",
+                         be.getMessage());
+        }
+        try {
+            f.getFiles(buildRule.getProject());
+            fail("Can make FileList a Reference to itself.");
+        } catch (BuildException be) {
+            assertEquals("This data type contains a circular reference.",
+                         be.getMessage());
+        }
+
+        // dummy1 --> dummy2 --> dummy3 --> dummy1
+        FileList f1 = new FileList();
+        buildRule.getProject().addReference("dummy1", f1);
+        f1.setRefid(new Reference(buildRule.getProject(), "dummy2"));
+        FileList f2 = new FileList();
+        buildRule.getProject().addReference("dummy2", f2);
+        f2.setRefid(new Reference(buildRule.getProject(), "dummy3"));
+        FileList f3 = new FileList();
+        buildRule.getProject().addReference("dummy3", f3);
+        f3.setRefid(new Reference(buildRule.getProject(), "dummy1"));
+        try {
+            f1.getDir(buildRule.getProject());
+            fail("Can make circular reference.");
+        } catch (BuildException be) {
+            assertEquals("This data type contains a circular reference.",
+                         be.getMessage());
+        }
+        try {
+            f1.getFiles(buildRule.getProject());
+            fail("Can make circular reference.");
+        } catch (BuildException be) {
+            assertEquals("This data type contains a circular reference.",
+                         be.getMessage());
+        }
+
+        // dummy1 --> dummy2 --> dummy3
+        // (which has the Project's basedir as root).
+        f1 = new FileList();
+        buildRule.getProject().addReference("dummy1", f1);
+        f1.setRefid(new Reference(buildRule.getProject(), "dummy2"));
+        f2 = new FileList();
+        buildRule.getProject().addReference("dummy2", f2);
+        f2.setRefid(new Reference(buildRule.getProject(), "dummy3"));
+        f3 = new FileList();
+        buildRule.getProject().addReference("dummy3", f3);
+        f3.setDir(buildRule.getProject().resolveFile("."));
+        File dir = f1.getDir(buildRule.getProject());
+        assertEquals("Dir is basedir", dir, buildRule.getProject().getBaseDir());
+    }
+
+    @Test
+    public void testSimple() {
+        buildRule.executeTarget("simple");
+        assertEquals("/abc/a", buildRule.getLog());
+    }
+
+    @Test
+    public void testDouble() {
+        buildRule.executeTarget("double");
+        assertEquals("/abc/a:/abc/b", buildRule.getLog());
+    }
+
+    @Test
+    public void testNested() {
+        buildRule.executeTarget("nested");
+        assertEquals("/abc/a:/abc/b", buildRule.getLog());
+    }
+}

http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/types/FileSetTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/FileSetTest.java b/src/tests/junit/org/apache/tools/ant/types/FileSetTest.java
index f58a3f0..8a1c35a 100644
--- a/src/tests/junit/org/apache/tools/ant/types/FileSetTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/FileSetTest.java
@@ -1,36 +1,36 @@
-/*
- *  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;
-
-
-/**
- * JUnit 3 testcases for org.apache.tools.ant.types.FileSet.
- *
- * <p>This doesn't actually test much, mainly reference handling.
- *
- */
-
-public class FileSetTest extends AbstractFileSetTest {
-
-
-    protected AbstractFileSet getInstance() {
-        return new FileSet();
-    }
-
-}
+/*
+ *  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;
+
+
+/**
+ * JUnit 3 testcases for org.apache.tools.ant.types.FileSet.
+ *
+ * <p>This doesn't actually test much, mainly reference handling.
+ *
+ */
+
+public class FileSetTest extends AbstractFileSetTest {
+
+
+    protected AbstractFileSet getInstance() {
+        return new FileSet();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java b/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java
index 7122ea1..9a17687 100644
--- a/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java
@@ -1,239 +1,239 @@
-/*
- *  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;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.BuildFileRule;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.Hashtable;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-/**
- * FilterSet testing
- *
- */
-public class FilterSetTest {
-
-    static private final int BUF_SIZE = 32768;
-
-    @Rule
-    public BuildFileRule buildRule = new BuildFileRule();
-
-    @Before
-    public void setUp() {
-        buildRule.configureProject("src/etc/testcases/types/filterset.xml");
-    }
-
-    @After
-    public void tearDown() {
-        buildRule.executeTarget("cleanup");
-    }
-
-    @Test
-    public void test1() throws IOException {
-        buildRule.executeTarget("test1");
-        assertTrue("Filterset 1 failed", compareFiles("src/etc/testcases/types/gold/filterset1.txt",
-                                                      "src/etc/testcases/types/dest1.txt"));
-    }
-
-    @Test
-    public void test2() throws IOException {
-        buildRule.executeTarget("test2");
-        assertTrue("Filterset 2 failed", compareFiles("src/etc/testcases/types/gold/filterset2.txt",
-                                                      "src/etc/testcases/types/dest2.txt"));
-    }
-
-    @Test
-    public void test3() throws IOException {
-        buildRule.executeTarget("test3");
-        assertTrue("Filterset 3 failed", compareFiles("src/etc/testcases/types/gold/filterset3.txt",
-                                                      "src/etc/testcases/types/dest3.txt"));
-    }
-
-    /**
-     * This will test the recursive FilterSet.  Which means that if
-     * the filter value @test@ contains another filter value, it will
-     * actually resolve.
-     */
-    @Test
-    public void testRecursive() {
-        String result = "it works line";
-        String line="@test@ line";
-        FilterSet fs = new FilterSet();
-        fs.addFilter("test", "@test1@");
-        fs.addFilter("test1","@test2@");
-        fs.addFilter("test2", "it works");
-        fs.setBeginToken("@");
-        fs.setEndToken("@");
-        assertEquals(result, fs.replaceTokens(line));
-    }
-
-    /**
-     * Test to see what happens when the resolving occurs in an
-     * infinite loop.
-     */
-    @Test
-    public void testInfinite() {
-        String result = "@test@ line testvalue";
-        String line = "@test@ line @test3@";
-        FilterSet fs = new FilterSet();
-        fs.addFilter("test", "@test1@");
-        fs.addFilter("test1","@test2@");
-        fs.addFilter("test2", "@test@");
-        fs.addFilter("test3", "testvalue");
-        fs.setBeginToken("@");
-        fs.setEndToken("@");
-        assertEquals(result, fs.replaceTokens(line));
-    }
-
-    /**
-     * Test to see what happens when the resolving occurs in
-     * what would be an infinite loop, but with recursion disabled.
-     */
-    @Test
-    public void testRecursionDisabled() {
-        String result = "@test1@ line testvalue";
-        String line = "@test@ line @test2@";
-        FilterSet fs = new FilterSet();
-        fs.addFilter("test", "@test1@");
-        fs.addFilter("test1","@test@");
-        fs.addFilter("test2", "testvalue");
-        fs.setBeginToken("@");
-        fs.setEndToken("@");
-        fs.setRecurse(false);
-        assertEquals(result, fs.replaceTokens(line));
-    }
-
-    @Test
-    public void testNonInfiniteRecursiveMultipleOnSingleLine() {
-        FilterSet filters = new FilterSet();
-
-        filters.setBeginToken("<");
-        filters.setEndToken(">");
-
-        filters.addFilter("ul", "<itemizedlist>");
-        filters.addFilter("/ul", "</itemizedList>");
-        filters.addFilter("li", "<listitem>");
-        filters.addFilter("/li", "</listitem>");
-
-        String result = "<itemizedlist><listitem>Item 1</listitem> <listitem>Item 2</listitem></itemizedList>";
-        String line = "<ul><li>Item 1</li> <li>Item 2</li></ul>";
-
-        assertEquals(result, filters.replaceTokens(line));
-    }
-    
-    @Test
-    public void testNestedFilterSets() {
-        buildRule.executeTarget("test-nested-filtersets");
-
-        FilterSet fs = (FilterSet) buildRule.getProject().getReference("1");
-        Hashtable filters = fs.getFilterHash();
-        assertEquals(1, filters.size());
-        assertEquals("value1", filters.get("token1"));
-
-        fs = (FilterSet) buildRule.getProject().getReference("2");
-        filters = fs.getFilterHash();
-        assertEquals(2, filters.size());
-        assertEquals("1111", filters.get("aaaa"));
-        assertEquals("2222", filters.get("bbbb"));
-
-        fs = (FilterSet) buildRule.getProject().getReference("3");
-        filters = fs.getFilterHash();
-        assertEquals(1, filters.size());
-        assertEquals("value4", filters.get("token4"));
-
-        fs = (FilterSet) buildRule.getProject().getReference("5");
-        filters = fs.getFilterHash();
-        assertEquals(1, filters.size());
-        assertEquals("value1", filters.get("token1"));
-    }
-
-    @Test
-    public void testFiltersFileElement() {
-        buildRule.executeTarget("testFiltersFileElement");
-    }
-
-    @Test
-    public void testFiltersFileAttribute() {
-        buildRule.executeTarget("testFiltersFileAttribute");
-    }
-
-    @Test
-    public void testMultipleFiltersFiles() {
-        buildRule.executeTarget("testMultipleFiltersFiles");
-    }
-
-    @Test
-    public void testMissingFiltersFile() {
-        try {
-            buildRule.executeTarget("testMissingFiltersFile");
-            fail("should fail due to missing  filtersfile");
-        } catch (BuildException ex) {
-            //TODO assert exception text
-        }
-    }
-
-    @Test
-    public void testAllowMissingFiltersFile() {
-        buildRule.executeTarget("testAllowMissingFiltersFile");
-    }
-
-    private boolean compareFiles(String name1, String name2) throws IOException {
-        File file1 = new File(System.getProperty("root"), name1);
-        File file2 = new File(System.getProperty("root"), name2);
-
-
-        if (!file1.exists() || !file2.exists()) {
-            return false;
-        }
-
-        if (file1.length() != file2.length()) {
-            return false;
-        }
-
-        // byte - byte compare
-        byte[] buffer1 = new byte[BUF_SIZE];
-        byte[] buffer2 = new byte[BUF_SIZE];
-
-        FileInputStream fis1 = new FileInputStream(file1);
-        FileInputStream fis2 = new FileInputStream(file2);
-        int index = 0;
-        int read = 0;
-        while ((read = fis1.read(buffer1)) != -1) {
-            fis2.read(buffer2);
-            for (int i = 0; i < read; ++i, ++index) {
-                if (buffer1[i] != buffer2[i]) {
-                    return false;
-                }
-            }
-        }
-        return true;
-
-    }
-}
+/*
+ *  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;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Hashtable;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * FilterSet testing
+ *
+ */
+public class FilterSetTest {
+
+    static private final int BUF_SIZE = 32768;
+
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
+
+    @Before
+    public void setUp() {
+        buildRule.configureProject("src/etc/testcases/types/filterset.xml");
+    }
+
+    @After
+    public void tearDown() {
+        buildRule.executeTarget("cleanup");
+    }
+
+    @Test
+    public void test1() throws IOException {
+        buildRule.executeTarget("test1");
+        assertTrue("Filterset 1 failed", compareFiles("src/etc/testcases/types/gold/filterset1.txt",
+                                                      "src/etc/testcases/types/dest1.txt"));
+    }
+
+    @Test
+    public void test2() throws IOException {
+        buildRule.executeTarget("test2");
+        assertTrue("Filterset 2 failed", compareFiles("src/etc/testcases/types/gold/filterset2.txt",
+                                                      "src/etc/testcases/types/dest2.txt"));
+    }
+
+    @Test
+    public void test3() throws IOException {
+        buildRule.executeTarget("test3");
+        assertTrue("Filterset 3 failed", compareFiles("src/etc/testcases/types/gold/filterset3.txt",
+                                                      "src/etc/testcases/types/dest3.txt"));
+    }
+
+    /**
+     * This will test the recursive FilterSet.  Which means that if
+     * the filter value @test@ contains another filter value, it will
+     * actually resolve.
+     */
+    @Test
+    public void testRecursive() {
+        String result = "it works line";
+        String line="@test@ line";
+        FilterSet fs = new FilterSet();
+        fs.addFilter("test", "@test1@");
+        fs.addFilter("test1","@test2@");
+        fs.addFilter("test2", "it works");
+        fs.setBeginToken("@");
+        fs.setEndToken("@");
+        assertEquals(result, fs.replaceTokens(line));
+    }
+
+    /**
+     * Test to see what happens when the resolving occurs in an
+     * infinite loop.
+     */
+    @Test
+    public void testInfinite() {
+        String result = "@test@ line testvalue";
+        String line = "@test@ line @test3@";
+        FilterSet fs = new FilterSet();
+        fs.addFilter("test", "@test1@");
+        fs.addFilter("test1","@test2@");
+        fs.addFilter("test2", "@test@");
+        fs.addFilter("test3", "testvalue");
+        fs.setBeginToken("@");
+        fs.setEndToken("@");
+        assertEquals(result, fs.replaceTokens(line));
+    }
+
+    /**
+     * Test to see what happens when the resolving occurs in
+     * what would be an infinite loop, but with recursion disabled.
+     */
+    @Test
+    public void testRecursionDisabled() {
+        String result = "@test1@ line testvalue";
+        String line = "@test@ line @test2@";
+        FilterSet fs = new FilterSet();
+        fs.addFilter("test", "@test1@");
+        fs.addFilter("test1","@test@");
+        fs.addFilter("test2", "testvalue");
+        fs.setBeginToken("@");
+        fs.setEndToken("@");
+        fs.setRecurse(false);
+        assertEquals(result, fs.replaceTokens(line));
+    }
+
+    @Test
+    public void testNonInfiniteRecursiveMultipleOnSingleLine() {
+        FilterSet filters = new FilterSet();
+
+        filters.setBeginToken("<");
+        filters.setEndToken(">");
+
+        filters.addFilter("ul", "<itemizedlist>");
+        filters.addFilter("/ul", "</itemizedList>");
+        filters.addFilter("li", "<listitem>");
+        filters.addFilter("/li", "</listitem>");
+
+        String result = "<itemizedlist><listitem>Item 1</listitem> <listitem>Item 2</listitem></itemizedList>";
+        String line = "<ul><li>Item 1</li> <li>Item 2</li></ul>";
+
+        assertEquals(result, filters.replaceTokens(line));
+    }
+
+    @Test
+    public void testNestedFilterSets() {
+        buildRule.executeTarget("test-nested-filtersets");
+
+        FilterSet fs = (FilterSet) buildRule.getProject().getReference("1");
+        Hashtable filters = fs.getFilterHash();
+        assertEquals(1, filters.size());
+        assertEquals("value1", filters.get("token1"));
+
+        fs = (FilterSet) buildRule.getProject().getReference("2");
+        filters = fs.getFilterHash();
+        assertEquals(2, filters.size());
+        assertEquals("1111", filters.get("aaaa"));
+        assertEquals("2222", filters.get("bbbb"));
+
+        fs = (FilterSet) buildRule.getProject().getReference("3");
+        filters = fs.getFilterHash();
+        assertEquals(1, filters.size());
+        assertEquals("value4", filters.get("token4"));
+
+        fs = (FilterSet) buildRule.getProject().getReference("5");
+        filters = fs.getFilterHash();
+        assertEquals(1, filters.size());
+        assertEquals("value1", filters.get("token1"));
+    }
+
+    @Test
+    public void testFiltersFileElement() {
+        buildRule.executeTarget("testFiltersFileElement");
+    }
+
+    @Test
+    public void testFiltersFileAttribute() {
+        buildRule.executeTarget("testFiltersFileAttribute");
+    }
+
+    @Test
+    public void testMultipleFiltersFiles() {
+        buildRule.executeTarget("testMultipleFiltersFiles");
+    }
+
+    @Test
+    public void testMissingFiltersFile() {
+        try {
+            buildRule.executeTarget("testMissingFiltersFile");
+            fail("should fail due to missing  filtersfile");
+        } catch (BuildException ex) {
+            //TODO assert exception text
+        }
+    }
+
+    @Test
+    public void testAllowMissingFiltersFile() {
+        buildRule.executeTarget("testAllowMissingFiltersFile");
+    }
+
+    private boolean compareFiles(String name1, String name2) throws IOException {
+        File file1 = new File(System.getProperty("root"), name1);
+        File file2 = new File(System.getProperty("root"), name2);
+
+
+        if (!file1.exists() || !file2.exists()) {
+            return false;
+        }
+
+        if (file1.length() != file2.length()) {
+            return false;
+        }
+
+        // byte - byte compare
+        byte[] buffer1 = new byte[BUF_SIZE];
+        byte[] buffer2 = new byte[BUF_SIZE];
+
+        FileInputStream fis1 = new FileInputStream(file1);
+        FileInputStream fis2 = new FileInputStream(file2);
+        int index = 0;
+        int read = 0;
+        while ((read = fis1.read(buffer1)) != -1) {
+            fis2.read(buffer2);
+            for (int i = 0; i < read; ++i, ++index) {
+                if (buffer1[i] != buffer2[i]) {
+                    return false;
+                }
+            }
+        }
+        return true;
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/types/FlexIntegerTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/FlexIntegerTest.java b/src/tests/junit/org/apache/tools/ant/types/FlexIntegerTest.java
index 7435515..3e08b2c 100644
--- a/src/tests/junit/org/apache/tools/ant/types/FlexIntegerTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/FlexIntegerTest.java
@@ -1,74 +1,74 @@
-/*
- *  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;
-
-import org.apache.tools.ant.BuildFileRule;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.BuildException;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class FlexIntegerTest {
-
-    @Rule
-    public BuildFileRule buildRule = new BuildFileRule();
-
-    @Before
-    public void setUp() {
-        buildRule.configureProject("src/etc/testcases/types/flexinteger.xml");
-    }
-
-    @Test
-    public void testFlexInteger() {
-        buildRule.executeTarget("test");
-        assertEquals(buildRule.getProject().getProperty("flexint.value1"), "10");
-        assertEquals(buildRule.getProject().getProperty("flexint.value2"), "8");
-    }
-
-    // This class acts as a custom Ant task also
-    // and uses these variables/methods in that mode
-    private Project taskProject;
-    String propName;
-    private FlexInteger value;
-
-
-
-    public void setPropName(String propName) {
-        this.propName = propName;
-    }
-
-    public void setValue(FlexInteger value) {
-        this.value = value;
-    }
-
-    public void setProject(Project project) {
-        taskProject = project;
-    }
-
-    public void execute() {
-        if (propName == null || value == null) {
-            throw new BuildException("name and value required");
-        }
-
-        taskProject.setNewProperty(propName, value.toString());
-    }
-}
+/*
+ *  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;
+
+import org.apache.tools.ant.BuildFileRule;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.BuildException;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class FlexIntegerTest {
+
+    @Rule
+    public BuildFileRule buildRule = new BuildFileRule();
+
+    @Before
+    public void setUp() {
+        buildRule.configureProject("src/etc/testcases/types/flexinteger.xml");
+    }
+
+    @Test
+    public void testFlexInteger() {
+        buildRule.executeTarget("test");
+        assertEquals(buildRule.getProject().getProperty("flexint.value1"), "10");
+        assertEquals(buildRule.getProject().getProperty("flexint.value2"), "8");
+    }
+
+    // This class acts as a custom Ant task also
+    // and uses these variables/methods in that mode
+    private Project taskProject;
+    String propName;
+    private FlexInteger value;
+
+
+
+    public void setPropName(String propName) {
+        this.propName = propName;
+    }
+
+    public void setValue(FlexInteger value) {
+        this.value = value;
+    }
+
+    public void setProject(Project project) {
+        taskProject = project;
+    }
+
+    public void execute() {
+        if (propName == null || value == null) {
+            throw new BuildException("name and value required");
+        }
+
+        taskProject.setNewProperty(propName, value.toString());
+    }
+}


Mime
View raw message