diff --git a/src/etc/poms/ant-testutil/pom.xml b/src/etc/poms/ant-testutil/pom.xml index 3de43eafd..50f26c680 100644 --- a/src/etc/poms/ant-testutil/pom.xml +++ b/src/etc/poms/ant-testutil/pom.xml @@ -60,6 +60,7 @@ org/apache/tools/ant/AntAssert* org/apache/tools/ant/BuildFile* org/apache/tools/ant/FileUtilities* + org/apache/tools/ant/MagicTestNames* org/apache/tools/ant/util/regexp/RegexpMatcherTest* org/apache/tools/ant/util/regexp/RegexpTest* org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest* diff --git a/src/main/org/apache/tools/ant/MagicNames.java b/src/main/org/apache/tools/ant/MagicNames.java index 2479bce6e..074f4131e 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"; } diff --git a/src/tests/junit/org/apache/tools/ant/BuildFileRule.java b/src/tests/junit/org/apache/tools/ant/BuildFileRule.java index 48c71adbc..bb77b747a 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("")); - 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("")); + 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); diff --git a/src/tests/junit/org/apache/tools/ant/BuildFileTest.java b/src/tests/junit/org/apache/tools/ant/BuildFileTest.java index 723e4e1c7..cdb45f40c 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("")); - project.setProperty(MagicNames.TEST_THREAD_NAME, Thread.currentThread().getName()); + project.setProperty(MagicTestNames.TEST_PROCESS_ID, ProcessUtil.getProcessId("")); + project.setProperty(MagicTestNames.TEST_THREAD_NAME, Thread.currentThread().getName()); project.addBuildListener(new AntTestListener(logLevel)); ProjectHelper.configureProject(project, antFile); } 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 000000000..95d08fe2b --- /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"; +} 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 e9c47ab7b..601a34ad7 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"); 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 79408b1ea..b6ef4c5f3 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); } 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 81296de20..d4c468243 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 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 c09369a8d..3f4fd5006 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 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 241dab76c..f602a25af 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; 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 649584c83..361f28586 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; 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 fdb78abb7..6e5280f34 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 {