From: Christian Thalinger Date: Tue, 17 Jun 2008 14:25:28 +0000 (+0200) Subject: * tests/regression/base/All.java, X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=cacao.git;a=commitdiff_plain;h=528c824602be8a4ff95abd12eb0bf6f077582f90 * tests/regression/base/All.java, tests/regression/base/TestExceptionInStaticClassInitializer.java, tests/regression/base/TestPatcher.java, tests/regression/bugzilla/All.java, tests/regression/bugzilla/PR52.java, tests/regression/bugzilla/PR57.java, tests/regression/bugzilla/PR58.java, tests/regression/bugzilla/PR65.java, tests/regression/bugzilla/PR80.java: Ported to JUnit 4. --- diff --git a/tests/regression/base/All.java b/tests/regression/base/All.java index 15a552301..9d9c8e8b7 100644 --- a/tests/regression/base/All.java +++ b/tests/regression/base/All.java @@ -23,30 +23,15 @@ */ -import junit.framework.*; -import junit.textui.*; - -public class All extends TestCase { - /** - * Runs all CACAO regression unit tests using - * junit.textui.TestRunner - */ - public static void main(String[] args) { - Test s = suite(); - TestRunner.run(s); - } - - /** - * Collects all CACAO regression unit tests as one suite. - */ - public static Test suite() { - TestSuite suite = new TestSuite("CACAO Regression Unit Tests"); - - // Add your test here. - - suite.addTest(new TestSuite(TestPatcher.class)); - suite.addTest(new TestSuite(TestExceptionInStaticClassInitializer.class)); - - return suite; - } +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) + +@Suite.SuiteClasses({ +TestExceptionInStaticClassInitializer.class, +TestPatcher.class +}) + +public class All { } diff --git a/tests/regression/base/TestExceptionInStaticClassInitializer.java b/tests/regression/base/TestExceptionInStaticClassInitializer.java index e6cc93e07..61ab65cba 100644 --- a/tests/regression/base/TestExceptionInStaticClassInitializer.java +++ b/tests/regression/base/TestExceptionInStaticClassInitializer.java @@ -23,18 +23,11 @@ */ -import junit.framework.*; -import junit.textui.*; - -public class TestExceptionInStaticClassInitializer extends TestCase { - public static void main(String[] args) { - TestRunner.run(suite()); - } - - public static Test suite() { - return new TestSuite(TestExceptionInStaticClassInitializer.class); - } +import org.junit.Test; +import static org.junit.Assert.*; +public class TestExceptionInStaticClassInitializer { + @Test public void test() { try { TestExceptionInStaticClassInitializer_x.i = 1; @@ -52,7 +45,7 @@ public class TestExceptionInStaticClassInitializer extends TestCase { } // This linenumber must be the one from... - final static int LINE = 64; + final static int LINE = 57; } class TestExceptionInStaticClassInitializer_x { diff --git a/tests/regression/base/TestPatcher.java b/tests/regression/base/TestPatcher.java index 841760826..cbf8a1339 100644 --- a/tests/regression/base/TestPatcher.java +++ b/tests/regression/base/TestPatcher.java @@ -23,20 +23,12 @@ */ -import junit.framework.*; -import junit.textui.*; +import org.junit.Test; +import static org.junit.Assert.*; import java.io.*; -public class TestPatcher extends TestCase { - public static void main(String[] args) { - TestRunner.run(suite()); - } - - public static Test suite() { - return new TestSuite(TestPatcher.class); - } - +public class TestPatcher { static boolean doit = true; final static int i = 123; @@ -45,6 +37,7 @@ public class TestPatcher extends TestCase { final static double d = 789.012; final static Object o = new Object(); + @Test public void testNormal() { invokestatic(); invokespecial(); diff --git a/tests/regression/bugzilla/All.java b/tests/regression/bugzilla/All.java index bdf089878..773d457cd 100644 --- a/tests/regression/bugzilla/All.java +++ b/tests/regression/bugzilla/All.java @@ -23,33 +23,19 @@ */ -import junit.framework.*; -import junit.textui.*; - -public class All extends TestCase { - /** - * Runs all CACAO regression unit tests using - * junit.textui.TestRunner - */ - public static void main(String[] args) { - Test s = suite(); - TestRunner.run(s); - } - - /** - * Collects all CACAO regression unit tests as one suite - */ - public static Test suite() { - TestSuite suite = new TestSuite("CACAO Regression Unit Tests"); - - // Add your test here. - - suite.addTest(new TestSuite(PR52.class)); - suite.addTest(new TestSuite(PR57.class)); - suite.addTest(new TestSuite(PR58.class)); - suite.addTest(new TestSuite(PR65.class)); - suite.addTest(new TestSuite(PR80.class)); - - return suite; - } +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) + +@Suite.SuiteClasses({ +PR52.class, +PR57.class, +PR58.class, +PR65.class, +PR70.class, +PR80.class, +}) + +public class All { } diff --git a/tests/regression/bugzilla/PR52.java b/tests/regression/bugzilla/PR52.java index fae85f1ca..c189a2eb8 100644 --- a/tests/regression/bugzilla/PR52.java +++ b/tests/regression/bugzilla/PR52.java @@ -23,20 +23,12 @@ */ -import junit.framework.*; -import junit.textui.*; +import org.junit.Test; import java.security.*; -public class PR52 extends TestCase { - public static void main(String[] args) { - TestRunner.run(suite()); - } - - public static Test suite() { - return new TestSuite(PR52.class); - } - +public class PR52 { + @Test public void test() { // This one only triggers with GNU Classpath. AccessController.getContext(); diff --git a/tests/regression/bugzilla/PR57.java b/tests/regression/bugzilla/PR57.java index b8a960fe6..2bd11f5d0 100644 --- a/tests/regression/bugzilla/PR57.java +++ b/tests/regression/bugzilla/PR57.java @@ -23,24 +23,11 @@ */ -import junit.framework.*; -import junit.textui.*; +import org.junit.Test; -public class PR57 extends TestCase { - public static void main(String[] args) { - TestRunner.run(suite()); - } - - public static Test suite() { - return new TestSuite(PR57.class); - } - - public void test() { - try { - Class.forName("x"); - fail("Should throw ClassNotFoundException"); - } - catch (ClassNotFoundException success) { - } +public class PR57 { + @Test ( expected = ClassNotFoundException.class ) + public void test() throws ClassNotFoundException { + Class.forName("x"); } } diff --git a/tests/regression/bugzilla/PR58.java b/tests/regression/bugzilla/PR58.java index d70281c29..e8c9db083 100644 --- a/tests/regression/bugzilla/PR58.java +++ b/tests/regression/bugzilla/PR58.java @@ -23,23 +23,16 @@ */ -import junit.framework.*; -import junit.textui.*; +import org.junit.Test; +import static org.junit.Assert.*; import java.io.*; -public class PR58 extends TestCase { - public static void main(String[] args) { - TestRunner.run(suite()); - } - - public static Test suite() { - return new TestSuite(PR58.class); - } - +public class PR58 { class x extends y {} class y {} + @Test public void testSuperClass() { // Delete the class file which is extended. new File("PR58$y.class").delete(); @@ -60,6 +53,7 @@ public class PR58 extends TestCase { interface i {} class j implements i {} + @Test public void testSuperInterface() { // Delete the interface file which is implemented. new File("PR58$i.class").delete(); diff --git a/tests/regression/bugzilla/PR65.java b/tests/regression/bugzilla/PR65.java index 400a3e61a..8fd141806 100644 --- a/tests/regression/bugzilla/PR65.java +++ b/tests/regression/bugzilla/PR65.java @@ -23,25 +23,13 @@ */ -import junit.framework.*; -import junit.textui.*; - -public class PR65 extends TestCase { - public static void main(String[] args) { - TestRunner.run(suite()); - } - - public static Test suite() { - return new TestSuite(PR65.class); - } - - public void test() { - try { - Object o = new int[2][1]; - Number[][] na = (Number[][]) o; - na[0][0] = null; - fail("Should throw ClassCastException"); - } catch (ClassCastException success) { - } +import org.junit.Test; + +public class PR65 { + @Test ( expected = ClassCastException.class ) + public void test() throws ClassCastException { + Object o = new int[2][1]; + Number[][] na = (Number[][]) o; + na[0][0] = null; } } diff --git a/tests/regression/bugzilla/PR80.java b/tests/regression/bugzilla/PR80.java index 5e6e401cb..85f23d820 100644 --- a/tests/regression/bugzilla/PR80.java +++ b/tests/regression/bugzilla/PR80.java @@ -23,26 +23,14 @@ */ -import junit.framework.*; -import junit.textui.*; - -public class PR80 extends TestCase { - public static void main(String[] args) { - TestRunner.run(suite()); - } - - public static Test suite() { - return new TestSuite(PR80.class); - } - - public void test() { - try { - // Taken from Mauve gnu.testlet.java.lang.System.arraycopy - int[] a = new int[5]; - int[] b = new int[5]; - System.arraycopy(a, 4, b, 4, Integer.MAX_VALUE); - fail("Should throw ArrayIndexOutOfBoundsException"); - } catch (ArrayIndexOutOfBoundsException success) { - } +import org.junit.Test; + +public class PR80 { + @Test ( expected = ArrayIndexOutOfBoundsException.class ) + public void test() throws ArrayIndexOutOfBoundsException { + // Taken from Mauve gnu.testlet.java.lang.System.arraycopy + int[] a = new int[5]; + int[] b = new int[5]; + System.arraycopy(a, 4, b, 4, Integer.MAX_VALUE); } }