public inbox for mauve-patches@sourceware.org
 help / color / mirror / Atom feed
* FYI: Mauve goes JUnit
@ 2006-10-06 10:43 Roman Kennke
  0 siblings, 0 replies; only message in thread
From: Roman Kennke @ 2006-10-06 10:43 UTC (permalink / raw)
  To: mauve-patches

[-- Attachment #1: Type: text/plain, Size: 789 bytes --]

Here comes an implementation of the core JUnit API (junit.framework +
some bits) for running JUnit tests inside the Mauve Harness. As an
example I prepared the harmony testsuite a little (I only moved the
tests into the gnu.testlet namespace so that the Harness can find it):

http://kennke.org/~roman/harmony-swing-awt.jar

This is the Swing/AWT testsuite that has been prepared by David and
moved into the gnu.testlet namespace.

You can run single tests like you are used from Mauve, e.g.:

jamvm Harness test.javax.swing.AbstractButtonTest

This patch not only allows integration of existing JUnit tests, you can
now write new tests in JUnit style if you like. This has some
advantages, like having setUp() and tearDown() called, some kind of
standard named test methods etc.

/Roman


[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 55804 bytes --]

Index: junit/framework/Assert.java
===================================================================
RCS file: junit/framework/Assert.java
diff -N junit/framework/Assert.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ junit/framework/Assert.java	6 Oct 2006 10:37:44 -0000
@@ -0,0 +1,571 @@
+/* Assert.java -- Assertions to be used by tests
+   Copyright (C) 2006 Roman Kennke (kennke@aicas.com)
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: not-a-test
+
+package junit.framework;
+
+import gnu.testlet.TestHarness;
+
+/**
+ * Test assertions to be used by test cases.
+ */
+public class Assert
+{
+
+  /**
+   * The mauve test harness. The assertions are delegated to the harness
+   * if this is not null. Otherwise the normal JUnit behaviour is implemented,
+   * which is to throw an AssertionFailedError.
+   */
+  static TestHarness harness;
+
+  /**
+   * Creates a new Assert object.
+   */
+  protected Assert()
+  {
+    // Nothing to do here.
+  }
+
+  /**
+   * Checks if <code>value</code> is <code>true</code>.
+   *
+   * @param message the error message in the case this assertion fails
+   * @param value the value to check.
+   */
+  public static void assertTrue(String message, boolean value)
+  {
+    if (harness != null)
+      harness.check(value);
+    else if (! value)
+      fail(message);
+  }
+
+  /**
+   * Checks if <code>value</code> is <code>true</code>.
+   *
+   * @param value the value to check.
+   */
+  public static void assertTrue(boolean value)
+  {
+    assertTrue(null, value);
+  }
+
+  /**
+   * Checks if <code>value</code> is <code>true</code>.
+   *
+   * @param message the error message in the case this assertion fails
+   * @param value the value to check.
+   */
+  public static void assertFalse(String message, boolean value)
+  {
+    assertTrue(message, ! value);
+  }
+
+  /**
+   * Checks if <code>value</code> is <code>false</code>.
+   *
+   * @param value the value to check.
+   */
+  public static void assertFalse(boolean value)
+  {
+    assertFalse(null, value);
+  }
+
+  /**
+   * Unconditionally fails with the specified message.
+   *
+   * @param message
+   */
+  public static void fail(String message)
+  {
+    if (harness != null)
+      harness.check(false);
+    else
+      throw new AssertionFailedError(message);
+  }
+
+  /**
+   * Unconditionally fails without message.
+   */
+  public static void fail()
+  {
+    fail(null);
+  }
+
+  /**
+   * Checks if <code>value</code> is equal to <code>expexted</code> in the
+   * sense of <code>Object.equals()</code>.
+   *
+   * @param message the error message in case of failure
+   * @param expected the expected value
+   * @param value the actual value to check
+   */
+  public static void assertEquals(String message, Object expected,
+                                  Object value)
+  {
+    if (harness != null)
+      harness.check(expected, value);
+    else
+      {
+        if ((expected != null || value != null)
+            && (expected == null || ! expected.equals(value)))
+          failNotEquals(message, expected, value);
+      }
+  }
+
+  /**
+   * Checks if <code>value</code> is equal to <code>expexted</code> in the
+   * sense of <code>Object.equals()</code>.
+   *
+   * @param expected the expected value
+   * @param value the actual value to check
+   */
+  public static void assertEquals(Object expected, Object value)
+  {
+    assertEquals(null, expected, value);
+  }
+
+  /**
+   * Checks if <code>value</code> is equal to <code>expexted</code> in the
+   * sense of <code>Object.equals()</code>.
+   *
+   * @param message the error message in case of failure
+   * @param expected the expected value
+   * @param value the actual value to check
+   */
+  public static void assertEquals(String message, String expected,
+                                  String value)
+  {
+    if (harness != null)
+      harness.check(expected, value);
+    else
+      {
+        if ((expected != null || value != null)
+            && (expected == null || ! expected.equals(value)))
+          throw new ComparisonFailure(message, expected, value);
+      }
+  }
+
+  /**
+   * Checks if <code>value</code> is equal to <code>expexted</code> in the
+   * sense of <code>Object.equals()</code>.
+   *
+   * @param expected the expected value
+   * @param value the actual value to check
+   */
+  public static void assertEquals(String expected, String value)
+  {
+    assertEquals(null, expected, value);
+  }
+
+  /**
+   * Checks if <code>value</code> is equal to <code>expected</code>, taking
+   * a rounding delta <code>delta</code> into account.
+   *
+   * @param message the error message in the case of failure
+   * @param expected the expected value
+   * @param value the actual value to check
+   * @param delta the rounding delta
+   */
+  public static void assertEquals(String message, double expected,
+                                  double value, double delta)
+  {
+    if (harness != null)
+      harness.check(expected, value, delta);
+    else
+      {
+        if (Double.isInfinite(expected))
+          {
+            if (value != expected)
+              failNotEquals(message, new Double(expected), new Double(value));
+          }
+        else if (! (Math.abs(expected - value) <= delta))
+          failNotEquals(message, new Double(expected), new Double(value));
+      }
+  }
+
+  /**
+   * Checks if <code>value</code> is equal to <code>expected</code>, taking
+   * a rounding delta <code>delta</code> into account.
+   *
+   * @param expected the expected value
+   * @param value the actual value to check
+   * @param delta the rounding delta
+   */
+  public static void assertEquals(double expected, double value, double delta)
+  {
+    assertEquals(null, expected, value, delta);
+  }
+
+  /**
+   * Checks if <code>value</code> is equal to <code>expected</code>, taking
+   * a rounding delta <code>delta</code> into account.
+   *
+   * @param message the error message in the case of failure
+   * @param expected the expected value
+   * @param value the actual value to check
+   * @param delta the rounding delta
+   */
+  public static void assertEquals(String message, float expected, float value,
+                                  float delta)
+  {
+    if (harness != null)
+      harness.check(expected, value, delta);
+    else
+      {
+        if (Float.isInfinite(expected))
+          {
+            if (value != expected)
+              failNotEquals(message, new Float(expected), new Float(value));
+          }
+        else if (! (Math.abs(expected - value) <= delta))
+          failNotEquals(message, new Float(expected), new Float(value));
+      }
+  }
+
+  /**
+   * Checks if <code>value</code> is equal to <code>expected</code>, taking
+   * a rounding delta <code>delta</code> into account.
+   *
+   * @param expected the expected value
+   * @param value the actual value to check
+   * @param delta the rounding delta
+   */
+  public static void assertEquals(float expected, float value, float delta)
+  {
+    assertEquals(null, expected, value, delta);
+  }
+
+  /**
+   * Checks if <code>value</code> is equal to <code>expected</code>.
+   *
+   * @param message the error message in the case of failure
+   * @param expected the expected value
+   * @param value the actual value
+   */
+  public static void assertEquals(String message, long expected, long value)
+  {
+    if (harness != null)
+      harness.check(expected, value);
+    else
+      failNotEquals(message, new Long(expected), new Long(value));
+  }
+
+  /**
+   * Checks if <code>value</code> is equal to <code>expected</code>.
+   *
+   * @param expected the expected value
+   * @param value the actual value
+   */
+  public static void assertEquals(long expected, long value)
+  {
+    assertEquals(null, expected, value);
+  }
+
+  /**
+   * Checks if <code>value</code> is equal to <code>expected</code>.
+   *
+   * @param message the error message in the case of failure
+   * @param expected the expected value
+   * @param value the actual value
+   */
+  public static void assertEquals(String message, boolean expected,
+                                  boolean value)
+  {
+    if (harness != null)
+      harness.check(expected, value);
+    else
+      failNotEquals(message, new Boolean(expected), new Boolean(value));
+  }
+
+  /**
+   * Checks if <code>value</code> is equal to <code>expected</code>.
+   *
+   * @param expected the expected value
+   * @param value the actual value
+   */
+  public static void assertEquals(boolean expected, boolean value)
+  {
+    assertEquals(null, expected, value);
+  }
+
+  /**
+   * Checks if <code>value</code> is equal to <code>expected</code>.
+   *
+   * @param message the error message in the case of failure
+   * @param expected the expected value
+   * @param value the actual value
+   */
+  public static void assertEquals(String message, byte expected, byte value)
+  {
+    if (harness != null)
+      harness.check(expected, value);
+    else
+      failNotEquals(message, new Byte(expected), new Byte(value));
+  }
+
+  /**
+   * Checks if <code>value</code> is equal to <code>expected</code>.
+   *
+   * @param expected the expected value
+   * @param value the actual value
+   */
+  public static void assertEquals(byte expected, byte value)
+  {
+    assertEquals(null, expected, value);
+  }
+
+  /**
+   * Checks if <code>value</code> is equal to <code>expected</code>.
+   *
+   * @param message the error message in the case of failure
+   * @param expected the expected value
+   * @param value the actual value
+   */
+  public static void assertEquals(String message, char expected, char value)
+  {
+    if (harness != null)
+      harness.check(expected, value);
+    else
+      failNotEquals(message, new Character(expected), new Character(value));
+  }
+
+  /**
+   * Checks if <code>value</code> is equal to <code>expected</code>.
+   *
+   * @param expected the expected value
+   * @param value the actual value
+   */
+  public static void assertEquals(char expected, char value)
+  {
+    assertEquals(null, expected, value);
+  }
+
+  /**
+   * Checks if <code>value</code> is equal to <code>expected</code>.
+   *
+   * @param message the error message in the case of failure
+   * @param expected the expected value
+   * @param value the actual value
+   */
+  public static void assertEquals(String message, short expected, short value)
+  {
+    if (harness != null)
+      harness.check(expected, value);
+    else
+      failNotEquals(message, new Short(expected), new Short(value));
+  }
+
+  /**
+   * Checks if <code>value</code> is equal to <code>expected</code>.
+   *
+   * @param expected the expected value
+   * @param value the actual value
+   */
+  public static void assertEquals(short expected, short value)
+  {
+    assertEquals(null, expected, value);
+  }
+
+  /**
+   * Checks if <code>value</code> is equal to <code>expected</code>.
+   *
+   * @param message the error message in the case of failure
+   * @param expected the expected value
+   * @param value the actual value
+   */
+  public static void assertEquals(String message, int expected, int value)
+  {
+    if (harness != null)
+      harness.check(expected, value);
+    else
+      failNotEquals(message, new Integer(expected), new Integer(value));
+  }
+
+  /**
+   * Checks if <code>value</code> is equal to <code>expected</code>.
+   *
+   * @param expected the expected value
+   * @param value the actual value
+   */
+  public static void assertEquals(int expected, int value)
+  {
+    assertEquals(null, expected, value);
+  }
+
+  /**
+   * Checks that the <code>value</code> is not null.
+   *
+   * @param message the error message in the case of failure
+   * @param value the value to check
+   */
+  public static void assertNotNull(String message, Object value)
+  {
+    assertTrue(message, value != null);
+  }
+
+  /**
+   * Checks that the <code>value</code> is not null.
+   *
+   * @param value the value to check
+   */
+  public static void assertNotNull(Object value)
+  {
+    assertNotNull(null, value);
+  }
+
+  /**
+   * Checks that the <code>value</code> is null.
+   *
+   * @param message the error message in the case of failure
+   * @param value the value to check
+   */
+  public static void assertNull(String message, Object value)
+  {
+    assertTrue(message, value == null);
+  }
+
+  /**
+   * Checks that the <code>value</code> is null.
+   *
+   * @param value the value to check
+   */
+  public static void assertNull(Object value)
+  {
+    assertNull(null, value);
+  }
+
+  /**
+   * Checks that the <code>value</code> is the same object instance as
+   * <code>expected</code>.
+   *
+   * @param message the error message in case of failure
+   * @param expected the expected value
+   * @param value the actual value to check
+   */
+  public static void assertSame(String message, Object expected, Object value)
+  {
+    if (harness != null)
+      harness.check(expected == value);
+    else if (value != expected)
+      {
+        StringBuffer str = new StringBuffer();
+        if (message != null)
+          {
+            str.append(message);
+            str.append(' ');
+            str.append("expected to be same");
+          }
+        fail(format(str, expected, value));
+      }
+  }
+
+  /**
+   * Checks that the <code>value</code> is the same object instance as
+   * <code>expected</code>.
+   *
+   * @param expected the expected value
+   * @param value the actual value to check
+   */
+  public static void assertSame(Object expected, Object value)
+  {
+    assertSame(null, expected, value);
+  }
+
+  /**
+   * Checks that the <code>value</code> is not the same object instance as
+   * <code>expected</code>.
+   *
+   * @param message the error message in case of failure
+   * @param expected the expected value
+   * @param value the actual value to check
+   */
+  public static void assertNotSame(String message, Object expected,
+                                   Object value)
+  {
+    if (harness != null)
+      harness.check(expected != value);
+    else if (value == expected)
+      {
+        StringBuffer str = new StringBuffer();
+        if (message != null)
+          {
+            str.append(message);
+            str.append(' ');
+            str.append("expected to be not the same");
+          }
+        fail(format(str, expected, value));
+      }
+  }
+
+  /**
+   * Checks that the <code>value</code> is not the same object instance as
+   * <code>expected</code>.
+   *
+   * @param expected the expected value
+   * @param value the actual value to check
+   */
+  public static void assertNotSame(Object expected, Object value)
+  {
+    assertNotSame(null, expected, value);
+  }
+
+  /**
+   * Called when a test failed because two objects are not equal.
+   *
+   * @param message the error message
+   * @param expected the expected value
+   * @param value the actual value
+   */
+  private static void failNotEquals(String message, Object expected,
+                                    Object value)
+  {
+    StringBuffer str = new StringBuffer();
+    if (message != null)
+      {
+        str.append(message);
+        str.append(' ');
+      }
+    fail(format(str, expected, value));
+  }
+
+  /**
+   * Formats the error message.
+   *
+   * @param str the string buffer to append to, with the start of the error
+   *        message
+   * @param expected the expected value
+   * @param value the actual value
+   *
+   * @return the formatted message
+   */
+  private static String format(StringBuffer str, Object expected,
+                               Object value)
+  {
+    str.append(' ');
+    str.append(" expected value: ");
+    str.append(expected);
+    str.append(" actual value: " + value);
+    return str.toString();
+  }
+}
Index: junit/framework/AssertionFailedError.java
===================================================================
RCS file: junit/framework/AssertionFailedError.java
diff -N junit/framework/AssertionFailedError.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ junit/framework/AssertionFailedError.java	6 Oct 2006 10:37:44 -0000
@@ -0,0 +1,50 @@
+/* AssertionFailedError.java -- Thrown when a test failed
+   Copyright (C) 2006 Roman Kennke (kennke@aicas.com)
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: not-a-test
+
+package junit.framework;
+
+/**
+ * Indicates that a test assertion failed.
+ */
+public class AssertionFailedError
+  extends Error
+{
+
+  /**
+   * Creates an AssertionFailedError without message.
+   */
+  public AssertionFailedError()
+  {
+    // Nothing to do here.
+  }
+
+  /**
+   * Creates an AssertionFailedError with the specified error message.
+   *
+   * @param message the error message.
+   */
+  public AssertionFailedError(String message)
+  {
+    super(message);
+  }
+}
Index: junit/framework/ComparisonFailure.java
===================================================================
RCS file: junit/framework/ComparisonFailure.java
diff -N junit/framework/ComparisonFailure.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ junit/framework/ComparisonFailure.java	6 Oct 2006 10:37:44 -0000
@@ -0,0 +1,47 @@
+/* ComparisonFailure.java -- Thrown when a string comparison failed
+   Copyright (C) 2006 Roman Kennke (kennke@aicas.com)
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: not-a-test
+
+package junit.framework;
+
+/**
+ * Thrown when a string comparison failed.
+ *
+ * @see Assert#assertEquals(String, String, String)
+ * @see Assert#assertEquals(String, String)
+ */
+public class ComparisonFailure extends AssertionFailedError
+{
+
+  /**
+   * Creates a new ComparisonFailure with an error message.
+   *
+   * @param message the error message
+   * @param expected the expected string
+   * @param the actual string value
+   */
+  public ComparisonFailure(String message, String expected, String value)
+  {
+    super(message);
+  }
+
+}
Index: junit/framework/Protectable.java
===================================================================
RCS file: junit/framework/Protectable.java
diff -N junit/framework/Protectable.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ junit/framework/Protectable.java	6 Oct 2006 10:37:44 -0000
@@ -0,0 +1,38 @@
+/* Protectable.java -- The Protectable interface from the JUnit API
+   Copyright (C) 2006 Roman Kennke (kennke@aicas.com)
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: not-a-test
+
+package junit.framework;
+
+/**
+ * Runs tests inside a protected environmant. The code to be run is put
+ * in the protect() method.
+ */
+public interface Protectable
+{
+  
+  /**
+   * Runs tests inside a protected environmant.
+   */
+  void protect()
+    throws Throwable;
+}
Index: junit/framework/Test.java
===================================================================
RCS file: junit/framework/Test.java
diff -N junit/framework/Test.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ junit/framework/Test.java	6 Oct 2006 10:37:44 -0000
@@ -0,0 +1,45 @@
+/* Test.java -- The basic interface for a JUnit test
+   Copyright (C) 2006 Roman Kennke (kennke@aicas.com)
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: not-a-test
+
+package junit.framework;
+
+/**
+ * The basic interface for a JUnit test.
+ */
+public interface Test
+{
+
+  /**
+   * Returns the number of test cases that will be run by this test.
+   *
+   * @return the number of test cases that will be run by this test
+   */
+  int countTestCases();
+
+  /**
+   * Runs the test and store the results in <code>result</code>
+   *
+   * @param result the test result object for storing the results into
+   */
+  void run(TestResult result);
+}
Index: junit/framework/TestCase.java
===================================================================
RCS file: junit/framework/TestCase.java
diff -N junit/framework/TestCase.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ junit/framework/TestCase.java	6 Oct 2006 10:37:44 -0000
@@ -0,0 +1,313 @@
+/* TestCase.java -- A JUnit test case
+   Copyright (C) 2006 Roman Kennke (kennke@aicas.com)
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: not-a-test
+
+package junit.framework;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+/**
+ * A JUnit test case.
+ */
+public abstract class TestCase
+  extends Assert
+  implements Test, Testlet
+  
+{
+
+  /**
+   * The name of the test case.
+   */
+  private String fName;
+
+  /**
+   * Creates a new TestCase.
+   */
+  public TestCase()
+  {
+    fName = null;
+  }
+
+  /**
+   * Creates a test case with a name.
+   *
+   * @param name the name of the test case
+   */
+  public TestCase(String name)
+  {
+    fName = name;
+  }
+
+  /**
+   * Returns the number of test cases executed by this test.
+   *
+   * @return the number of test cases executed by this test
+   */
+  public int countTestCases()
+  {
+    return 1;
+  }
+
+  /**
+   * Creates a default TestResult object.
+   *
+   * @return a default TestResult object
+   */
+  protected TestResult createResult()
+  {
+    return new TestResult();
+  }
+
+  /**
+   * Creates a TestResult and runs a test by calling
+   * {@link #run(TestResult)}.
+   *
+   * @return the test results after running the test
+   */
+  public TestResult run()
+  {
+    TestResult result = createResult();
+    run(result);
+    return result;
+  }
+
+  /**
+   * Runs the test and collects the result in the specified TestResult
+   * object.
+   *
+   * @param result the TestResult object to collect the results in
+   */
+  public void run(TestResult result)
+  {
+    result.run(this);
+  }
+
+  /**
+   * Runs the bare test sequence. This calls {@link #setUp()}, executes
+   * the test by calling {@link #runTest}, and finally finishes with
+   * {@link #tearDown()}.
+   *
+   * @throws Throwable if a failure or error occured
+   */
+  public void runBare()
+    throws Throwable
+  {
+    Throwable t = null;
+    setUp();
+    try
+      {
+        runTest();
+      }
+    catch (Throwable ex)
+      {
+        t = ex;
+      }
+    finally
+      {
+        try
+          {
+            tearDown();
+          }
+        catch (Throwable ex2)
+          {
+            if (t == null)
+              t = ex2;
+          }
+      }
+    if (t != null)
+      throw t;
+  }
+
+  /**
+   * Actually runs the test. The default implementation tries to find
+   * a method with the name specified in the constructor of this class.
+   * If such a method is found, it is invoked.
+   *
+   * @throws Throwable for test errors or failures
+   */
+  protected void runTest()
+    throws Throwable
+  {
+    Method method = null;
+    try
+      {
+        method = getClass().getMethod(fName, (Class[]) null);
+      }
+    catch (NoSuchMethodException ex)
+      {
+        fail("Method " + fName + " not found");
+      }
+    if (! Modifier.isPublic(method.getModifiers()))
+      fail("Method " + fName + " must be public");
+    try
+      {
+        method.invoke(this, new Object[0]);
+      }
+    catch (InvocationTargetException ex)
+      {
+        ex.fillInStackTrace();
+        throw ex.getTargetException();
+      }
+    catch (IllegalAccessException ex)
+      {
+        ex.fillInStackTrace();
+        throw ex;
+      }
+  }
+
+  /**
+   * Prepares the test. This is called before {@link #runTest()}.
+   *
+   * @throws Exception if anything goes wrong
+   */
+  protected void setUp()
+    throws Exception
+  {
+    // This is a hook with nothing to do itself.
+  }
+
+  /**
+   * Finishes the test. This is called after {@link #runTest()}.
+   *
+   * @throws Exception if anything goes wrong
+   */
+  protected void tearDown()
+    throws Exception
+  {
+    // This is a hook with nothing to do itself.
+  }
+
+  /**
+   * Returns the name of the test case.
+   *
+   * @return the name of the test case
+   */
+  public String getName()
+  {
+    return fName;
+  }
+
+  /**
+   * Sets the name of the test case.
+   *
+   * @param name the name to set
+   */
+  public void setName(String name)
+  {
+    fName = name;
+  }
+
+  /**
+   * Returns a string representation of this test case.
+   *
+   * @return a string representation of this TestCase
+   */
+  public String toString()
+  {
+    StringBuffer str = new StringBuffer();
+    str.append(getName());
+    str.append('(');
+    str.append(getClass().getName());
+    str.append(')');
+    return str.toString();
+  }
+
+  /**
+   * Implementation of Mauve's Testlet interface. This makes JUnit TestCases
+   * automatically executable by the Mauve test harness.
+   */
+  public void test(TestHarness harness)
+  {
+    // Fetch the actual JUnit testsuite.
+    Test test = getTest();
+    // This is normally an instance of TestSuite.
+    if (test instanceof TestSuite)
+      {
+        TestSuite suite = (TestSuite) test;
+        suite.test(harness);
+      }
+  }
+
+  /**
+   * Performs a single test.
+   *
+   * @param harness the test harness to use
+   */
+  void testSingle(TestHarness harness)
+  {
+    TestCase.harness = harness;
+    try
+      {
+        runBare();
+      }
+    catch (Throwable ex)
+      {
+        harness.fail(ex.getMessage());
+        harness.debug(ex);
+      }
+    TestCase.harness = null;
+  }
+
+  /**
+   * Fetches the test suite to be run. This tries to call a static
+   * suite() method on this class, and, if that fails, create a new TestSuite
+   * with this class as parameter, which will collect all test*() methods.
+   *
+   * @return the testsuite for this class or null, if no test suite could be
+   *         created
+   */
+  private Test getTest()
+  {
+    Class clazz = getClass();
+    Method suiteMethod = null;
+    Test test = null;
+    try
+      {
+        clazz.getMethod("suite", new Class[0]);
+      }
+    catch (Exception ex)
+      {
+        test = new TestSuite(clazz);
+      }
+    if (test == null && suiteMethod != null) // suite() method found.
+      {
+        try
+          {
+            test = (Test) suiteMethod.invoke(null, (Object[]) new Class[0]);
+          }
+        catch (InvocationTargetException ex)
+          {
+            test = null;
+          }
+        catch (IllegalAccessException ex)
+          {
+            test = null;
+          }
+      }
+    return test;
+  }
+}
Index: junit/framework/TestFailure.java
===================================================================
RCS file: junit/framework/TestFailure.java
diff -N junit/framework/TestFailure.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ junit/framework/TestFailure.java	6 Oct 2006 10:37:44 -0000
@@ -0,0 +1,116 @@
+/* TestFailure.java -- Wraps a test failure
+   Copyright (C) 2006 Roman Kennke (kennke@aicas.com)
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: not-a-test
+
+package junit.framework;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * Wraps a failed test together with the failure.
+ */
+public class TestFailure
+{
+
+  /**
+   * The test that failed.
+   */
+  protected Test fFailedTest;
+
+  /**
+   * The exception that has been thrown.
+   */
+  protected Throwable fThrownException;
+
+  /**
+   * Creates a new TestFailure.
+   *
+   * @param failedTest the failed test
+   * @param thrownException the thrown exception
+   */
+  public TestFailure(Test failedTest, Throwable thrownException)
+  {
+    fFailedTest = failedTest;
+    fThrownException = thrownException;
+  }
+
+  /**
+   * Returns the message of the thrown exception.
+   *
+   * @return the message of the thrown exception
+   */
+  public String exceptionMessage()
+  {
+    return fThrownException.getMessage();
+  }
+
+  /**
+   * Returns the failed test.
+   *
+   * @return the failed test
+   */
+  public Test failedTest()
+  {
+    return fFailedTest;
+  }
+
+  /**
+   * Returns <code>true</code>, if this is a failure (that is, the exception is
+   * an instance of {@link AssertionFailedError}, <code>false</code>
+   * otherwise (in case of error for instance).
+   *
+   * @return <code>true</code>, if this is a failure, <code>false</code>
+   *         otherwise
+   */
+  public boolean isFailure()
+  {
+    return fThrownException instanceof AssertionFailedError;
+  }
+
+  /**
+   * Returns a string representation of this TestFailure object.
+   *
+   * @return a string representation of this TestFailure object
+   */
+  public String toString()
+  {
+    StringBuffer str = new StringBuffer();
+    str.append(fFailedTest);
+    str.append(": ");
+    str.append(fThrownException.getMessage());
+    return str.toString();
+  }
+
+  /**
+   * Returns the stacktrace of the exception as string.
+   *
+   * @return the stacktrace of the exception as string
+   */
+  public String trace()
+  {
+    StringWriter w = new StringWriter();
+    PrintWriter p = new PrintWriter(w);
+    fThrownException.printStackTrace(p);
+    return w.getBuffer().toString();
+  }
+}
Index: junit/framework/TestListener.java
===================================================================
RCS file: junit/framework/TestListener.java
diff -N junit/framework/TestListener.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ junit/framework/TestListener.java	6 Oct 2006 10:37:44 -0000
@@ -0,0 +1,60 @@
+/* TestListener.java -- Listens for test progress
+   Copyright (C) 2006 Roman Kennke (kennke@aicas.com)
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: not-a-test
+
+package junit.framework;
+
+/**
+ * Listens for progress on a test.
+ */
+public interface TestListener
+{
+  /**
+   * Notifies that a test error has occured.
+   *
+   * @param test the test
+   * @param t the error that was thrown
+   */
+  void addError(Test test, Throwable t);
+
+  /**
+   * Notifies that a test failure has occured.
+   *
+   * @param test the test
+   * @param t the failure
+   */
+  void addFailure(Test test, AssertionFailedError t);
+
+  /**
+   * Notifies that a new test has started.
+   * 
+   * @param test the test
+   */
+  void startTest(Test test);
+
+  /**
+   * Notifies that a new test has been finished.
+   * 
+   * @param test the test
+   */
+  void endTest(Test test);
+}
Index: junit/framework/TestResult.java
===================================================================
RCS file: junit/framework/TestResult.java
diff -N junit/framework/TestResult.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ junit/framework/TestResult.java	6 Oct 2006 10:37:44 -0000
@@ -0,0 +1,300 @@
+/* TestResult.java -- Collects test results
+   Copyright (C) 2006 Roman Kennke (kennke@aicas.com)
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: not-a-test
+
+package junit.framework;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Collects the results of a test run.
+ */
+public class TestResult
+{
+
+  /**
+   * The errors from the test run.
+   */
+  protected List fErrors;
+
+  /**
+   * The failures from the test run.
+   */
+  protected List fFailures;
+
+  /**
+   * The test listeners.
+   */
+  protected List fListeners;
+
+  /**
+   * The number of tests that have been run.
+   */
+  protected int fRunTests;
+
+  /**
+   * Indicates if the test run should stop.
+   */
+  private boolean fStop;
+
+  /**
+   * Creates a new TestResult object.
+   */
+  public TestResult()
+  {
+    fErrors = new ArrayList();
+    fFailures = new ArrayList();
+    fListeners = new ArrayList();
+    fRunTests = 0;
+    fStop = false;
+  }
+
+  /**
+   * Runs the specified TestCase.
+   *
+   * @param test the test case to run
+   */
+  protected void run(final TestCase test)
+  {
+    startTest(test);
+    Protectable protectable = new Protectable()
+    {
+      public void protect()
+        throws Throwable
+      {
+        test.runBare();
+      }
+    };
+    runProtected(test, protectable);
+    endTest(test);
+  }
+
+  /**
+   * Runs a test in a protected environment.
+   *
+   * @param test the test to run
+   * @param p the protectable
+   */
+  public void runProtected(final TestCase test, Protectable p)
+  {
+    try
+      {
+        p.protect();
+      }
+    catch (AssertionFailedError e)
+      {
+        addFailure(test, e);
+      }
+    catch (ThreadDeath e)
+      {
+        throw e;
+      }
+    catch (Throwable e)
+      {
+        addError(test, e);
+      }
+  }
+
+  /**
+   * Starts the specified test. This counts the tests and informs
+   * interested listeners.
+   *
+   * @param test the test to start
+   */
+  public void startTest(Test test)
+  {
+    final int count = test.countTestCases();
+    synchronized (this)
+      {
+        fRunTests += count;
+      }
+    for (Iterator i = cloneListeners().iterator(); i.hasNext();)
+      {
+        TestListener l = (TestListener) i.next();
+        l.startTest(test);
+      }
+  }
+
+  /**
+   * Ends the specified test. This informs interested listeners.
+   *
+   * @param test the test to end
+   */
+  public void endTest(Test test)
+  {
+    for (Iterator i = cloneListeners().iterator(); i.hasNext();)
+      {
+        TestListener l = (TestListener) i.next();
+        l.endTest(test);
+      }
+  }
+
+  /**
+   * Adds a failure to the test result.
+   *
+   * @param test the failed test
+   * @param failure the test failure
+   */
+  public synchronized void addFailure(Test test, AssertionFailedError failure)
+  {
+    fFailures.add(new TestFailure(test, failure));
+    for (Iterator i = cloneListeners().iterator(); i.hasNext();)
+      {
+        TestListener l = (TestListener) i.next();
+        l.addFailure(test, failure);
+      }
+  }
+
+  /**
+   * Adds an error to the test result.
+   *
+   * @param test the err'ed test
+   * @param failure the test error
+   */
+  public synchronized void addError(Test test, Throwable failure)
+  {
+    fErrors.add(new TestFailure(test, failure));
+    for (Iterator i = cloneListeners().iterator(); i.hasNext();)
+      {
+        TestListener l = (TestListener) i.next();
+        l.addError(test, failure);
+      }
+  }
+
+  /**
+   * Adds a test listener.
+   *
+   * @param l the listener to add
+   */
+  public synchronized void addListener(TestListener l)
+  {
+    fListeners.add(l);
+  }
+
+  /**
+   * Removes a test listener.
+   *
+   * @param l the listener to be removed
+   */
+  public synchronized void removeListener(TestListener l)
+  {
+    fListeners.remove(l);
+  }
+
+  /**
+   * Returns the number of errors.
+   *
+   * @return the number of errors
+   */
+  public synchronized int errorCount()
+  {
+    return fErrors.size();
+  }
+
+  /**
+   * Returns the errors in this test result.
+   *
+   * @return the errors in this test result
+   */
+  public synchronized Enumeration errors()
+  {
+    return Collections.enumeration(fErrors);
+  }
+
+  /**
+   * Returns the number of failures.
+   *
+   * @return the number of failures
+   */
+  public synchronized int failureCount()
+  {
+    return fFailures.size();
+  }
+
+  /**
+   * Returns the failures in this test result.
+   *
+   * @return the failures in this test result
+   */
+  public synchronized Enumeration failures()
+  {
+    return Collections.enumeration(fFailures);
+  }
+
+  /**
+   * Returns the number of tests that have been run.
+   *
+   * @return the number of tests that have been run
+   */
+  public synchronized int runCount()
+  {
+    return fRunTests;
+  }
+
+  /**
+   * Returns <code>true</code> when the test should stop, <code>false</code>
+   * otherwise.
+   *
+   * @return <code>true</code> when the test should stop, <code>false</code>
+   *         otherwise
+   */
+  public synchronized boolean shouldStop()
+  {
+    return fStop;
+  }
+
+  /**
+   * Stops the test.
+   */
+  public synchronized void stop()
+  {
+    fStop = true;
+  }
+
+  /**
+   * Returns <code>true</code> when the test had no errors and no failures,
+   * <code>false</code> otherwise.
+   *
+   * @return <code>true</code> when the test had no errors and no failures,
+   *         <code>false</code> otherwise
+   */
+  public synchronized boolean wasSuccessful()
+  {
+    return failureCount() == 0 && errorCount() == 0;
+  }
+
+  /**
+   * Returns a cloned listener list.
+   *
+   * @return a cloned listener list
+   */
+  private synchronized List cloneListeners()
+  {
+    List copy = new ArrayList();
+    copy.addAll(fListeners);
+    return copy;
+  }
+}
Index: junit/framework/TestSuite.java
===================================================================
RCS file: junit/framework/TestSuite.java
diff -N junit/framework/TestSuite.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ junit/framework/TestSuite.java	6 Oct 2006 10:37:44 -0000
@@ -0,0 +1,338 @@
+/* TestSuite.java -- JUnit test suite
+   Copyright (C) 2006 Roman Kennke (kennke@aicas.com)
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: not-a-test
+
+package junit.framework;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import gnu.testlet.Testlet;
+import gnu.testlet.TestHarness;
+
+/**
+ * A collection of JUnit tests.
+ */
+public class TestSuite
+  implements Test, Testlet
+{
+
+  /**
+   * The name of the test.
+   */
+  private String fName;
+
+  /**
+   * The tests in this test suite.
+   */
+  private Vector fTests;
+
+  /**
+   * Creates a new test suite.
+   */
+  public TestSuite()
+  {
+    fTests = new Vector();
+  }
+
+  /**
+   * Creates a new test suite that loads its tests from the specified class.
+   *
+   * @param theClass the class to load the tests from
+   */
+  public TestSuite(Class theClass)
+  {
+    this();
+    fName = theClass.getName();
+    Class clazz = theClass;
+    List names = new ArrayList();
+    while (Test.class.isAssignableFrom(clazz))
+      {
+        Method[] methods = clazz.getDeclaredMethods();
+        for (int i = 0; i < methods.length; i++)
+          {
+            addTestMethod(methods[i], names, theClass);
+          }
+        clazz = clazz.getSuperclass();
+      }
+  }
+
+  /**
+   * Creates a new TestSuite with the specified name.
+   *
+   * @param name the name of the test suite
+   */
+  public TestSuite(String name)
+  {
+    setName(name);
+  }
+
+  /**
+   * Creates a new TestSuite with the specified name that loads the tests from
+   * the specified class.
+   *
+   * @param theClass the class to load the tests from
+   * @param name the name of the test suite
+   */
+  public TestSuite(Class theClass, String name)
+  {
+    this(theClass);
+    setName(name);
+  }
+
+  /**
+   * Adds the specified method to the test suite if appropriate.
+   *
+   * @param method the method to check
+   * @param names the list of names of already added methods
+   * @param theClass the test class
+   */
+  private void addTestMethod(Method method, List names, Class theClass)
+  {
+    String name = method.getName();
+    if (! names.contains(name))
+      {
+        if (isPublicTestMethod(method))
+          {
+            names.add(name);
+            addTest(createTest(theClass, name));
+          }
+      }
+  }
+
+  /**
+   * Checks if the specified method is a test method and is public.
+   *
+   * @param method the method to check
+   *
+   * @return <code>true</code> if the method is a public test method,
+   *         <code>false</code> otherwise
+   */
+  private boolean isPublicTestMethod(Method method)
+  {
+    return isTestMethod(method) && Modifier.isPublic(method.getModifiers());
+  }
+
+  /**
+   * Checks if the specified method is a test method.
+   *
+   * @param method the method to check
+   *
+   * @return <code>true</code> if the method is a test method,
+   *         <code>false</code> otherwise
+   */
+  private boolean isTestMethod(Method method)
+  {
+    String name = method.getName();
+    Class[] params = method.getParameterTypes();
+    Class ret = method.getReturnType();
+    return params.length == 0 && name.startsWith("test")
+           && ret.equals(Void.TYPE);
+  }
+
+  /**
+   * Creates a test for the specified test class and with the specified
+   * name.
+   *
+   * @param theClass the test class
+   * @param name the test name
+   *
+   * @return the test instance
+   */
+  public static Test createTest(Class theClass, String name)
+  {
+    Constructor constructor = null;
+    Test test = null;
+    try
+      {
+        constructor = getTestConstructor(theClass);
+      }
+    catch (NoSuchMethodException ex)
+      {
+        test = null;
+      }
+    if (constructor != null)
+      {
+        Object o = null;
+        try
+          {
+            if (constructor.getParameterTypes().length == 0)
+              {
+                o = constructor.newInstance(new Object[0]);
+                if (o instanceof TestCase)
+                  ((TestCase) o).setName(name);
+              }
+            else
+              {
+                o = constructor.newInstance(new Object[]{ name });
+              }
+          }
+        catch (InstantiationException ex)
+          {
+            test = null;
+          }
+        catch (InvocationTargetException ex)
+          {
+            test = null;
+          }
+        catch (IllegalAccessException ex)
+          {
+            test = null;
+          }
+        test = (Test) o;
+      }
+    return test;
+  }
+
+  /**
+   * Returns the constructor for the specified test class.
+   *
+   * @param theClass the test class
+   *
+   * @return the constructor for the specified test class
+   *
+   * @throws NoSuchMethodException if no suitable constructor exists
+   */
+  public static Constructor getTestConstructor(Class theClass)
+    throws NoSuchMethodException
+  {
+    Class[] args = { String.class };
+    try
+      {
+        return theClass.getConstructor(args);
+      }
+    catch (NoSuchMethodException ex)
+      {
+        // Search for a no-arg constructor below.
+      }
+    return theClass.getConstructor(new Class[0]);
+  }
+
+  /**
+   * Returns the number of tests in this test suite.
+   *
+   * @return the number of tests in this test suite
+   */
+  public int countTestCases()
+  {
+    int count = 0;
+    for (Iterator i = fTests.iterator(); i.hasNext();)
+      {
+        Test test = (Test) i.next();
+        count += test.countTestCases();
+      }
+    return count;
+  }
+
+  /**
+   * Runs the test cases from this test suite.
+   *
+   * @param result the test results
+   */
+  public void run(TestResult result)
+  {
+    for (Iterator i = fTests.iterator(); i.hasNext();)
+      {
+        if (! result.shouldStop())
+          {
+            Test test = (Test) i.next();
+            runTest(test, result);
+          }
+      }
+  }
+
+  /**
+   * Runs a single test.
+   *
+   * @param test the test to run
+   * @param result the test results
+   */
+  public void runTest(Test test, TestResult result)
+  {
+    test.run(result);
+  }
+
+  /**
+   * Adds a single test to the test suite.
+   *
+   * @param test the test to add
+   */
+  public void addTest(Test test)
+  {
+    fTests.add(test);
+  }
+
+  /**
+   * Adds tests from the specified class to the test suite.
+   *
+   * @param testClass the class from which to load tests to add
+   */
+  public void addTestSuite(Class testClass)
+  {
+    fTests.add(new TestSuite(testClass));
+  }
+
+  /**
+   * Sets the name for this test.
+   *
+   * @param name the name to set
+   */
+  public void setName(String name)
+  {
+    fName = name;
+  }
+
+  /**
+   * Returns the name of this test.
+   *
+   * @return the name of this test
+   */
+  public String getName()
+  {
+    return fName;
+  }
+
+  /**
+   * This implements the Mauve Testlet interface. This implementation
+   * runs all tests in this testsuite that are runnable by Mauve.
+   *
+   * @param harness the Mauve test harness
+   */
+  public void test(TestHarness harness)
+  {
+    for (Iterator i = fTests.iterator(); i.hasNext();)
+      {
+        Test test = (Test) i.next();
+        if (test instanceof TestCase)
+          ((TestCase) test).testSingle(harness);
+        else if (test instanceof Testlet)
+          ((Testlet) test).test(harness);
+      }
+  }
+
+}
Index: junit/framework/package.html
===================================================================
RCS file: junit/framework/package.html
diff -N junit/framework/package.html
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ junit/framework/package.html	6 Oct 2006 10:37:44 -0000
@@ -0,0 +1,36 @@
+<!--
+   Copyright (C) 2006 Roman Kennke (kennke@aicas.com)
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+-->
+<html>
+  <head>
+    <title>Mauve JUnit bridge</title>
+  <body>
+    <h1>Mauve JUnit bridge</h1>
+    <p>Allows JUnit tests to be run inside the Mauve Harness. This is a
+     complete implementation of the JUnit core API, with the additional
+     functionality to make every JUnit test case automatically runnable
+     inside Mauve. To achieve this, two changes to the API have been applied:
+     Both the TestCase and TestSuite class implement gnu.testlet.Testlet,
+     which makes them a Mauve Testlet. The methods Assert have been prepared
+     so that they call into the TestHarness check() methods when beeing
+     run inside a Mauve TestHarness. Otherwise they throw AssertionFailedErrors
+     like the standard JUnit implementation.</p>
+  </body>
+</html>
Index: junit/runner/BaseTestRunner.java
===================================================================
RCS file: junit/runner/BaseTestRunner.java
diff -N junit/runner/BaseTestRunner.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ junit/runner/BaseTestRunner.java	6 Oct 2006 10:37:44 -0000
@@ -0,0 +1,30 @@
+/* BaseRunner.java -- Base class for test runners
+   Copyright (C) 2006 Roman Kennke (kennke@aicas.com)
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: not-a-test
+
+package junit.runner;
+
+// TODO: Implement.
+public class BaseTestRunner
+{
+
+}
Index: junit/textui/TestRunner.java
===================================================================
RCS file: junit/textui/TestRunner.java
diff -N junit/textui/TestRunner.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ junit/textui/TestRunner.java	6 Oct 2006 10:37:44 -0000
@@ -0,0 +1,44 @@
+/* TestRunner.java -- A text output test runner
+   Copyright (C) 2006 Roman Kennke (kennke@aicas.com)
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: not-a-test
+
+package junit.textui;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.runner.BaseTestRunner;
+
+// TODO: Implement.
+public class TestRunner
+  extends BaseTestRunner
+{
+
+  public static void run(Class testClass)
+  {
+    run(new TestSuite(testClass));
+  }
+
+  public static void run(Test test)
+  {
+    
+  }
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-10-06 10:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-06 10:43 FYI: Mauve goes JUnit Roman Kennke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).