KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > ejtools > management > test > Main


1 /*
2  * EJTools, the Enterprise Java Tools
3  *
4  * Distributable under LGPL license.
5  * See terms of license at www.gnu.org.
6  */

7 package net.sourceforge.ejtools.management.test;
8
9 import java.io.File JavaDoc;
10 import java.net.URL JavaDoc;
11 import java.net.URLClassLoader JavaDoc;
12 import java.security.AccessController JavaDoc;
13 import java.security.Permission JavaDoc;
14 import java.security.PrivilegedExceptionAction JavaDoc;
15 import java.util.LinkedList JavaDoc;
16
17 /**
18  * Description of the Class
19  *
20  * @author letiembl
21  * @created 21 mars 2002
22  */

23 public class Main
24 {
25    /**
26     * The main program for the Main class
27     *
28     * @param args The command line arguments
29     * @exception Exception Description of Exception
30     */

31    public static void main(String JavaDoc[] args) throws Exception JavaDoc
32    {
33       File JavaDoc pluginDir = new File JavaDoc("../lib/ext");
34       LinkedList JavaDoc list = new LinkedList JavaDoc();
35       File JavaDoc[] plugins = pluginDir.listFiles();
36       for (int i = 0; i < plugins.length; i++)
37       {
38          System.out.println(plugins[i].toURL());
39          list.add(plugins[i].toURL());
40       }
41       pluginDir = new File JavaDoc("../lib");
42       plugins = pluginDir.listFiles();
43       for (int i = 0; i < plugins.length; i++)
44       {
45          System.out.println(plugins[i].toURL());
46          list.add(plugins[i].toURL());
47       }
48       URL JavaDoc[] pluginURLs = (URL JavaDoc[]) list.toArray(new URL JavaDoc[list.size()]);
49
50       Thread.currentThread().setContextClassLoader(new URLClassLoader JavaDoc(pluginURLs, Thread.currentThread().getContextClassLoader()));
51       System.setSecurityManager(
52          new SecurityManager JavaDoc()
53          {
54             public void checkPermission(Permission JavaDoc p) { }
55
56
57             public void checkPermission(Permission JavaDoc perm, Object JavaDoc context) { }
58          });
59
60       // Create result dir if not exists
61
File JavaDoc resultDir = new File JavaDoc("../report/xml");
62       if (!resultDir.exists())
63       {
64          resultDir.mkdirs();
65       }
66
67       // Launch the GUI Test Suite
68
AccessController.doPrivileged(
69          new PrivilegedExceptionAction JavaDoc()
70          {
71             public Object JavaDoc run()
72                    throws Exception JavaDoc
73             {
74                java.beans.Beans.instantiate(Thread.currentThread().getContextClassLoader(), "net.sourceforge.ejtools.management.test.ManagementTestRunner");
75                return null;
76             }
77          });
78
79    }
80 }
81
82
Popular Tags