You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by bc...@apache.org on 2004/01/21 20:35:00 UTC

cvs commit: xml-fop/src/java/org/apache/fop/tools/anttasks RunTest.java

bckfnn      2004/01/21 11:35:00

  Modified:    src/java/org/apache/fop/tools/anttasks RunTest.java
  Log:
  Add dependant jars to the classloader.
  Don't check for org.apache.fop.apps.Options, it does not exists anymore.
  
  PR: 25691
  
  Revision  Changes    Path
  1.2       +21 -12    xml-fop/src/java/org/apache/fop/tools/anttasks/RunTest.java
  
  Index: RunTest.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/tools/anttasks/RunTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RunTest.java	11 Mar 2003 13:05:42 -0000	1.1
  +++ RunTest.java	21 Jan 2004 19:35:00 -0000	1.2
  @@ -61,6 +61,7 @@
   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 @@
        */
       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 @@
           // 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 @@
                   failed = true;
               } catch (ClassNotFoundException are) {
                   failed = true;
  -            } catch (InstantiationException are) {
  -                failed = true;
               } catch (NoSuchMethodException are) {
                   failed = true;
               }
  @@ -253,4 +246,20 @@
           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()]);
  +    }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org