diff options
author | Finn Bock <bckfnn@apache.org> | 2004-01-21 19:35:00 +0000 |
---|---|---|
committer | Finn Bock <bckfnn@apache.org> | 2004-01-21 19:35:00 +0000 |
commit | aa2a7247f976a73b92909bc76614cdc871b87fad (patch) | |
tree | 7cf44815f9164db36f6d3f47e153b10017bbded6 /src/java/org | |
parent | ea5870e1ceaecd87fa9ba9699cb18562194bef4b (diff) | |
download | xmlgraphics-fop-aa2a7247f976a73b92909bc76614cdc871b87fad.tar.gz xmlgraphics-fop-aa2a7247f976a73b92909bc76614cdc871b87fad.zip |
Add dependant jars to the classloader.
Don't check for org.apache.fop.apps.Options, it does not exists anymore.
PR: 25691
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197239 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org')
-rw-r--r-- | src/java/org/apache/fop/tools/anttasks/RunTest.java | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/java/org/apache/fop/tools/anttasks/RunTest.java b/src/java/org/apache/fop/tools/anttasks/RunTest.java index 1fa6d00dc..7605e7ef6 100644 --- a/src/java/org/apache/fop/tools/anttasks/RunTest.java +++ b/src/java/org/apache/fop/tools/anttasks/RunTest.java @@ -61,6 +61,7 @@ import java.lang.reflect.Method; import java.net.URLClassLoader; import java.net.URL; import java.net.MalformedURLException; +import java.util.ArrayList; import java.util.Iterator; import java.util.Map; @@ -128,9 +129,8 @@ public class RunTest extends Task { */ protected void testNewBuild() { try { - ClassLoader loader = new URLClassLoader(new URL[] { - new URL("file:build/fop.jar") - }); + ClassLoader loader = new URLClassLoader( + createUrls("build/fop.jar")); Map diff = runConverter(loader, "areatree", "reference/output/"); if (diff != null && !diff.isEmpty()) { @@ -172,16 +172,11 @@ public class RunTest extends Task { // return; // } else { try { - ClassLoader loader = new URLClassLoader(new URL[] { - new URL("file:" + referenceJar) - }); + ClassLoader loader = new URLClassLoader(createUrls(referenceJar)); boolean failed = false; try { - Class cla = Class.forName("org.apache.fop.apps.Options", - true, loader); - /*Object opts =*/ cla.newInstance(); - cla = Class.forName("org.apache.fop.apps.Version", true, + Class cla = Class.forName("org.apache.fop.apps.Version", true, loader); Method get = cla.getMethod("getVersion", new Class[]{}); if (!get.invoke(null, new Object[]{}).equals(refVersion)) { @@ -196,8 +191,6 @@ public class RunTest extends Task { failed = true; } catch (ClassNotFoundException are) { failed = true; - } catch (InstantiationException are) { - failed = true; } catch (NoSuchMethodException are) { failed = true; } @@ -253,4 +246,20 @@ public class RunTest extends Task { return diff; } + /** + * Return a list of URL's with the specified URL first and followed + * by all the jar files from lib/. + * @return a list of urls to the runtime jar files. + */ + private URL[] createUrls(String mainJar) throws MalformedURLException { + ArrayList urls = new ArrayList(); + urls.add(new File(mainJar).toURL()); + File[] libFiles = new File("lib").listFiles(); + for (int i = 0; i < libFiles.length; i++) { + if (libFiles[i].getPath().endsWith(".jar")) { + urls.add(libFiles[i].toURL()); + } + } + return (URL[]) urls.toArray(new URL[urls.size()]); + } } |