KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > junit > runtime > LegacyRemotePluginTestRunner


1 /*******************************************************************************
2  * Copyright (c) 2003, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.junit.runtime;
12
13 import java.util.Locale JavaDoc;
14
15 import org.eclipse.core.runtime.Platform;
16
17 import org.eclipse.jdt.internal.junit.runner.RemoteTestRunner;
18
19 /**
20  * Runs JUnit tests contained inside a plugin.
21  */

22 public class LegacyRemotePluginTestRunner extends RemoteTestRunner {
23
24     private String JavaDoc fTestPluginName;
25     
26     /**
27      * The main entry point. Supported arguments in addition
28      * to the ones supported by RemoteTestRunner:
29      * <pre>
30      * -testpluginname: the name of the plugin containing the tests.
31       * </pre>
32      * @see RemoteTestRunner
33      */

34
35     public static void main(String JavaDoc[] args) {
36         LegacyRemotePluginTestRunner testRunner= new LegacyRemotePluginTestRunner();
37         testRunner.init(args);
38         testRunner.run();
39     }
40     
41     /**
42      * Returns the Plugin class loader of the plugin containing the test.
43      * @see RemotePluginTestRunner#getClassLoader()
44      */

45     protected ClassLoader JavaDoc getClassLoader() {
46         if (Platform.getPluginRegistry().getPluginDescriptor(fTestPluginName) != null)
47             return Platform
48                 .getPluginRegistry()
49                 .getPluginDescriptor(fTestPluginName)
50                 .getPluginClassLoader();
51         throw new IllegalArgumentException JavaDoc("No Classloader found for plug-in " + fTestPluginName); //$NON-NLS-1$
52
}
53
54     protected void init(String JavaDoc[] args) {
55         defaultInit(args);
56         setTestPluginName(args);
57     }
58
59     protected void setTestPluginName(String JavaDoc[] args) {
60         for (int i = 0; i < args.length; i++) {
61             if (args[i].toLowerCase(Locale.ENGLISH).equals("-testpluginname")) { //$NON-NLS-1$
62
if (i < args.length - 1)
63                     fTestPluginName = args[i + 1];
64                 return;
65             }
66         }
67         throw new IllegalArgumentException JavaDoc("Parameter -testpluginnname not specified."); //$NON-NLS-1$
68
}
69 }
70
Popular Tags