Bug 561040 - Migrate ant tests to JUnit 4
Actually migrate tests in ant.tests.core to POJOs.
Change-Id: Ibae157f5a106d2bd89e9f8fc37f2b31594f12a0c
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/AbstractAntTest.java b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/AbstractAntTest.java
index 9fc8019..95350a9 100644
--- a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/AbstractAntTest.java
+++ b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/AbstractAntTest.java
@@ -13,6 +13,9 @@
*******************************************************************************/
package org.eclipse.ant.tests.core;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.io.File;
import java.util.List;
@@ -46,22 +49,20 @@
import org.eclipse.ui.intro.IIntroManager;
import org.eclipse.ui.intro.IIntroPart;
import org.eclipse.ui.progress.UIJob;
-
-import junit.framework.TestCase;
+import org.junit.Before;
/**
* Tests for Ant core
*/
-public abstract class AbstractAntTest extends TestCase {
+public abstract class AbstractAntTest {
protected static final String BUILD_SUCCESSFUL = "BUILD SUCCESSFUL"; //$NON-NLS-1$
public static final String ANT_TEST_BUILD_LOGGER = "org.eclipse.ant.tests.core.support.testloggers.TestBuildLogger"; //$NON-NLS-1$
public static final String ANT_TEST_BUILD_LISTENER = "org.eclipse.ant.tests.core.support.testloggers.TestBuildListener"; //$NON-NLS-1$
private static boolean welcomeClosed = false;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
assertProject();
assertWelcomeScreenClosed();
}
@@ -132,10 +133,6 @@
return ResourcesPlugin.getWorkspace().getRoot().getProject(ProjectHelper.PROJECT_NAME);
}
- public AbstractAntTest(String name) {
- super(name);
- }
-
protected IFile getBuildFile(String buildFileName) {
IFile file = getProject().getFolder(ProjectHelper.BUILDFILES_FOLDER).getFile(buildFileName);
assertTrue("Could not find build file named: " + buildFileName, file.exists()); //$NON-NLS-1$
@@ -252,7 +249,7 @@
* Return the log message n from the last: e.g. getLoggedMessage(0) returns the most recent message
*
* @param n
- * message index
+ * message index
* @return the nth last message
*/
protected String getLoggedMessage(int n) {
diff --git a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/AntSecurityManagerTest.java b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/AntSecurityManagerTest.java
index b4f897e..0cb8ad0 100644
--- a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/AntSecurityManagerTest.java
+++ b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/AntSecurityManagerTest.java
@@ -1,15 +1,15 @@
package org.eclipse.ant.tests.core.tests;
+import static org.junit.Assert.assertFalse;
+
import org.eclipse.ant.internal.core.AntSecurityManager;
import org.eclipse.ant.tests.core.AbstractAntTest;
+import org.junit.Test;
public class AntSecurityManagerTest extends AbstractAntTest {
- public AntSecurityManagerTest(String name) {
- super(name);
- }
-
@SuppressWarnings("deprecation")
+ @Test
public void test_getInCheck() {
AntSecurityManager securityManager = new AntSecurityManager(System.getSecurityManager(), Thread.currentThread());
assertFalse(securityManager.getInCheck());
diff --git a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/FrameworkTests.java b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/FrameworkTests.java
index 10aeace..29c6844 100644
--- a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/FrameworkTests.java
+++ b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/FrameworkTests.java
@@ -14,6 +14,11 @@
*******************************************************************************/
package org.eclipse.ant.tests.core.tests;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
@@ -32,13 +37,10 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
+import org.junit.Test;
public class FrameworkTests extends AbstractAntTest {
- public FrameworkTests(String name) {
- super(name);
- }
-
/**
* Ensures that the deprecated means of setting the class path still works correctly Do not fix deprecations unless the deprecated methods are
* being removed.
@@ -47,6 +49,7 @@
* @throws CoreException
*/
@SuppressWarnings("deprecation")
+ @Test
public void testClasspathOrderingDeprecated() throws MalformedURLException, CoreException {
AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
@@ -88,6 +91,7 @@
restorePreferenceDefaults();
}
+ @Test
public void testClasspathOrdering() throws CoreException {
AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
@@ -129,6 +133,7 @@
restorePreferenceDefaults();
}
+ @Test
public void testNoDefaultTarget() throws CoreException {
run("NoDefault.xml"); //$NON-NLS-1$
assertSuccessful();
@@ -139,6 +144,7 @@
*
* @throws CoreException
*/
+ @Test
public void testSpecificTargetWithNoDefaultTarget() throws CoreException {
run("NoDefault.xml", new String[] { "test" }); //$NON-NLS-1$ //$NON-NLS-2$
assertSuccessful();
@@ -148,6 +154,7 @@
* Ensures that tasks like javac work when includeAntRuntime is specified bug 20857. This test will just return if the tests are conducted on a
* JRE (no tools.jar).
*/
+ @Test
public void testIncludeAntRuntime() throws CoreException {
IAntClasspathEntry toolsEntry = AntCorePlugin.getPlugin().getPreferences().getToolsJarEntry();
if (toolsEntry == null) {
@@ -167,6 +174,7 @@
/**
* Tests the properties added using a global property file
*/
+ @Test
public void testGlobalPropertyFile() throws CoreException {
AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
@@ -186,6 +194,7 @@
/**
* Tests the properties added using a global property
*/
+ @Test
public void testGlobalProperty() throws CoreException {
AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
@@ -200,6 +209,7 @@
restorePreferenceDefaults();
}
+ @Test
public void testGlobalPropertyFileWithMinusDTakingPrecedence() throws CoreException {
AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
@@ -217,6 +227,7 @@
/**
* Tests that the default ANT_HOME is set and that it can be changed
*/
+ @Test
public void testSettingAntHome() throws CoreException {
try {
AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
@@ -237,6 +248,7 @@
/**
* Tests retrieving target info using AntRunner Covers bug 73602 at the same time
*/
+ @Test
public void testGetTargets() throws CoreException {
AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
@@ -266,6 +278,7 @@
*
* @throws MalformedURLException
*/
+ @Test
public void testAntClasspathEntryFromUrl() throws MalformedURLException {
AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
diff --git a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/OptionTests.java b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/OptionTests.java
index d328793..320e8c8 100644
--- a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/OptionTests.java
+++ b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/OptionTests.java
@@ -13,6 +13,11 @@
*******************************************************************************/
package org.eclipse.ant.tests.core.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -24,6 +29,7 @@
import org.eclipse.ant.tests.core.testplugin.AntTestChecker;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
+import org.junit.Test;
public class OptionTests extends AbstractAntTest {
@@ -32,13 +38,10 @@
protected static final String VERSION = "Apache Ant(TM) version 1.10.7"; //$NON-NLS-1$
protected static final String PLUGIN_VERSION = "org.apache.ant_1.10.7"; //$NON-NLS-1$
- public OptionTests(String name) {
- super(name);
- }
-
/**
* Tests the "-help" option
*/
+ @Test
public void testHelp() throws CoreException {
run("TestForEcho.xml", new String[] { "-help" }); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("incorrect message number logged", 36, AntTestChecker.getDefault().getMessagesLoggedCount()); //$NON-NLS-1$
@@ -48,6 +51,7 @@
/**
* Tests the "-h" option (help)
*/
+ @Test
public void testMinusH() throws CoreException {
run("TestForEcho.xml", new String[] { "-h" }); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("incorrect message number logged", 36, AntTestChecker.getDefault().getMessagesLoggedCount()); //$NON-NLS-1$
@@ -57,6 +61,7 @@
/**
* Tests the "-version" option
*/
+ @Test
public void testVersion() throws CoreException {
run("TestForEcho.xml", new String[] { "-version" }); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("One message should have been logged", AntTestChecker.getDefault().getMessagesLoggedCount() == 1); //$NON-NLS-1$
@@ -66,6 +71,7 @@
/**
* Tests the "-projecthelp" option
*/
+ @Test
public void testProjecthelp() throws CoreException {
run("TestForEcho.xml", new String[] { "-projecthelp" }); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Incorrect number of messages", 4, AntTestChecker.getDefault().getMessagesLoggedCount()); //$NON-NLS-1$
@@ -75,6 +81,7 @@
/**
* Tests the "-p" option (project help)
*/
+ @Test
public void testMinusP() throws CoreException {
run("TestForEcho.xml", new String[] { "-p" }); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Incorrect number of messages", 4, AntTestChecker.getDefault().getMessagesLoggedCount()); //$NON-NLS-1$
@@ -84,6 +91,7 @@
/**
* Tests the "-projecthelp" option when it will not show as much (quite mode)
*/
+ @Test
public void testProjecthelpQuiet() throws CoreException {
run("TestForEcho.xml", new String[] { "-projecthelp", "-q" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertEquals(1, AntTestChecker.getDefault().getMessagesLoggedCount());
@@ -92,6 +100,7 @@
/**
* Tests the "-listener" option with a listener that is not an instance of BuildListener
*/
+ @Test
public void testListenerBad() {
try {
run("TestForEcho.xml", new String[] { "-listener", "java.lang.String" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -108,6 +117,7 @@
/**
* Tests passing an unrecognized argument
*/
+ @Test
public void testUnknownArg() throws CoreException {
run("TestForEcho.xml", new String[] { "-listenr" }); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("Unrecognized option message should have been logged before successful build", //$NON-NLS-1$
@@ -118,6 +128,7 @@
/**
* Tests specifying the -logfile with no arg
*/
+ @Test
public void testLogFileWithNoArg() {
try {
run("TestForEcho.xml", new String[] { "-logfile" }); //$NON-NLS-1$ //$NON-NLS-2$
@@ -131,6 +142,7 @@
/**
* Tests specifying the -logfile
*/
+ @Test
public void testLogFile() throws CoreException, IOException {
run("TestForEcho.xml", new String[] { "-logfile", "TestLogFile.txt" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
IFile file = checkFileExists("TestLogFile.txt"); //$NON-NLS-1$
@@ -151,6 +163,7 @@
/**
* Tests specifying the -logger with no arg
*/
+ @Test
public void testLoggerWithNoArg() {
try {
run("TestForEcho.xml", new String[] { "-logger" }); //$NON-NLS-1$ //$NON-NLS-2$
@@ -164,6 +177,7 @@
/**
* Tests the "-logger" option with a logger that is not an instance of BuildLogger
*/
+ @Test
public void testLoggerBad() {
try {
run("TestForEcho.xml", new String[] { "-logger", "java.lang.String" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -177,6 +191,7 @@
/**
* Tests the "-logger" option with two loggers specified...only one is allowed
*/
+ @Test
public void testTwoLoggers() {
try {
run("TestForEcho.xml", new String[] { "-logger", "java.lang.String", "-q", "-logger", "java.lang.String" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
@@ -190,6 +205,7 @@
/**
* Tests specifying the -listener with no arg
*/
+ @Test
public void testListenerWithNoArg() {
try {
run("TestForEcho.xml", new String[] { "-listener" }); //$NON-NLS-1$ //$NON-NLS-2$
@@ -203,6 +219,7 @@
/**
* Tests specifying the -listener with a class that will not be found
*/
+ @Test
public void testListenerClassNotFound() {
try {
run("TestForEcho.xml", new String[] { "-listener", "TestBuildListener" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -219,6 +236,7 @@
/**
* Tests specifying the -listener option
*/
+ @Test
public void testListener() throws CoreException {
run("TestForEcho.xml", new String[] { "-listener", ANT_TEST_BUILD_LISTENER }); //$NON-NLS-1$ //$NON-NLS-2$
assertSuccessful();
@@ -229,6 +247,7 @@
/**
* Tests specifying the XmlLogger as a listener (bug 80435)
*/
+ @Test
public void testXmlLoggerListener() throws CoreException {
run("TestForEcho.xml", new String[] { "-listener", "org.apache.tools.ant.XmlLogger" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertSuccessful();
@@ -247,6 +266,7 @@
/**
* Tests specifying the -listener option multiple times...which is allowed
*/
+ @Test
public void testListenerMultiple() throws CoreException {
run("TestForEcho.xml", new String[] { "-listener", ANT_TEST_BUILD_LISTENER, "-listener", ANT_TEST_BUILD_LISTENER }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertSuccessful();
@@ -258,6 +278,7 @@
/**
* Tests specifying the -listener option multiple times, with one missing the arg
*/
+ @Test
public void testListenerMultipleWithBad() {
try {
run("TestForEcho.xml", new String[] { "-listener", ANT_TEST_BUILD_LISTENER, "-q", "-listener", "-verbose" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
@@ -272,6 +293,7 @@
/**
* Tests specifying the -buildfile with no arg
*/
+ @Test
public void testBuildFileWithNoArg() {
try {
run("TestForEcho.xml", new String[] { "-buildfile" }); //$NON-NLS-1$ //$NON-NLS-2$
@@ -286,6 +308,7 @@
/**
* Tests specifying the -buildfile
*/
+ @Test
public void testBuildFile() throws CoreException {
String buildFileName = getProject().getFolder("buildfiles").getFile("echoing.xml").getLocation().toFile().getAbsolutePath(); //$NON-NLS-1$ //$NON-NLS-2$
run("TestForEcho.xml", new String[] { "-buildfile", buildFileName }, false, "buildfiles"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -300,6 +323,7 @@
* @since 3.6 this will not fail - the default target will be run instead
* @since 3.8 this will fail as there are no more known targets
*/
+ @Test
public void testSpecifyBadTargetAsArg() throws CoreException {
run("TestForEcho.xml", new String[] { "echo2" }, false); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("Should be an unknown target message", AntTestChecker.getDefault().getLoggedMessage(1).contains("Unknown target")); //$NON-NLS-1$//$NON-NLS-2$
@@ -312,6 +336,7 @@
* Tests specifying both a non-existent target and an existent target in the command line
*
*/
+ @Test
public void testSpecifyBothBadAndGoodTargetsAsArg() throws CoreException {
run("TestForEcho.xml", new String[] { "echo2", "Test for Echo" }, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertTrue("Should be an unknown target message", AntTestChecker.getDefault().getLoggedMessage(5).contains("Unknown target")); //$NON-NLS-1$ //$NON-NLS-2$
@@ -322,6 +347,7 @@
/**
* Tests specifying a target at the command line
*/
+ @Test
public void testSpecifyTargetAsArg() throws CoreException {
run("echoing.xml", new String[] { "echo3" }, false); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("3 messages should have been logged; was " //$NON-NLS-1$
@@ -332,6 +358,7 @@
/**
* Tests specifying a target at the command line with other options
*/
+ @Test
public void testSpecifyTargetAsArgWithOtherOptions() throws CoreException {
run("echoing.xml", new String[] { "-logfile", "TestLogFile.txt", "echo3" }, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
assertTrue("4 messages should have been logged; was " //$NON-NLS-1$
@@ -345,6 +372,7 @@
/**
* Tests specifying targets at the command line with other options
*/
+ @Test
public void testSpecifyTargetsAsArgWithOtherOptions() throws CoreException {
run("echoing.xml", new String[] { "-logfile", "TestLogFile.txt", "echo2", "echo3" }, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
assertTrue("5 messages should have been logged; was " //$NON-NLS-1$
@@ -358,6 +386,7 @@
/**
* Tests specifying a target at the command line and quiet reporting
*/
+ @Test
public void testSpecifyTargetAsArgAndQuiet() throws CoreException {
run("echoing.xml", new String[] { "-logfile", "TestLogFile.txt", "echo3", "-quiet" }, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
assertTrue("2 messages should have been logged; was " //$NON-NLS-1$
@@ -367,6 +396,7 @@
/**
* Tests properties using "-D"
*/
+ @Test
public void testMinusD() throws CoreException {
run("echoing.xml", new String[] { "-DAntTests=testing", "-Declipse.is.cool=true" }, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertSuccessful();
@@ -379,6 +409,7 @@
/**
* Tests properties using "-D" and "-d" to specify debug
*/
+ @Test
public void testMinusDMinusd() throws CoreException {
run("echoing.xml", new String[] { "-d", "-DAntTests=testing", "-Declipse.is.cool=true" }, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
assertSuccessful();
@@ -388,6 +419,7 @@
}
+ @Test
public void testMinusDAndGlobalProperties() throws CoreException {
run("echoing.xml", new String[] { "-DAntTests=testing", "-Declipse.is.cool=true" }, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertSuccessful();
@@ -398,6 +430,7 @@
/**
* Tests specifying a property such as "-D=emptyStringIsMyName Bug 37007
*/
+ @Test
public void testMinusDEmpty() throws CoreException {
run("echoing.xml", new String[] { "-D=emptyStringIsMyName", "-Declipse.is.cool=true" }, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertSuccessful();
@@ -409,6 +442,7 @@
/**
* Tests specifying properties that contain spaces Bug 37094
*/
+ @Test
public void testMinusDWithSpaces() throws CoreException {
run("echoing.xml", new String[] { "-DAntTests= testing", "-Declipse.is.cool= true" }, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertSuccessful();
@@ -420,6 +454,7 @@
/**
* Tests specifying properties when the user has incorrectly specified "-Debug" Bug 40935
*/
+ @Test
public void testPropertiesWithMinusDebug() throws CoreException {
run("echoing.xml", new String[] { "-Debug", "-DAntTests= testing", "-Declipse.is.cool= true" }, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
assertTrue("\"-Debug\" should be flagged as an unknown argument", "Unknown argument: -Debug".equals(AntTestChecker.getDefault().getMessages().get(0))); //$NON-NLS-1$ //$NON-NLS-2$
@@ -432,12 +467,14 @@
/**
* Tests when the user has incorrectly specified "-Debug" Bug 40935
*/
+ @Test
public void testMinusDebug() throws CoreException {
run("echoing.xml", new String[] { "-Debug" }); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("\"-Debug\" should be flagged as an unknown argument", "Unknown argument: -Debug".equals(AntTestChecker.getDefault().getMessages().get(0))); //$NON-NLS-1$ //$NON-NLS-2$
assertSuccessful();
}
+ @Test
public void testPropertyFileWithNoArg() {
try {
run("TestForEcho.xml", new String[] { "-propertyfile" }); //$NON-NLS-1$ //$NON-NLS-2$
@@ -453,6 +490,7 @@
/**
* A build should succeed when a property file is not found. The error is reported and the build continues.
*/
+ @Test
public void testPropertyFileFileNotFound() throws CoreException {
run("TestForEcho.xml", new String[] { "-propertyfile", "qq.txt" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -461,6 +499,7 @@
assertTrue("Message incorrect!: " + msg, msg.startsWith("Could not load property file:")); //$NON-NLS-1$ //$NON-NLS-2$
}
+ @Test
public void testPropertyFile() throws CoreException {
run("TestForEcho.xml", new String[] { "-propertyfile", getPropertyFileName() }); //$NON-NLS-1$ //$NON-NLS-2$
assertSuccessful();
@@ -469,6 +508,7 @@
assertNull("my.name was not set and should be null", AntTestChecker.getDefault().getUserProperty("my.name")); //$NON-NLS-1$ //$NON-NLS-2$
}
+ @Test
public void testPropertyFileWithMinusDTakingPrecedence() throws CoreException {
run("echoing.xml", new String[] { "-propertyfile", getPropertyFileName(), "-DAntTests=testing", "-Declipse.is.cool=true" }, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
assertSuccessful();
@@ -477,6 +517,7 @@
assertNull("my.name was not set and should be null", AntTestChecker.getDefault().getUserProperty("my.name")); //$NON-NLS-1$ //$NON-NLS-2$
}
+ @Test
public void testInputHandlerWithNoArg() {
try {
run("TestForEcho.xml", new String[] { "-inputhandler" }); //$NON-NLS-1$ //$NON-NLS-2$
@@ -492,6 +533,7 @@
/**
* Tests the "-inputhandler" option with two handlers specified...only one is allowed
*/
+ @Test
public void testInputHandlerMultiple() {
try {
run("TestForEcho.xml", new String[] { "-inputhandler", "org.apache.tools.ant.input.DefaultInputHandler", "-q", "-inputhandler", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
@@ -508,6 +550,7 @@
/**
* Tests the "-inputhandler" option with a input handler that is not an instance of InputHandler
*/
+ @Test
public void testInputHandlerBad() {
try {
run("TestForEcho.xml", new String[] { "-inputhandler", "java.lang.StringBuffer" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -524,6 +567,7 @@
/**
* Tests the "-inputhandler" option with a input handler that is not a defined class
*/
+ @Test
public void testInputHandlerBad2() {
try {
run("TestForEcho.xml", new String[] { "-inputhandler", "ja.lang.StringBuffer" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -539,6 +583,7 @@
/**
* Tests the "-inputhandler" option with a test input handler and the -noinput option
*/
+ @Test
public void testInputHandlerWithMinusNoInput() {
try {
run("input.xml", new String[] { "-inputhandler", "org.eclipse.ant.tests.core.support.inputHandlers.AntTestInputHandler", "-noinput" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -555,6 +600,7 @@
/**
* Tests the -noinput option with the default input handler
*/
+ @Test
public void testMinusNoInput() {
try {
run("input.xml", new String[] { "-noinput" }); //$NON-NLS-1$ //$NON-NLS-2$
@@ -570,6 +616,7 @@
/**
* Tests the "-inputhandler" option with a test input handler Order after the noinput tests so that we test we are resetting the system property
*/
+ @Test
public void testInputHandler() throws CoreException {
run("input.xml", new String[] { "-inputhandler", "org.eclipse.ant.tests.core.support.inputHandlers.AntTestInputHandler" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -582,6 +629,7 @@
/**
* Tests the "-diagnostics" option with no ANT_HOME set bug 25693
*/
+ @Test
public void testDiagnosticsWithNoAntHome() throws CoreException {
try {
AntCorePlugin.getPlugin().getPreferences().setAntHome(null);
@@ -598,6 +646,7 @@
/**
* Tests the "-diagnostics" option with ANT_HOME set bug 25693
*/
+ @Test
public void testDiagnostics() throws CoreException {
try {
@@ -634,6 +683,7 @@
/**
* Tests the "-quiet" still reports build successful bug 34488
*/
+ @Test
public void testMinusQuiet() throws CoreException {
run("TestForEcho.xml", new String[] { "-quiet" }); //$NON-NLS-1$ //$NON-NLS-2$
assertSuccessful();
@@ -642,6 +692,7 @@
/**
* Tests the "-keep-going" option
*/
+ @Test
public void testMinusKeepGoing() {
try {
run("failingTarget.xml", new String[] { "-keep-going" }, false); //$NON-NLS-1$ //$NON-NLS-2$
@@ -660,6 +711,7 @@
/**
* Tests the "-k" option
*/
+ @Test
public void testMinusK() {
try {
run("failingTarget.xml", new String[] { "-k" }, false); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/ProjectTests.java b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/ProjectTests.java
index 3e7c1c2..868b2ab 100644
--- a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/ProjectTests.java
+++ b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/ProjectTests.java
@@ -13,21 +13,23 @@
*******************************************************************************/
package org.eclipse.ant.tests.core.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
import org.eclipse.ant.core.AntCorePlugin;
import org.eclipse.ant.tests.core.AbstractAntTest;
import org.eclipse.ant.tests.core.testplugin.AntTestChecker;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
+import org.junit.Test;
public class ProjectTests extends AbstractAntTest {
- public ProjectTests(String name) {
- super(name);
- }
-
/**
* Tests that the three properties that should always be set are correct
*/
+ @Test
public void testBasePropertiesSet() throws CoreException {
String buildFileName = "TestForEcho.xml"; //$NON-NLS-1$
run(buildFileName);
@@ -40,12 +42,14 @@
assertNotNull("eclipse.home should have been set", AntTestChecker.getDefault().getUserProperty("eclipse.home")); //$NON-NLS-1$ //$NON-NLS-2$
}
+ @Test
public void testValue() throws CoreException {
String buildFileName = "TestForEcho.xml"; //$NON-NLS-1$
run(buildFileName);
assertEquals("property.testing should have been set as true", "true", AntTestChecker.getDefault().getUserProperty("property.testing")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
+ @Test
public void testValueWithClass() throws CoreException {
String buildFileName = "TestForEcho.xml"; //$NON-NLS-1$
@@ -53,12 +57,14 @@
assertEquals("property.testing2 should have been set as hey", "hey", AntTestChecker.getDefault().getUserProperty("property.testing2")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
+ @Test
public void testClass() throws CoreException {
String buildFileName = "TestForEcho.xml"; //$NON-NLS-1$
run(buildFileName);
assertEquals("property.testing3 should have been set as AntTestPropertyProvider", "AntTestPropertyValueProvider", AntTestChecker.getDefault().getUserProperty("property.testing3")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
+ @Test
public void testHeadless() throws CoreException {
try {
AntCorePlugin.getPlugin().setRunningHeadless(true);
@@ -71,6 +77,7 @@
}
}
+ @Test
public void testNotHeadless() throws CoreException {
String buildFileName = "TestForEcho.xml"; //$NON-NLS-1$
run(buildFileName);
diff --git a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/PropertyTests.java b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/PropertyTests.java
index 8e1764c..268a6aa 100644
--- a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/PropertyTests.java
+++ b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/PropertyTests.java
@@ -13,8 +13,12 @@
*******************************************************************************/
package org.eclipse.ant.tests.core.tests;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.ant.core.Property;
import org.eclipse.ant.tests.core.AbstractAntTest;
+import org.junit.Test;
/**
* Tests the {@link Property} class
@@ -23,37 +27,35 @@
*/
public class PropertyTests extends AbstractAntTest {
- /**
- * Constructor
- */
- public PropertyTests() {
- super("Ant property tests"); //$NON-NLS-1$
- }
-
+ @Test
public void testPropertyEqual() throws Exception {
Property p1 = new Property("one", "ONE"); //$NON-NLS-1$ //$NON-NLS-2$
Property p2 = new Property("one", "ONE"); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("The properties should be equal", p1.equals(p2)); //$NON-NLS-1$
}
+ @Test
public void testPropertyEqualNameOnly() throws Exception {
Property p1 = new Property("two", "TWO"); //$NON-NLS-1$ //$NON-NLS-2$
Property p2 = new Property("two", "FOUR"); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("The properties should be equal", p1.equals(p2)); //$NON-NLS-1$
}
+ @Test
public void testPropertyNotEqual() throws Exception {
Property p1 = new Property("three", "THREE"); //$NON-NLS-1$ //$NON-NLS-2$
Property p2 = new Property("four", "FOUR"); //$NON-NLS-1$ //$NON-NLS-2$
assertFalse("The properties should not be equal", p1.equals(p2)); //$NON-NLS-1$
}
+ @Test
public void testPropertyNotEqual2() throws Exception {
Property p1 = new Property("five", "FIVE"); //$NON-NLS-1$ //$NON-NLS-2$
Property p2 = new Property("six", "FIVE"); //$NON-NLS-1$ //$NON-NLS-2$
assertFalse("The properties should not be equal", p1.equals(p2)); //$NON-NLS-1$
}
+ @Test
public void testPropertyNotEqualNull() throws Exception {
Property p1 = new Property("seven", "SEVEN"); //$NON-NLS-1$ //$NON-NLS-2$
assertFalse("The properties should not be equal", p1.equals(null)); //$NON-NLS-1$
diff --git a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/TargetTests.java b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/TargetTests.java
index 7a0cf5c..2f3c026 100644
--- a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/TargetTests.java
+++ b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/TargetTests.java
@@ -13,22 +13,25 @@
*******************************************************************************/
package org.eclipse.ant.tests.core.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.File;
import org.eclipse.ant.core.TargetInfo;
import org.eclipse.ant.tests.core.AbstractAntTest;
import org.eclipse.ant.tests.core.testplugin.AntTestChecker;
import org.eclipse.core.runtime.CoreException;
+import org.junit.Test;
public class TargetTests extends AbstractAntTest {
- public TargetTests(String name) {
- super(name);
- }
-
/**
* Ensures that a default target is found
*/
+ @Test
public void testDefaultTarget() throws CoreException {
TargetInfo[] targets = getTargets("TestForEcho.xml"); //$NON-NLS-1$
assertEquals("Should be two targets in TestForEcho.xml", 2, targets.length); //$NON-NLS-1$
@@ -38,6 +41,7 @@
/**
* Ensures that targets are found in a build file with data types
*/
+ @Test
public void testGetTargetsWithDataTypes() throws CoreException {
TargetInfo[] targets = getTargets("Bug32551.xml"); //$NON-NLS-1$
assertEquals("Should be one targets in Bug32551.xml", 1, targets.length); //$NON-NLS-1$
@@ -46,6 +50,7 @@
/**
* Ensures that targets are found in a buildfile with a fileset based on ant_home (that ant_home is set at parse time) Bug 42926.
*/
+ @Test
public void testGetTargetsWithAntHome() {
System.getProperties().remove("ant.home"); //$NON-NLS-1$
try {
@@ -54,13 +59,15 @@
catch (CoreException ce) {
// classpathref was successful but the task is not defined
String message = ce.getMessage();
- assertTrue("Core exception message not as expected: " + message, message.endsWith("Bug42926.xml:7: taskdef class com.foo.SomeTask cannot be found\n using the classloader AntClassLoader[]")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Core exception message not as expected: " //$NON-NLS-1$
+ + message, message.endsWith("Bug42926.xml:7: taskdef class com.foo.SomeTask cannot be found\n using the classloader AntClassLoader[]")); //$NON-NLS-1$
}
}
/**
* Ensures that target names are retrieved properly
*/
+ @Test
public void testTargetNames() throws CoreException {
String[] targetNames = getTargetNames("TestForEcho.xml"); //$NON-NLS-1$
assertEquals("Should be two targets in TestForEcho.xml", 2, targetNames.length); //$NON-NLS-1$
@@ -71,6 +78,7 @@
/**
* Ensures that target descriptions are retrieved properly
*/
+ @Test
public void testTargetDescription() throws CoreException {
String[] targetDescriptions = getTargetDescriptions("TestForEcho.xml"); //$NON-NLS-1$
assertEquals("Should be two targets in TestForEcho.xml", 2, targetDescriptions.length); //$NON-NLS-1$
@@ -81,6 +89,7 @@
/**
* Ensures that target projects are retrieved properly
*/
+ @Test
public void testTargetProject() throws CoreException {
String targetProject = getProjectName("TestForEcho.xml", "Test for Echo"); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Project name should be Echo Test", "Echo Test", targetProject); //$NON-NLS-1$ //$NON-NLS-2$
@@ -89,6 +98,7 @@
/**
* Ensures that target dependencies are retrieved properly
*/
+ @Test
public void testTargetDependencies() throws CoreException {
String[] dependencies = getDependencies("TestForEcho.xml", "Test for Echo"); //$NON-NLS-1$ //$NON-NLS-2$
assertNotNull("Dependencies should not be null", dependencies); //$NON-NLS-1$
@@ -99,10 +109,12 @@
/**
* Runs an Ant build and ensure that the build file location is logged
*/
+ @Test
public void testRunScript() throws CoreException {
run("TestForEcho.xml"); //$NON-NLS-1$
String message = AntTestChecker.getDefault().getMessages().get(0);
- assertTrue("Build file location should be logged as the first message", message != null && message.endsWith("AntTests" + File.separator + "buildfiles" + File.separator + "TestForEcho.xml")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertTrue("Build file location should be logged as the first message", message != null //$NON-NLS-1$
+ && message.endsWith("AntTests" + File.separator + "buildfiles" + File.separator + "TestForEcho.xml")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertSuccessful();
}
}
\ No newline at end of file
diff --git a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/TaskTests.java b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/TaskTests.java
index 33e7495..0891252 100644
--- a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/TaskTests.java
+++ b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/TaskTests.java
@@ -13,6 +13,9 @@
*******************************************************************************/
package org.eclipse.ant.tests.core.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.io.File;
import java.net.URL;
@@ -26,19 +29,17 @@
import org.eclipse.ant.tests.core.testplugin.AntTestChecker;
import org.eclipse.ant.tests.core.testplugin.ProjectHelper;
import org.eclipse.core.runtime.CoreException;
+import org.junit.Test;
public class TaskTests extends AbstractAntTest {
- public TaskTests(String name) {
- super(name);
- }
-
/**
* Testing the old deprecated API
*
* @throws CoreException
*/
@SuppressWarnings("deprecation")
+ @Test
public void testAddTaskSettingLibrary() throws CoreException {
AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
URL[] urls = prefs.getExtraClasspathURLs();
@@ -56,6 +57,7 @@
assertSuccessful();
}
+ @Test
public void testAddTaskSettingLibraryEntry() throws CoreException {
AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
URL[] urls = prefs.getExtraClasspathURLs();
@@ -73,6 +75,7 @@
assertSuccessful();
}
+ @Test
public void testRemoveTask() {
AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
prefs.setCustomTasks(new Task[] {});
@@ -89,6 +92,7 @@
assertTrue("Build should have failed as task no longer defined", false); //$NON-NLS-1$
}
+ @Test
public void testAddTaskFromFolder() throws CoreException {
try {
AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
@@ -118,6 +122,7 @@
}
}
+ @Test
public void testTasksDefinedInPropertyFile() throws CoreException {
try {
AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
@@ -130,6 +135,7 @@
}
}
+ @Test
public void testTaskDefinedInExtensionPoint() throws CoreException {
run("ExtensionPointTask.xml"); //$NON-NLS-1$
String msg = AntTestChecker.getDefault().getMessages().get(1);
@@ -137,6 +143,7 @@
assertSuccessful();
}
+ @Test
public void testTaskDefinedInExtensionPointHeadless() {
AntCorePlugin.getPlugin().setRunningHeadless(true);
try {
@@ -152,6 +159,7 @@
assertTrue("Build should have failed as task was not defined to run in headless", false); //$NON-NLS-1$
}
+ @Test
public void testTaskDefinedInExtensionPointWithURI() throws CoreException {
run("ExtensionPointTask.xml"); //$NON-NLS-1$
String msg = AntTestChecker.getDefault().getMessages().get(2);
diff --git a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/TypeTests.java b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/TypeTests.java
index 2fb40b4..cfcb592 100644
--- a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/TypeTests.java
+++ b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/TypeTests.java
@@ -13,6 +13,9 @@
*******************************************************************************/
package org.eclipse.ant.tests.core.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.net.URL;
import org.eclipse.ant.core.AntCorePlugin;
@@ -22,13 +25,11 @@
import org.eclipse.ant.tests.core.AbstractAntTest;
import org.eclipse.ant.tests.core.testplugin.AntTestChecker;
import org.eclipse.core.runtime.CoreException;
+import org.junit.Test;
public class TypeTests extends AbstractAntTest {
- public TypeTests(String name) {
- super(name);
- }
-
+ @Test
public void testAddType() throws CoreException {
AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
URL[] urls = prefs.getExtraClasspathURLs();
@@ -44,6 +45,7 @@
assertSuccessful();
}
+ @Test
public void testRemoveType() {
AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
prefs.setCustomTypes(new Type[] {});
@@ -51,7 +53,8 @@
run("CustomType.xml"); //$NON-NLS-1$
}
catch (CoreException ce) {
- assertTrue("Exception from undefined type is incorrect: " + ce.getMessage(), ce.getMessage().trim().endsWith("Action: Check that any <presetdef>/<macrodef> declarations have taken place.")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Exception from undefined type is incorrect: " //$NON-NLS-1$
+ + ce.getMessage(), ce.getMessage().trim().endsWith("Action: Check that any <presetdef>/<macrodef> declarations have taken place.")); //$NON-NLS-1$
return;
}
finally {
@@ -61,6 +64,7 @@
}
+ @Test
public void testTypeDefinedInExtensionPoint() throws CoreException {
run("ExtensionPointType.xml"); //$NON-NLS-1$
String msg = AntTestChecker.getDefault().getMessages().get(1);
@@ -68,13 +72,15 @@
assertSuccessful();
}
+ @Test
public void testTypeDefinedInExtensionPointHeadless() {
AntCorePlugin.getPlugin().setRunningHeadless(true);
try {
run("ExtensionPointType.xml"); //$NON-NLS-1$
}
catch (CoreException ce) {
- assertTrue("Exception from undefined type is incorrect: " + ce.getMessage(), ce.getMessage().trim().endsWith("Action: Check that any <presetdef>/<macrodef> declarations have taken place.")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Exception from undefined type is incorrect: " //$NON-NLS-1$
+ + ce.getMessage(), ce.getMessage().trim().endsWith("Action: Check that any <presetdef>/<macrodef> declarations have taken place.")); //$NON-NLS-1$
return;
}
finally {