diff options
author | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-15 00:59:58 +0200 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2020-08-15 09:27:26 -0700 |
commit | 48522f987fb2247a190c842e871edd70ff63df2b (patch) | |
tree | 87ddba53990457ac658892587d9a38aaec04e85d /testing-util/src/main/java | |
parent | dfa04a0104f7b0d7e59c7fb3ba5f43b06e49e29f (diff) | |
download | aspectj-48522f987fb2247a190c842e871edd70ff63df2b.tar.gz aspectj-48522f987fb2247a190c842e871edd70ff63df2b.zip |
Update to JUnit 4.13
Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
Diffstat (limited to 'testing-util/src/main/java')
-rw-r--r-- | testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java | 45 |
1 files changed, 31 insertions, 14 deletions
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 { @@ -395,6 +385,33 @@ public final class TestUtil { } /** + * @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 */ |