From: Lars Grefer Date: Fri, 14 Aug 2020 22:59:58 +0000 (+0200) Subject: Update to JUnit 4.13 X-Git-Tag: V1_9_7M1~13 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=48522f987fb2247a190c842e871edd70ff63df2b;p=aspectj.git Update to JUnit 4.13 Signed-off-by: Lars Grefer --- diff --git a/ajde/src/test/java/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java b/ajde/src/test/java/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java index fe642ff95..74a8cc1eb 100644 --- a/ajde/src/test/java/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java +++ b/ajde/src/test/java/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java @@ -28,10 +28,6 @@ public class LstBuildConfigManagerTest extends AjdeTestCase { private BuildConfigManager buildConfigManager = new LstBuildConfigManager(); - public static void main(String[] args) { - junit.swingui.TestRunner.run(LstBuildConfigManagerTest.class); - } - public static TestSuite suite() { TestSuite result = new TestSuite(); result.addTestSuite(LstBuildConfigManagerTest.class); diff --git a/ajde/src/test/java/org/aspectj/ajde/ui/StructureSearchManagerTest.java b/ajde/src/test/java/org/aspectj/ajde/ui/StructureSearchManagerTest.java index 1dc3d9928..ecbfed0d7 100644 --- a/ajde/src/test/java/org/aspectj/ajde/ui/StructureSearchManagerTest.java +++ b/ajde/src/test/java/org/aspectj/ajde/ui/StructureSearchManagerTest.java @@ -26,10 +26,6 @@ import junit.framework.TestSuite; * @author Mik Kersten */ public class StructureSearchManagerTest extends AjdeTestCase { - - public static void main(String[] args) { - junit.swingui.TestRunner.run(StructureSearchManagerTest.class); - } public static TestSuite suite() { TestSuite result = new TestSuite(); diff --git a/ajde/src/test/java/org/aspectj/ajde/ui/StructureViewManagerTest.java b/ajde/src/test/java/org/aspectj/ajde/ui/StructureViewManagerTest.java index eca56feec..c2372ddb7 100644 --- a/ajde/src/test/java/org/aspectj/ajde/ui/StructureViewManagerTest.java +++ b/ajde/src/test/java/org/aspectj/ajde/ui/StructureViewManagerTest.java @@ -38,10 +38,6 @@ public class StructureViewManagerTest extends AjdeTestCase { private File testFile; private StructureViewProperties properties; - public static void main(String[] args) { - junit.swingui.TestRunner.run(StructureViewManagerTest.class); - } - public static TestSuite suite() { TestSuite result = new TestSuite(); result.addTestSuite(StructureViewManagerTest.class); diff --git a/pom.xml b/pom.xml index 898d9c781..32934ba49 100644 --- a/pom.xml +++ b/pom.xml @@ -134,7 +134,7 @@ junit junit - 3.8.1 + 4.13 test diff --git a/testing-util/pom.xml b/testing-util/pom.xml index 8d96c92b2..d3deb8e65 100644 --- a/testing-util/pom.xml +++ b/testing-util/pom.xml @@ -35,7 +35,7 @@ junit junit - 3.8.1 + 4.13 jdiff diff --git a/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java b/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java index 76b7a181a..cf2ae8ef0 100644 --- a/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java +++ b/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java @@ -28,18 +28,8 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.net.MalformedURLException; import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; +import java.net.URLClassLoader; +import java.util.*; import org.aspectj.bridge.IMessageHandler; import org.aspectj.bridge.MessageUtil; @@ -56,7 +46,7 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestResult; import junit.framework.TestSuite; -import junit.runner.TestCaseClassLoader; +import sun.net.www.ParseUtil; /** * Things that junit should perhaps have, but doesn't. Note the file-comparison methods require JDiff to run, but JDiff types are @@ -383,7 +373,7 @@ public final class TestUtil { public static Object runMethod(String classPath, String className, String methodName, Object[] args) { classPath += File.pathSeparator + System.getProperty("java.class.path"); - ClassLoader loader = new TestCaseClassLoader(classPath); + ClassLoader loader = new URLClassLoader(pathToURLs(classPath), null); Class c = null; try { @@ -394,6 +384,33 @@ public final class TestUtil { return Reflection.invokestaticN(c, methodName, args); } + /** + * @see sun.misc.URLClassPath#pathToURLs(String) + */ + public static URL[] pathToURLs(String path) { + StringTokenizer st = new StringTokenizer(path, File.pathSeparator); + URL[] urls = new URL[st.countTokens()]; + int count = 0; + while (st.hasMoreTokens()) { + File f = new File(st.nextToken()); + try { + f = new File(f.getCanonicalPath()); + } catch (IOException x) { + // use the non-canonicalized filename + } + try { + urls[count++] = ParseUtil.fileToEncodedURL(f); + } catch (IOException x) { } + } + + if (urls.length != count) { + URL[] tmp = new URL[count]; + System.arraycopy(urls, 0, tmp, 0, count); + urls = tmp; + } + return urls; + } + /** * Checks that two multi-line strings have the same value. Each line is trimmed before comparision Produces an error on the * particular line of conflict diff --git a/testing/pom.xml b/testing/pom.xml index 0f6977bb6..1fb99c417 100644 --- a/testing/pom.xml +++ b/testing/pom.xml @@ -135,7 +135,7 @@ junit junit - 3.8.1 + 4.13 commons diff --git a/testing/src/test/java/org/aspectj/testing/AutowiredXMLBasedAjcTestCase.java b/testing/src/test/java/org/aspectj/testing/AutowiredXMLBasedAjcTestCase.java index 2b7e4942f..f36959c7e 100644 --- a/testing/src/test/java/org/aspectj/testing/AutowiredXMLBasedAjcTestCase.java +++ b/testing/src/test/java/org/aspectj/testing/AutowiredXMLBasedAjcTestCase.java @@ -48,7 +48,7 @@ public abstract class AutowiredXMLBasedAjcTestCase extends XMLBasedAjcTestCase { return testMap; } - public static Test loadSuite(Class testCaseClass) { + public static Test loadSuite(Class testCaseClass) { TestSuite suite = new TestSuite(testCaseClass.getName()); //suite.addTestSuite(testCaseClass); diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java index e5e2fcdb9..e3d29e966 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.Map; import java.util.Stack; +import junit.framework.TestCase; import org.apache.commons.digester.Digester; import org.aspectj.apache.bcel.classfile.Attribute; import org.aspectj.apache.bcel.classfile.JavaClass; @@ -81,7 +82,7 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase { * @param testCaseClass * @return */ - public static Test loadSuite(Class testCaseClass) { + public static Test loadSuite(Class testCaseClass) { TestSuite suite = new TestSuite(testCaseClass.getName()); suite.addTestSuite(testCaseClass); TestSetup wrapper = new TestSetup(suite) { diff --git a/testing/src/test/java/org/aspectj/testing/util/StructureModelUtilTest.java b/testing/src/test/java/org/aspectj/testing/util/StructureModelUtilTest.java index 11b9ea2b4..0b9d7ef41 100644 --- a/testing/src/test/java/org/aspectj/testing/util/StructureModelUtilTest.java +++ b/testing/src/test/java/org/aspectj/testing/util/StructureModelUtilTest.java @@ -34,10 +34,6 @@ public class StructureModelUtilTest extends AjdeCoreTestCase { "figures" + File.separator + "primitives" + File.separator + "planar" + File.separator + "Point.java", "figures" + File.separator + "primitives" + File.separator + "solid" + File.separator + "SolidPoint.java" }; - public static void main(String[] args) { - junit.swingui.TestRunner.run(StructureModelUtilTest.class); - } - public static TestSuite suite() { TestSuite result = new TestSuite(); result.addTestSuite(StructureModelUtilTest.class);