01: /*
02: * (c) Copyright IBM Corp. 2000, 2001.
03: * All Rights Reserved.
04: */
05: package org.eclipse.pde.internal.junit.ui;
06:
07: import org.eclipse.core.runtime.Platform;
08: import org.eclipse.jdt.internal.junit.runner.RemoteTestRunner;
09:
10: /**
11: * Runs JUnit tests contained inside a plugin.
12: */
13: public class RemotePluginTestRunner extends RemoteTestRunner {
14:
15: private String fTestPluginName;
16:
17: /**
18: * The main entry point. Supported arguments in addition
19: * to the ones supported by RemoteTestRunner:
20: * <pre>
21: * -testpluginname: the name of the plugin containing the tests.
22: * </pre
23: * @see RemoteTestRunner
24: */
25:
26: public static void main(String[] args) {
27: RemotePluginTestRunner testRunner = new RemotePluginTestRunner();
28: testRunner.init(args);
29: testRunner.run();
30: }
31:
32: /**
33: * Returns the Plugin class loader of the plugin containing the test.
34: * @see RemotePluginTestRunner#getClassLoader()
35: */
36: protected ClassLoader getClassLoader() {
37: if (Platform.getPluginRegistry().getPluginDescriptor(
38: fTestPluginName) != null)
39: return Platform.getPluginRegistry().getPluginDescriptor(
40: fTestPluginName).getPluginClassLoader();
41: throw new IllegalArgumentException(
42: "No ClassLoader found for testplugin: "
43: + fTestPluginName);
44: }
45:
46: protected void init(String[] args) {
47: defaultInit(args);
48: setTestPluginName(args);
49: }
50:
51: protected void setTestPluginName(String[] args) {
52: for (int i = 0; i < args.length; i++) {
53: if (args[i].toLowerCase().equals("-testpluginname")) {
54: if (i < args.length - 1)
55: fTestPluginName = args[i + 1];
56: return;
57: }
58: }
59: throw new IllegalArgumentException(
60: "Parameter -testpluginname not specified");
61: }
62: }
|