From 5f2768c82ec2dbe035f4eda927e4aae2084be903 Mon Sep 17 00:00:00 2001 From: Jacobus Martinus Kruithof Date: Sat, 11 Nov 2006 19:45:20 +0000 Subject: [PATCH] Avoid JUNIT methods requiring java 1.4 or higher. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@473781 13f79535-47bb-0310-9956-ffa450edef68 --- .../junit/org/apache/tools/ant/IntrospectionHelperTest.java | 3 ++- .../junit/org/apache/tools/ant/taskdefs/ManifestTest.java | 6 +++--- .../junit/org/apache/tools/ant/taskdefs/PropertyTest.java | 6 +++--- src/tests/junit/org/apache/tools/tar/TarRoundTripTest.java | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java b/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java index 298477680..26a0156a7 100644 --- a/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java +++ b/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java @@ -589,7 +589,8 @@ public class IntrospectionHelperTest extends TestCase { } public void setNineteen(double d) { - assertEquals(19, d, 1e-6); + double diff = d - 19; + assertTrue("Expected 19, received " + d, diff > -1e-6 && diff < 1e-6); } public void testGetExtensionPoints() { diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java index 5757f7cfc..f16e6c388 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java @@ -108,7 +108,7 @@ public class ManifestTest extends BuildFileTest { executeTarget("test5"); String output = getLog(); boolean hasWarning = output.indexOf("Manifest warning: \"Name\" attributes should not occur in the main section") != -1; - assertEquals("Expected warning about Name in main section", true, hasWarning); + assertTrue("Expected warning about Name in main section", hasWarning); } /** @@ -119,7 +119,7 @@ public class ManifestTest extends BuildFileTest { "Invalid Manifest"); String output = getLog(); boolean hasWarning = output.indexOf("Manifest sections should start with a \"Name\" attribute") != -1; - assertEquals("Expected warning about section not starting with Name: attribute", true, hasWarning); + assertTrue("Expected warning about section not starting with Name: attribute", hasWarning); } /** @@ -129,7 +129,7 @@ public class ManifestTest extends BuildFileTest { executeTarget("test7"); boolean hasWarning = getLog().indexOf(Manifest.ERROR_FROM_FORBIDDEN) != -1; - assertEquals("Expected warning about From: attribute", true, hasWarning); + assertTrue("Expected warning about From: attribute", hasWarning); } /** diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java index b636da656..a4f6b5d75 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java @@ -51,7 +51,7 @@ public class PropertyTest extends BuildFileTest { executeTarget("test3"); } catch (BuildException e) { - assertEquals("Circular definition not detected - ", true, + assertTrue("Circular definition not detected - ", e.getMessage().indexOf("was circularly defined") != -1); return; } @@ -85,7 +85,7 @@ public class PropertyTest extends BuildFileTest { executeTarget("prefix.fail"); } catch (BuildException e) { - assertEquals("Prefix allowed on non-resource/file load - ", true, + assertTrue("Prefix allowed on non-resource/file load - ", e.getMessage().indexOf("Prefix is only valid") != -1); return; } @@ -96,7 +96,7 @@ public class PropertyTest extends BuildFileTest { try { executeTarget("testCircularReference"); } catch (BuildException e) { - assertEquals("Circular definition not detected - ", true, + assertTrue("Circular definition not detected - ", e.getMessage().indexOf("was circularly defined") != -1); return; diff --git a/src/tests/junit/org/apache/tools/tar/TarRoundTripTest.java b/src/tests/junit/org/apache/tools/tar/TarRoundTripTest.java index 6df0de845..a86fd2592 100644 --- a/src/tests/junit/org/apache/tools/tar/TarRoundTripTest.java +++ b/src/tests/junit/org/apache/tools/tar/TarRoundTripTest.java @@ -37,7 +37,7 @@ public class TarRoundTripTest extends TestCase { */ public void testLongRoundTripping() throws IOException { TarEntry original = new TarEntry(LONG_NAME); - assertEquals("over 100 chars", true, LONG_NAME.length() > 100); + assertTrue("over 100 chars", LONG_NAME.length() > 100); assertEquals("original name", LONG_NAME, original.getName());