]> source.dussan.org Git - aspectj.git/commitdiff
Update to JUnit 4.13
authorLars Grefer <eclipse@larsgrefer.de>
Fri, 14 Aug 2020 22:59:58 +0000 (00:59 +0200)
committerAndy Clement <aclement@pivotal.io>
Sat, 15 Aug 2020 16:27:26 +0000 (09:27 -0700)
Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
ajde/src/test/java/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java
ajde/src/test/java/org/aspectj/ajde/ui/StructureSearchManagerTest.java
ajde/src/test/java/org/aspectj/ajde/ui/StructureViewManagerTest.java
pom.xml
testing-util/pom.xml
testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java
testing/pom.xml
testing/src/test/java/org/aspectj/testing/AutowiredXMLBasedAjcTestCase.java
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java
testing/src/test/java/org/aspectj/testing/util/StructureModelUtilTest.java

index fe642ff95ee8486766fceca7d375554408932a04..74a8cc1eb5790a1d87b9a80aa3d056a6dc44afb9 100644 (file)
@@ -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);   
index 1dc3d99284563746231fedea1dc9e934bdd40685..ecbfed0d77b2912fe69ac3f686ef645d935e5da3 100644 (file)
@@ -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();
index eca56feec7a96efe3c83846fbd76b50be93c26bb..c2372ddb7ca68111ab59b6f49fcc3efeab36e765 100644 (file)
@@ -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 898d9c781956a110ae0e9e681de46854d1a91dba..32934ba49e8d4a1adeba926520e65de95b3cdb51 100644 (file)
--- a/pom.xml
+++ b/pom.xml
                <dependency>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
-                       <version>3.8.1</version>
+                       <version>4.13</version>
                        <scope>test</scope>
                </dependency>
        </dependencies>
index 8d96c92b269f3764182cf463c3a30e23e5f35bd0..d3deb8e65f5b11f422ef363a9b1c3f6a0274dbb2 100644 (file)
@@ -35,7 +35,7 @@
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
-      <version>3.8.1</version>
+      <version>4.13</version>
     </dependency>
     <dependency>
       <groupId>jdiff</groupId>
index 76b7a181a6ab8616e582609851ff229c08e37088..cf2ae8ef0444b3814f69f0b3204ca48c6b2e642a 100644 (file)
@@ -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
index 0f6977bb6e8378030051c592dca4bb4575d47818..1fb99c4174c651421cdffd4b6b54192563b20e2e 100644 (file)
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
-      <version>3.8.1</version>
+      <version>4.13</version>
     </dependency>
     <dependency>
       <groupId>commons</groupId>
index 2b7e4942f8d645efa4a21d7d224f723ce80ccd78..f36959c7ec6e8b1e8d24341284e692da6dfbe861 100644 (file)
@@ -48,7 +48,7 @@ public abstract class AutowiredXMLBasedAjcTestCase extends XMLBasedAjcTestCase {
         return testMap;
     }
 
-    public static Test loadSuite(Class<?> testCaseClass) {
+    public static Test loadSuite(Class<? extends TestCase> testCaseClass) {
         TestSuite suite = new TestSuite(testCaseClass.getName());
         //suite.addTestSuite(testCaseClass);
 
index e5e2fcdb9166d5492d0ca44be5ab41294dd3b96b..e3d29e966dfbe7f739191520330d9df7685c55d5 100644 (file)
@@ -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<? extends TestCase> testCaseClass) {
                TestSuite suite = new TestSuite(testCaseClass.getName());
                suite.addTestSuite(testCaseClass);
                TestSetup wrapper = new TestSetup(suite) {
index 11b9ea2b4676793e683a39de17869a3d5ba84254..0b9d7ef41760117b7dabc369b4f10cd690e0a205 100644 (file)
@@ -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);