| 1 |  |  | 
| 2 |  |  | 
| 3 |  |  | 
| 4 |  |  | 
| 5 |  |  | 
| 6 |  |  | 
| 7 |  | package jtr.remote.test.impl; | 
| 8 |  |  | 
| 9 |  | import java.rmi.RemoteException; | 
| 10 |  | import java.rmi.server.UnicastRemoteObject; | 
| 11 |  | import jtr.config.TestConfig; | 
| 12 |  | import jtr.remote.test.*; | 
| 13 |  | import jtr.remote.test.TestGatewayService; | 
| 14 |  | import jtr.test.SystemProperties; | 
| 15 |  | import jtr.test.TestFailedException; | 
| 16 |  | import jtr.test.TestOutcomeTable; | 
| 17 |  | import org.apache.log4j.Logger; | 
| 18 |  |  | 
| 19 |  |  | 
| 20 |  |  | 
| 21 |  |  | 
| 22 |  |  | 
| 23 |  |  | 
| 24 |  |  | 
| 25 |  |  | 
| 26 |  | public class TestGateway extends UnicastRemoteObject implements TestGatewayService { | 
| 27 |  |  | 
| 28 |  |  | 
| 29 |  |  | 
| 30 |  |  | 
| 31 |  |  | 
| 32 | 1 | public TestGateway() throws RemoteException { | 
| 33 | 1 | super(new Integer(System.getProperty(SystemProperties.TEST_GW_SERVICE_PORT_PROPERTY,SystemProperties.TEST_GW_SERVICE_PORT.toString())).intValue()); | 
| 34 | 1 | logger.debug("Using "+System.getProperty(SystemProperties.TEST_GW_SERVICE_PORT_PROPERTY)+"=" | 
| 35 |  | +System.getProperty(SystemProperties.TEST_GW_SERVICE_PORT_PROPERTY,SystemProperties.TEST_GW_SERVICE_PORT.toString())); | 
| 36 |  | } | 
| 37 |  |  | 
| 38 | 1 | public void launchTest(TestConfig tc, final NodeInfo serverCL, final NodeInfo testOutcomeCollector) throws RemoteException { | 
| 39 | 1 | logger.info("Received test configuration from node "+serverCL.getHost()); | 
| 40 |  |  | 
| 41 | 1 | RemoteTestRunManagerStarter testStarter = new RemoteTestRunManagerStarter() { | 
| 42 | 1 | public void init(TestConfig tc) { | 
| 43 | 1 | testConfig = tc; | 
| 44 |  | } | 
| 45 |  |  | 
| 46 | 1 | public void run() { | 
| 47 | 1 | RemoteTestRunManager rtrm = new RemoteTestRunManager(testConfig,serverCL,testOutcomeCollector); | 
| 48 | 1 | try { | 
| 49 | 1 | rtrm.startTest(); | 
| 50 |  | } catch (TestFailedException ex) { | 
| 51 | 0 | logger.error("Caught an exception during test execution, throwing it back to the active node "+serverCL.getHost(),ex); | 
| 52 |  | } | 
| 53 |  | } | 
| 54 |  |  | 
| 55 | 0 | public void setOutcome(TestOutcomeTable testOutcomeTable) { | 
| 56 | 0 | outcome = testOutcomeTable; | 
| 57 |  | } | 
| 58 |  |  | 
| 59 |  | private TestConfig testConfig; | 
| 60 |  | private TestOutcomeTable outcome; | 
| 61 |  | private Thread suspendedThread; | 
| 62 |  | }; | 
| 63 |  |  | 
| 64 | 1 | testStarter.init(tc); | 
| 65 | 1 | new Thread(testStarter,"JTR-RemoteTestRunManager-"+System.nanoTime()).start(); | 
| 66 |  | } | 
| 67 |  |  | 
| 68 |  | private Logger logger = Logger.getLogger(TestGateway.class); | 
| 69 |  |  | 
| 70 |  |  | 
| 71 |  |  | 
| 72 |  |  | 
| 73 |  |  | 
| 74 |  |  | 
| 75 |  |  | 
| 76 |  |  | 
| 77 |  |  | 
| 78 |  |  | 
| 79 |  |  | 
| 80 |  |  | 
| 81 |  |  | 
| 82 |  |  | 
| 83 |  | interface RemoteTestRunManagerStarter extends Runnable { | 
| 84 |  |  | 
| 85 |  |  | 
| 86 |  |  | 
| 87 |  |  | 
| 88 |  |  | 
| 89 |  | public void init(TestConfig testConfig); | 
| 90 |  |  | 
| 91 |  |  | 
| 92 |  |  | 
| 93 |  |  | 
| 94 |  |  | 
| 95 |  | public void setOutcome(TestOutcomeTable testOutcomeTable); | 
| 96 |  | } | 
| 97 |  | } |