1 /*
2 * CopyrightPlugin (c) 2004 Your Corporation. All Rights Reserved.
3 */
4 package remoteTester.framework;
5
6 import junit.framework.TestCase;
7 import junit.framework.TestResult;
8 import remoteTester.runner.TestRunner;
9
10 import java.rmi.RemoteException;
11
12 /***
13 * Created by nicolas FRANK
14 * <p/>
15 * Date: 24 févr. 2004
16 * Time: 19:36:06
17 */
18 public class RemoteTestCase extends TestCase {
19
20 /***
21 * tells if the test is currently executed on server or client side
22 */
23 private static boolean _isRemote;
24
25 public RemoteTestCase(String name) {
26 super(name);
27 }
28
29 public RemoteTestCase() {
30 }
31
32 public static void setIsRemote(boolean isRemote) {
33 _isRemote = isRemote;
34 }
35
36 public Class[] addHelpers() {
37 return null;
38 }
39
40 /***
41 * Creates a default Serializable TestResult object
42 *
43 * @see TestResult
44 */
45 protected TestResult createResult() {
46 return new TestResultSerializable();
47 }
48
49 /***
50 * overwrite runBare so it can behave differenctly on client and server side.
51 * on client side : call the remoteTesterRunner and execute the test on serverside
52 * on Serverside : just call super.runBare().
53 *
54 * @throws Throwable
55 */
56 public void runBare() throws Throwable {
57 if (_isRemote) {
58 super.runBare();
59 } else {
60 try {
61 TestResultSerializable testResultSerializable = TestRunner.uploadAndRunWithResult(getClass(), addHelpers(), getName());
62 System.out.println(testResultSerializable.getOutput());
63 } catch (Throwable e) {
64 while (e instanceof RemoteException) {
65 e = ((RemoteException) e).getCause();
66 }
67
68 throw e;
69 }
70 }
71 }
72
73 }
This page was automatically generated by Maven