Source code: org/eclipse/pde/internal/junit/runtime/RemotePluginTestRunner.java
1 /*
2 * (c) Copyright IBM Corp. 2000, 2001.
3 * All Rights Reserved.
4 */
5 package org.eclipse.pde.internal.junit.runtime;
6
7 import org.eclipse.core.runtime.Platform;
8
9 import org.eclipse.jdt.internal.junit.runner.RemoteTestRunner;
10
11 /**
12 * Runs JUnit tests contained inside a plugin.
13 */
14 public class RemotePluginTestRunner extends RemoteTestRunner {
15
16 private String fTestPluginName;
17
18 /**
19 * The main entry point. Supported arguments in addition
20 * to the ones supported by RemoteTestRunner:
21 * <pre>
22 * -testpluginname: the name of the plugin containing the tests.
23 * </pre>
24 * @see RemoteTestRunner
25 */
26
27 public static void main(String[] args) {
28 RemotePluginTestRunner testRunner= new RemotePluginTestRunner();
29 testRunner.init(args);
30 testRunner.run();
31 }
32
33 /**
34 * Returns the Plugin class loader of the plugin containing the test.
35 * @see RemotePluginTestRunner#getClassLoader()
36 */
37 protected ClassLoader getClassLoader() {
38 if (Platform.getPluginRegistry().getPluginDescriptor(fTestPluginName) != null)
39 return Platform
40 .getPluginRegistry()
41 .getPluginDescriptor(fTestPluginName)
42 .getPluginClassLoader();
43 throw new IllegalArgumentException(
44 PdeJUnitPlugin.getResourceString("RemotePluginTestRunner.noClassloader") //$NON-NLS-1$
45 + " " //$NON-NLS-1$
46 + fTestPluginName);
47 }
48
49 protected void init(String[] args) {
50 defaultInit(args);
51 setTestPluginName(args);
52 }
53
54 protected void setTestPluginName(String[] args) {
55 for (int i = 0; i < args.length; i++) {
56 if (args[i].toLowerCase().equals("-testpluginname")) { //$NON-NLS-1$
57 if (i < args.length - 1)
58 fTestPluginName = args[i + 1];
59 return;
60 }
61 }
62 throw new IllegalArgumentException(
63 PdeJUnitPlugin.getFormattedMessage(
64 "RemotePluginTestRunner.noParam", //$NON-NLS-1$
65 "-testpluginname")); //$NON-NLS-1$
66 }
67 }