Issue 5:
Add Master-Worker adapter interfaces.
diff --git a/src/main/org/testng/remote/adapter/IMasterAdapter.java b/src/main/org/testng/remote/adapter/IMasterAdapter.java
new file mode 100644
index 0000000..660bbd0
--- /dev/null
+++ b/src/main/org/testng/remote/adapter/IMasterAdapter.java
@@ -0,0 +1,39 @@
+package org.testng.remote.adapter;
+
+import java.io.IOException;
+import java.util.Properties;
+
+import org.testng.xml.XmlSuite;
+
+/**
+ * This interface should be implemented by the Master-Slave transport adapter.
+ * This interface is used by the Master to push suites and get results.
+ *
+ * @author Guy Korland
+ * @date April 9, 2007
+ * @see IWorkerApadter
+ */
+public interface IMasterAdapter
+{
+ /**
+ * Initializes the Master adapter.
+ * @param properties holds the properties loaded from the remote.properties file.
+ */
+ void init( Properties prop);
+
+ /**
+ * Run a suite remotely.
+ * @param suite the suite to send.
+ * @param listener the corresponded listener, should be called when result is ready.
+ * @throws IOException might be thrown on error
+ */
+ void runSuitesRemotely( XmlSuite suite, RemoteResultListener listener) throws IOException;
+
+ /**
+ * A blocking wait for the remote results to return.
+ *
+ * @param timeout the maximum time to wait for all the suites to return a result.
+ * @throws InterruptedException
+ */
+ public void awaitTermination(long timeout) throws InterruptedException;
+}
diff --git a/src/main/org/testng/remote/adapter/IWorkerApadter.java b/src/main/org/testng/remote/adapter/IWorkerApadter.java
new file mode 100644
index 0000000..bdcb25d
--- /dev/null
+++ b/src/main/org/testng/remote/adapter/IWorkerApadter.java
@@ -0,0 +1,37 @@
+package org.testng.remote.adapter;
+
+import java.util.Properties;
+
+import org.testng.ISuite;
+import org.testng.xml.XmlSuite;
+
+/**
+ * This interface should be implemented by the Master-Slave transport adapter.
+ * This interface is used by the Slave to pull suites and return results.
+ *
+ * @author Guy Korland
+ * @date April 9, 2007
+ * @see IMasterAdapter
+ */
+public interface IWorkerApadter
+{
+ /**
+ * Initializes the worker adapter.
+ * @param properties holds the properties loaded from the remote.properties file.
+ */
+ void init( Properties properties);
+
+ /**
+ * A blocking call to get the next Suite to test.
+ * @param timeout the maximum time to wait for the next suite.
+ * @return the next suite avaliable or <code>null</code> if the timeout has reached.
+ * @throws InterruptedException
+ */
+ XmlSuite getSuite( long timeout) throws InterruptedException;
+
+ /**
+ * Return a suite result.
+ * @param result the result to return
+ */
+ void returnResult( ISuite result);
+}
diff --git a/src/main/org/testng/remote/adapter/RemoteResultListener.java b/src/main/org/testng/remote/adapter/RemoteResultListener.java
new file mode 100644
index 0000000..597f23e
--- /dev/null
+++ b/src/main/org/testng/remote/adapter/RemoteResultListener.java
@@ -0,0 +1,63 @@
+/*
+ * @(#)ResultListener.java Apr 9, 2007
+ *
+ * Copyright 2007 GigaSpaces Technologies Inc.
+ */
+
+package org.testng.remote.adapter;
+
+import java.util.Map;
+
+import org.testng.ISuiteResult;
+import org.testng.ITestContext;
+import org.testng.SuiteRunner;
+import org.testng.reporters.TestHTMLReporter;
+
+/**
+ * This listener is called by the {@link IWorkerApadter} implementation when a remote test result is ready.
+ *
+ * @author Guy Korland
+ * @date April 9, 2007
+ * @see IWorkerApadter
+ */
+public class RemoteResultListener
+{
+ /**
+ * Holds the corresponded {@link SuiteRunner} for the processed {@link org.testng.xml.XmlSuite}.
+ */
+ final private SuiteRunner _runner;
+
+ /**
+ * Creates a listener for an {@link org.testng.xml.XmlSuite} result.
+ * @param runner the corresponded {@link SuiteRunner}
+ */
+ public RemoteResultListener( SuiteRunner runner)
+ {
+ _runner = runner;
+ }
+
+ /**
+ * Should called by the {@link IWorkerApadter} implementation when a remote suite result is ready.
+ * @param remoteSuiteRunner remote result.
+ */
+ public void onResult( SuiteRunner remoteSuiteRunner)
+ {
+ _runner.setHost(remoteSuiteRunner.getHost());
+ Map<String, ISuiteResult> tmpResults = remoteSuiteRunner.getResults();
+ Map<String, ISuiteResult> suiteResults = _runner.getResults();
+ for (String tests : tmpResults.keySet())
+ {
+ ISuiteResult suiteResult = tmpResults.get(tests);
+ suiteResults.put(tests, suiteResult);
+ ITestContext tc = suiteResult.getTestContext();
+ TestHTMLReporter.generateLog(tc, remoteSuiteRunner.getHost(),
+ _runner.getOutputDirectory(),
+ tc.getFailedConfigurations().getAllResults(),
+ tc.getSkippedConfigurations().getAllResults(),
+ tc.getPassedTests().getAllResults(),
+ tc.getFailedTests().getAllResults(),
+ tc.getSkippedTests().getAllResults(),
+ tc.getFailedButWithinSuccessPercentageTests().getAllResults());
+ }
+ }
+}