You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Erik Meade <em...@geekfarm.org> on 2000/10/02 00:27:18 UTC

[Patch] IntrospectionHelperTest.java

I checked Ant out of CVS today and executed "ant runtests" and got the
following
error:

    [junit] Testcase: testAttributeSetters took 0.02 sec
    [junit]     Caused an ERROR
    [junit] junit.framework.AssertionFailedError: expected:<c:\tmp\2> but
was:<e
:\tmp\2>
    [junit] junit.framework.AssertionFailedError: expected:<c:\tmp\2> but
was:<e
:\tmp\2>
    [junit]     at
org.apache.tools.ant.IntrospectionHelper.setAttribute(Introsp
ectionHelper.java:236)
    [junit]     at
org.apache.tools.ant.IntrospectionHelperTest.testAttributeSet
ters(IntrospectionHelperTest.java:302)
    [junit]     at java.lang.reflect.Method.invoke(Native Method)
    [junit]     at junit.framework.TestCase.runTest(TestCase.java:155)
    [junit]     at junit.framework.TestCase.runBare(TestCase.java:129)
    [junit]     at junit.framework.TestResult$1.protect(TestResult.java:100)
    [junit]     at
junit.framework.TestResult.runProtected(TestResult.java:117)
    [junit]     at junit.framework.TestResult.run(TestResult.java:103)
    [junit]     at junit.framework.TestCase.run(TestCase.java:120)
    [junit]     at junit.framework.TestSuite.run(TestSuite.java:144)
    [junit]     at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.
run(JUnitTestRunner.java:185)
    [junit]     at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.
main(JUnitTestRunner.java:309)
    [junit]

Obviously I am running Ant off of my e:\ drive, so here is a patch which
ignores
the drive letter for that test.  Did I create this patch correctly?  It
seems like
a lot of stuff when only one line was edited....

Erik Meade
----

Index: IntrospectionHelperTest.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/testcases/org/apache/tools/ant/Introspection
HelperTest.java,v
retrieving revision 1.3
diff -u -r1.3 IntrospectionHelperTest.java
--- IntrospectionHelperTest.java	2000/09/18 14:04:58	1.3
+++ IntrospectionHelperTest.java	2000/10/01 22:17:09
@@ -62,7 +62,7 @@
 /**
  * JUnit 3 testcases for org.apache.tools.ant.IntrospectionHelper.
  *
- * @author Stefan Bodewig <a
href="mailto:stefan.bodewig@megabit.net">stefan.bodewig@megabit.net</a>
+ * @author Stefan Bodewig <a
href="mailto:stefan.bodewig@megabit.net">stefan.bodewig@megabit.net</a>
  */

 public class IntrospectionHelperTest extends TestCase {
@@ -72,7 +72,7 @@
     public IntrospectionHelperTest(String name) {
         super(name);
     }
-
+
     public void testAddText() throws BuildException {
         IntrospectionHelper ih =
IntrospectionHelper.getHelper(java.lang.String.class);
         try {
@@ -95,14 +95,14 @@
         IntrospectionHelper ih =
IntrospectionHelper.getHelper(java.lang.String.class);
         assert("String doesn\'t support addText",
!ih.supportsCharacters());
         ih = IntrospectionHelper.getHelper(getClass());
-        assert("IntrospectionHelperTest supports addText",
+        assert("IntrospectionHelperTest supports addText",
                ih.supportsCharacters());
     }

     public void addText(String text) {
         assertEquals("test", text);
     }
-
+
     public void testElementCreators() throws BuildException {
         IntrospectionHelper ih = IntrospectionHelper.getHelper(getClass());
         try {
@@ -180,7 +180,7 @@
             assert(be.getException() instanceof NullPointerException);
         }
     }
-
+
     public void testGetNestedElements() {
         Hashtable h = new Hashtable();
         h.put("six", java.lang.String.class);
@@ -239,7 +239,7 @@
     public void addThirteen(StringBuffer sb) {
         sb.append("test");
     }
-
+
     public void addFourteen(StringBuffer s) {
         throw new NullPointerException();
     }
@@ -406,10 +406,10 @@
     }

     public void setTen(File f) {
-        if (isUnixStyle)

+        if (isUnixStyle) {
             assertEquals("/tmp/2", f.getAbsolutePath());
         } else {
-            assertEquals("c:\\tmp\\2", f.getAbsolutePath().toLowerCase());
+            assertEquals(":\\tmp\\2",
f.getAbsolutePath().toLowerCase().substring(1));
         }
     }



Re: [Patch] IntrospectionHelperTest.java

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "EM" == Erik Meade <em...@geekfarm.org> writes:

 EM> Obviously I am running Ant off of my e:\ drive, so here is a
 EM> patch which ignores the drive letter for that test.  

Mea culpa. I don't run Windows, so all testcases are only known to
work on Unix (my particular Linux development machine to be exact).

 EM> Did I create this patch correctly?  It seems like a lot of stuff
 EM> when only one line was edited....

Whitespace differences. Throw in the -b switch as well and it should
look better 8^).

Stefan

[Patch] PathTest.java

Posted by Erik Meade <em...@geekfarm.org>.
Turns out there where a few instances where Windows fails in PathTest.
I pretty much did the same thing in this patch as I did for
IntrospectionHelperTest.  All of the test work after this patch, so
maybe it is okay to fix the errors this way after all..?

Erik Meade
----

Index: PathTest.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/testcases/org/apache/tools/ant/types/PathTes
t.java,v
retrieving revision 1.6
diff -u -r1.6 PathTest.java
--- PathTest.java	2000/09/18 14:04:59	1.6
+++ PathTest.java	2000/10/01 23:05:36
@@ -65,7 +65,7 @@
 /**
  * JUnit 3 testcases for org.apache.tools.ant.types.Path
  *
- * @author <a href="mailto:stefan.bodewig@megabit.net">Stefan Bodewig</a>
+ * @author <a href="mailto:stefan.bodewig@megabit.net">Stefan Bodewig</a>
  */

 public class PathTest extends TestCase {
@@ -92,9 +92,9 @@
             assertEquals("/a", l[0]);
             assertEquals("/b", l[1]);
         } else {
-            assertEquals("\\a", l[0]);
-            assertEquals("\\b", l[1]);
-        }
+            assertEquals(":\\a", l[0].substring(1));
+            assertEquals(":\\b", l[1].substring(1));
+        }

         p = new Path(project, "\\a;\\b");
         l = p.list();
@@ -103,9 +103,9 @@
             assertEquals("/a", l[0]);
             assertEquals("/b", l[1]);
         } else {
-            assertEquals("\\a", l[0]);
-            assertEquals("\\b", l[1]);
-        }
+            assertEquals(":\\a", l[0].substring(1));
+            assertEquals(":\\b", l[1].substring(1));
+        }

         p = new Path(project, "\\a;\\b:/c");
         l = p.list();
@@ -115,16 +115,16 @@
             assertEquals("/b", l[1]);
             assertEquals("/c", l[2]);
         } else {
-            assertEquals("\\a", l[0]);
-            assertEquals("\\b", l[1]);
-            assertEquals("\\c", l[2]);
-        }
+            assertEquals(":\\a", l[0].substring(1));
+            assertEquals(":\\b", l[1].substring(1));
+            assertEquals(":\\c", l[2].substring(1));
+        }

         p = new Path(project, "c:\\test");
         l = p.list();
         if (isUnixStyle) {
             assertEquals("no drives on Unix", 2, l.length);
-            assert("c resolved relative to project\'s basedir",
+            assert("c resolved relative to project\'s basedir",
                    l[0].endsWith("/c"));
             assertEquals("/test", l[1]);
         } else {
@@ -136,7 +136,7 @@
         l = p.list();
         if (isUnixStyle) {
             assertEquals("no drives on Unix", 2, l.length);
-            assert("c resolved relative to project\'s basedir",
+            assert("c resolved relative to project\'s basedir",
                    l[0].endsWith("/c"));
             assertEquals("/test", l[1]);
         } else {
@@ -154,7 +154,7 @@
             assertEquals("/a", l[0]);
         } else {
             assertEquals(1, l.length);
-            assertEquals("\\a", l[0]);
+            assertEquals(":\\a", l[0].substring(1));
         }
     }

@@ -314,7 +314,7 @@
         if (isUnixStyle) {
             assertEquals("/a", l[0]);
         } else {
-            assertEquals("\\a", l[0]);
+            assertEquals(":\\a", l[0].substring(1));
         }
     }



Test org.apache.tools.ant.types.PathTest failed

Posted by Erik Meade <em...@geekfarm.org>.
I am not as confident about fixing this one:

    [junit] Testcase: testCircularReferenceCheck took 0.01 sec
    [junit]     FAILED
    [junit] expected:<\a> but was:<E:\a>
    [junit] junit.framework.AssertionFailedError: expected:<\a> but
was:<E:\a>
    [junit]     at junit.framework.Assert.fail(Assert.java:143)
    [junit]     at junit.framework.Assert.failNotEquals(Assert.java:149)
    [junit]     at junit.framework.Assert.assertEquals(Assert.java:86)
    [junit]     at junit.framework.Assert.assertEquals(Assert.java:52)
    [junit]     at
org.apache.tools.ant.types.PathTest.testCircularReferenceChec
k(PathTest.java:317)
    [junit]     at java.lang.reflect.Method.invoke(Native Method)
    [junit]     at junit.framework.TestCase.runTest(TestCase.java:155)
    [junit]     at junit.framework.TestCase.runBare(TestCase.java:129)
    [junit]     at junit.framework.TestResult$1.protect(TestResult.java:100)
    [junit]     at
junit.framework.TestResult.runProtected(TestResult.java:117)
    [junit]     at junit.framework.TestResult.run(TestResult.java:103)
    [junit]     at junit.framework.TestCase.run(TestCase.java:120)
    [junit]     at junit.framework.TestSuite.run(TestSuite.java:144)
    [junit]     at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.
run(JUnitTestRunner.java:185)
    [junit]     at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.
main(JUnitTestRunner.java:309)
    [junit]

BUILD FAILED

E:\java\cvs\jakarta-ant\build.xml:298: Test
org.apache.tools.ant.types.PathTest
failed