Repository: ant
Updated Branches:
  refs/heads/master 9558adefe -> 3b0fb1eba


move test constants into a class defined in the test tree


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

Branch: refs/heads/master
Commit: d7bafaa19a66a17333119711dfdb098c979285e0
Parents: 9558ade
Author: Stefan Bodewig <[email protected]>
Authored: Sun Oct 28 20:35:38 2018 +0100
Committer: Stefan Bodewig <[email protected]>
Committed: Sun Oct 28 20:35:38 2018 +0100

----------------------------------------------------------------------
 src/etc/poms/ant-testutil/pom.xml               |  1 +
 src/main/org/apache/tools/ant/MagicNames.java   | 35 -----------
 .../org/apache/tools/ant/BuildFileRule.java     |  8 +--
 .../org/apache/tools/ant/BuildFileTest.java     |  8 +--
 .../org/apache/tools/ant/MagicTestNames.java    | 61 ++++++++++++++++++++
 .../tools/ant/types/CommandlineJavaTest.java    |  5 +-
 .../org/apache/tools/ant/types/PathTest.java    |  6 +-
 .../apache/tools/ant/types/XMLCatalogTest.java  |  6 +-
 .../ant/types/resources/FileResourceTest.java   |  6 +-
 .../apache/tools/ant/util/FileUtilsTest.java    |  4 +-
 .../util/LayoutPreservingPropertiesTest.java    |  4 +-
 .../tools/ant/util/ReaderInputStreamTest.java   |  4 +-
 12 files changed, 88 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/d7bafaa1/src/etc/poms/ant-testutil/pom.xml
----------------------------------------------------------------------
diff --git a/src/etc/poms/ant-testutil/pom.xml 
b/src/etc/poms/ant-testutil/pom.xml
index 3de43ea..50f26c6 100644
--- a/src/etc/poms/ant-testutil/pom.xml
+++ b/src/etc/poms/ant-testutil/pom.xml
@@ -60,6 +60,7 @@
             <include>org/apache/tools/ant/AntAssert*</include>
             <include>org/apache/tools/ant/BuildFile*</include>
             <include>org/apache/tools/ant/FileUtilities*</include>
+            <include>org/apache/tools/ant/MagicTestNames*</include>
             
<include>org/apache/tools/ant/util/regexp/RegexpMatcherTest*</include>
             <include>org/apache/tools/ant/util/regexp/RegexpTest*</include>
             
<include>org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest*</include>

http://git-wip-us.apache.org/repos/asf/ant/blob/d7bafaa1/src/main/org/apache/tools/ant/MagicNames.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/MagicNames.java 
b/src/main/org/apache/tools/ant/MagicNames.java
index 2479bce..074f413 100644
--- a/src/main/org/apache/tools/ant/MagicNames.java
+++ b/src/main/org/apache/tools/ant/MagicNames.java
@@ -322,40 +322,5 @@ public final class MagicNames {
      */
     public static final String TSTAMP_NOW_ISO = "ant.tstamp.now.iso";
 
-    /**
-     * Magic property that makes unit tests based on BuildFileTest
-     * or BuildFileRule ignore externally set basedir
-     * (typically by Surefire/Failsafe)
-     *
-     * Value: {@value}
-     * @since Ant 1.10.6
-     */
-    public static final String TEST_BASEDIR_IGNORE = "ant.test.basedir.ignore";
-
-    /**
-     * Magic property that makes unit tests based on BuildFileTest
-     * or BuildFileRule use build files in alternative locations
-     * (relative to "root" directory)
-     *
-     * Value: {@value}
-     * @since Ant 1.10.6
-     */
-    public static final String TEST_ROOT_DIRECTORY = "root";
-
-    /**
-     * Property for ant process ID set in unit tests by BuildFileTest
-     * or BuildFileRule.
-     *
-     * Value: {@value}
-     */
-    public static final String TEST_PROCESS_ID = "ant.processid";
-
-    /**
-     * Property for ant thread name set in unit tests by BuildFileTest
-     * or BuildFileRule.
-     *
-     * Value: {@value}
-     */
-    public static final String TEST_THREAD_NAME = "ant.threadname";
 }
 

http://git-wip-us.apache.org/repos/asf/ant/blob/d7bafaa1/src/tests/junit/org/apache/tools/ant/BuildFileRule.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/BuildFileRule.java 
b/src/tests/junit/org/apache/tools/ant/BuildFileRule.java
index 48c71ad..bb77b74 100644
--- a/src/tests/junit/org/apache/tools/ant/BuildFileRule.java
+++ b/src/tests/junit/org/apache/tools/ant/BuildFileRule.java
@@ -153,13 +153,13 @@ public class BuildFileRule extends ExternalResource {
         logBuffer = new StringBuffer();
         fullLogBuffer = new StringBuffer();
         project = new Project();
-        if (Boolean.getBoolean(MagicNames.TEST_BASEDIR_IGNORE)) {
+        if (Boolean.getBoolean(MagicTestNames.TEST_BASEDIR_IGNORE)) {
             System.clearProperty(MagicNames.PROJECT_BASEDIR);
         }
         project.init();
-        File antFile = new 
File(System.getProperty(MagicNames.TEST_ROOT_DIRECTORY), filename);
-        project.setProperty(MagicNames.TEST_PROCESS_ID, 
ProcessUtil.getProcessId("<Process>"));
-        project.setProperty(MagicNames.TEST_THREAD_NAME, 
Thread.currentThread().getName());
+        File antFile = new 
File(System.getProperty(MagicTestNames.TEST_ROOT_DIRECTORY), filename);
+        project.setProperty(MagicTestNames.TEST_PROCESS_ID, 
ProcessUtil.getProcessId("<Process>"));
+        project.setProperty(MagicTestNames.TEST_THREAD_NAME, 
Thread.currentThread().getName());
         project.setUserProperty(MagicNames.ANT_FILE, 
antFile.getAbsolutePath());
         project.addBuildListener(new AntTestListener(logLevel));
         ProjectHelper.configureProject(project, antFile);

http://git-wip-us.apache.org/repos/asf/ant/blob/d7bafaa1/src/tests/junit/org/apache/tools/ant/BuildFileTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/BuildFileTest.java 
b/src/tests/junit/org/apache/tools/ant/BuildFileTest.java
index 723e4e1..cdb45f4 100644
--- a/src/tests/junit/org/apache/tools/ant/BuildFileTest.java
+++ b/src/tests/junit/org/apache/tools/ant/BuildFileTest.java
@@ -327,15 +327,15 @@ public abstract class BuildFileTest extends TestCase {
         logBuffer = new StringBuffer();
         fullLogBuffer = new StringBuffer();
         project = new Project();
-        if (Boolean.getBoolean(MagicNames.TEST_BASEDIR_IGNORE)) {
+        if (Boolean.getBoolean(MagicTestNames.TEST_BASEDIR_IGNORE)) {
             System.clearProperty(MagicNames.PROJECT_BASEDIR);
         }
         project.init();
-        File antFile = new 
File(System.getProperty(MagicNames.TEST_ROOT_DIRECTORY), filename);
+        File antFile = new 
File(System.getProperty(MagicTestNames.TEST_ROOT_DIRECTORY), filename);
         project.setUserProperty(MagicNames.ANT_FILE, 
antFile.getAbsolutePath());
         // set two new properties to allow to build unique names when running 
multithreaded tests
-        project.setProperty(MagicNames.TEST_PROCESS_ID, 
ProcessUtil.getProcessId("<Process>"));
-        project.setProperty(MagicNames.TEST_THREAD_NAME, 
Thread.currentThread().getName());
+        project.setProperty(MagicTestNames.TEST_PROCESS_ID, 
ProcessUtil.getProcessId("<Process>"));
+        project.setProperty(MagicTestNames.TEST_THREAD_NAME, 
Thread.currentThread().getName());
         project.addBuildListener(new AntTestListener(logLevel));
         ProjectHelper.configureProject(project, antFile);
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/d7bafaa1/src/tests/junit/org/apache/tools/ant/MagicTestNames.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/MagicTestNames.java 
b/src/tests/junit/org/apache/tools/ant/MagicTestNames.java
new file mode 100644
index 0000000..95d08fe
--- /dev/null
+++ b/src/tests/junit/org/apache/tools/ant/MagicTestNames.java
@@ -0,0 +1,61 @@
+/*
+ *  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;
+
+/**
+ * Magic names used within Ant's tests.
+ *
+ * @since Ant 1.10.6
+ */
+public final class MagicTestNames {
+    /**
+     * Magic property that makes unit tests based on BuildFileTest
+     * or BuildFileRule ignore externally set basedir
+     * (typically by Surefire/Failsafe)
+     *
+     * Value: {@value}
+     * @since Ant 1.10.6
+     */
+    public static final String TEST_BASEDIR_IGNORE = "ant.test.basedir.ignore";
+
+    /**
+     * Magic property that makes unit tests based on BuildFileTest
+     * or BuildFileRule use build files in alternative locations
+     * (relative to "root" directory)
+     *
+     * Value: {@value}
+     * @since Ant 1.10.6
+     */
+    public static final String TEST_ROOT_DIRECTORY = "root";
+
+    /**
+     * Property for ant process ID set in unit tests by BuildFileTest
+     * or BuildFileRule.
+     *
+     * Value: {@value}
+     */
+    public static final String TEST_PROCESS_ID = "ant.processid";
+
+    /**
+     * Property for ant thread name set in unit tests by BuildFileTest
+     * or BuildFileRule.
+     *
+     * Value: {@value}
+     */
+    public static final String TEST_THREAD_NAME = "ant.threadname";
+}

http://git-wip-us.apache.org/repos/asf/ant/blob/d7bafaa1/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 e9c47ab..601a34a 100644
--- a/src/tests/junit/org/apache/tools/ant/types/CommandlineJavaTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/CommandlineJavaTest.java
@@ -19,6 +19,7 @@
 package org.apache.tools.ant.types;
 
 import org.apache.tools.ant.MagicNames;
+import org.apache.tools.ant.MagicTestNames;
 import org.apache.tools.ant.Project;
 import org.junit.After;
 import org.junit.Before;
@@ -49,8 +50,8 @@ public class CommandlineJavaTest {
     @Before
     public void setUp() {
         project = new Project();
-        if (System.getProperty(MagicNames.TEST_ROOT_DIRECTORY) != null) {
-            
project.setBasedir(System.getProperty(MagicNames.TEST_ROOT_DIRECTORY));
+        if (System.getProperty(MagicTestNames.TEST_ROOT_DIRECTORY) != null) {
+            
project.setBasedir(System.getProperty(MagicTestNames.TEST_ROOT_DIRECTORY));
         }
         project.setProperty("build.sysclasspath", "ignore");
         cloneVm = System.getProperty("ant.build.clonevm");

http://git-wip-us.apache.org/repos/asf/ant/blob/d7bafaa1/src/tests/junit/org/apache/tools/ant/types/PathTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/PathTest.java 
b/src/tests/junit/org/apache/tools/ant/types/PathTest.java
index 79408b1..b6ef4c5 100644
--- a/src/tests/junit/org/apache/tools/ant/types/PathTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/PathTest.java
@@ -23,7 +23,7 @@ import java.nio.file.Paths;
 import java.util.Locale;
 
 import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.MagicNames;
+import org.apache.tools.ant.MagicTestNames;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.condition.Os;
 import org.junit.Before;
@@ -55,8 +55,8 @@ public class PathTest {
     @Before
     public void setUp() {
         project = new Project();
-        if (System.getProperty(MagicNames.TEST_ROOT_DIRECTORY) != null) {
-            
project.setBasedir(System.getProperty(MagicNames.TEST_ROOT_DIRECTORY));
+        if (System.getProperty(MagicTestNames.TEST_ROOT_DIRECTORY) != null) {
+            
project.setBasedir(System.getProperty(MagicTestNames.TEST_ROOT_DIRECTORY));
         }
         p = new Path(project);
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/d7bafaa1/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java 
b/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java
index 81296de..d4c4682 100644
--- a/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java
@@ -28,7 +28,7 @@ import javax.xml.transform.TransformerException;
 import javax.xml.transform.sax.SAXSource;
 
 import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.MagicNames;
+import org.apache.tools.ant.MagicTestNames;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.util.JAXPUtils;
 import org.junit.Before;
@@ -69,8 +69,8 @@ public class XMLCatalogTest {
     @Before
     public void setUp() {
         project = new Project();
-        if (System.getProperty(MagicNames.TEST_ROOT_DIRECTORY) != null) {
-            
project.setBasedir(System.getProperty(MagicNames.TEST_ROOT_DIRECTORY));
+        if (System.getProperty(MagicTestNames.TEST_ROOT_DIRECTORY) != null) {
+            
project.setBasedir(System.getProperty(MagicTestNames.TEST_ROOT_DIRECTORY));
         }
         // This causes XMLCatalog to print out detailed logging
         // messages for debugging

http://git-wip-us.apache.org/repos/asf/ant/blob/d7bafaa1/src/tests/junit/org/apache/tools/ant/types/resources/FileResourceTest.java
----------------------------------------------------------------------
diff --git 
a/src/tests/junit/org/apache/tools/ant/types/resources/FileResourceTest.java 
b/src/tests/junit/org/apache/tools/ant/types/resources/FileResourceTest.java
index c09369a..3f4fd50 100644
--- a/src/tests/junit/org/apache/tools/ant/types/resources/FileResourceTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/resources/FileResourceTest.java
@@ -20,7 +20,7 @@ package org.apache.tools.ant.types.resources;
 import java.io.File;
 import java.io.IOException;
 
-import org.apache.tools.ant.MagicNames;
+import org.apache.tools.ant.MagicTestNames;
 import org.apache.tools.ant.Project;
 import org.junit.Before;
 import org.junit.Test;
@@ -37,9 +37,9 @@ public class FileResourceTest {
 
     @Before
     public void setUp() throws IOException {
-        root = (System.getProperty(MagicNames.TEST_ROOT_DIRECTORY) == null)
+        root = (System.getProperty(MagicTestNames.TEST_ROOT_DIRECTORY) == null)
                 ? new File(".").getCanonicalFile()
-                : new File(System.getProperty(MagicNames.TEST_ROOT_DIRECTORY));
+                : new 
File(System.getProperty(MagicTestNames.TEST_ROOT_DIRECTORY));
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/ant/blob/d7bafaa1/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java 
b/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java
index 241dab7..f602a25 100644
--- a/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java
+++ b/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java
@@ -23,7 +23,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 
 import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.MagicNames;
+import org.apache.tools.ant.MagicTestNames;
 import org.apache.tools.ant.taskdefs.condition.Os;
 import org.junit.After;
 import org.junit.Before;
@@ -51,7 +51,7 @@ public class FileUtilsTest {
     public ExpectedException thrown = ExpectedException.none();
 
     private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
-    private static final String ROOT = 
System.getProperty(MagicNames.TEST_ROOT_DIRECTORY);
+    private static final String ROOT = 
System.getProperty(MagicTestNames.TEST_ROOT_DIRECTORY);
     private File removeThis;
     private String root;
 

http://git-wip-us.apache.org/repos/asf/ant/blob/d7bafaa1/src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java
----------------------------------------------------------------------
diff --git 
a/src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java 
b/src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java
index 649584c..361f285 100644
--- 
a/src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java
+++ 
b/src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java
@@ -24,7 +24,7 @@ import java.io.IOException;
 import java.io.InputStreamReader;
 import java.util.Properties;
 
-import org.apache.tools.ant.MagicNames;
+import org.apache.tools.ant.MagicTestNames;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -36,7 +36,7 @@ import static org.junit.Assert.assertThat;
 
 public class LayoutPreservingPropertiesTest {
 
-    private static final String ROOT = 
System.getProperty(MagicNames.TEST_ROOT_DIRECTORY);
+    private static final String ROOT = 
System.getProperty(MagicTestNames.TEST_ROOT_DIRECTORY);
 
     private LayoutPreservingProperties lpf;
 

http://git-wip-us.apache.org/repos/asf/ant/blob/d7bafaa1/src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java
----------------------------------------------------------------------
diff --git 
a/src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java 
b/src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java
index fdb78ab..6e5280f 100644
--- a/src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java
+++ b/src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java
@@ -17,7 +17,7 @@
  */
 package org.apache.tools.ant.util;
 
-import org.apache.tools.ant.MagicNames;
+import org.apache.tools.ant.MagicTestNames;
 import org.junit.Test;
 
 import java.io.ByteArrayOutputStream;
@@ -34,7 +34,7 @@ import static org.junit.Assert.assertEquals;
  */
 public class ReaderInputStreamTest {
 
-    private static final String ROOT = 
System.getProperty(MagicNames.TEST_ROOT_DIRECTORY);
+    private static final String ROOT = 
System.getProperty(MagicTestNames.TEST_ROOT_DIRECTORY);
 
     @Test
     public void testSimple() throws Exception {

Reply via email to