1 /* 2 * @(#)ResultListener.java Apr 9, 2007 3 * 4 * Copyright 2007 GigaSpaces Technologies Inc. 5 */ 6 7 package org.testng.remote.adapter; 8 9 import java.util.Map; 10 11 import org.testng.ISuite; 12 import org.testng.ISuiteResult; 13 import org.testng.ITestContext; 14 import org.testng.SuiteRunner; 15 import org.testng.reporters.TestHTMLReporter; 16 17 /** 18 * This listener is called by the {@link IWorkerAdapter} implementation when a remote test result is ready. 19 * 20 * @author Guy Korland 21 * @since April 9, 2007 22 * @see IWorkerAdapter 23 */ 24 public class RemoteResultListener 25 { 26 /** 27 * Holds the corresponded {@link SuiteRunner} for the processed {@link org.testng.xml.XmlSuite}. 28 */ 29 final private SuiteRunner m_runner; 30 31 /** 32 * Creates a listener for an {@link org.testng.xml.XmlSuite} result. 33 * @param runner the corresponded {@link SuiteRunner} 34 */ 35 public RemoteResultListener( SuiteRunner runner) 36 { 37 m_runner = runner; 38 } 39 40 /** 41 * Should called by the {@link IWorkerAdapter} implementation when a remote suite result is ready. 42 * @param remoteSuiteRunner remote result. 43 */ 44 public void onResult( ISuite remoteSuiteRunner) 45 { 46 m_runner.setHost(remoteSuiteRunner.getHost()); 47 Map<String, ISuiteResult> tmpResults = remoteSuiteRunner.getResults(); 48 Map<String, ISuiteResult> suiteResults = m_runner.getResults(); 49 for (Map.Entry<String, ISuiteResult> entry : tmpResults.entrySet()) 50 { 51 ISuiteResult suiteResult = entry.getValue(); 52 suiteResults.put(entry.getKey(), suiteResult); 53 ITestContext tc = suiteResult.getTestContext(); 54 TestHTMLReporter.generateLog(tc, remoteSuiteRunner.getHost(), 55 m_runner.getOutputDirectory(), 56 tc.getFailedConfigurations().getAllResults(), 57 tc.getSkippedConfigurations().getAllResults(), 58 tc.getPassedTests().getAllResults(), 59 tc.getFailedTests().getAllResults(), 60 tc.getSkippedTests().getAllResults(), 61 tc.getFailedButWithinSuccessPercentageTests().getAllResults()); 62 } 63 } 64 } 65