package test.timeout;

import org.testng.annotations.Test;
import org.testng.xml.XmlSuite;

import test.BaseTest;


/**
 * This class
 *
 * @author cbeust
 */
public class TimeOutTest extends BaseTest {
  private Long m_id;

  public TimeOutTest() {
    m_id = System.currentTimeMillis();
  }

  private void privateTimeOutTest(boolean parallel) {
    addClass("test.timeout.TimeOutSampleTest");
    if (parallel) {
      setParallel(XmlSuite.PARALLEL_METHODS);
    }
    run();
    String[] passed = {
        "timeoutShouldPass",
      };
      String[] failed = {
        "timeoutShouldFailByException", "timeoutShouldFailByTimeOut"
      };

//      dumpResults("Passed", getPassedTests());

      verifyTests("Passed", passed, getPassedTests());
      verifyTests("Failed", failed, getFailedTests());
  }

  @Test
  public void timeOutInParallel() {
    privateTimeOutTest(true);
  }

  @Test
  public void timeOutInNonParallel() {
    privateTimeOutTest(false);
  }

  @Test
  public void verifyInvocationTimeOut() {
    addClass("test.timeout.InvocationTimeOutSampleTest");
    run();
    String[] passed = {
        "shouldPass",
      };
      String[] failed = {
          "shouldFail"
      };
      verifyTests("Passed", passed, getPassedTests());
      verifyTests("Failed", failed, getFailedTests());
  }

  @Override
  public Long getId() {
    return m_id;
  }


}

@@ -16,16 +16,60 @@
 meout;%0A%0A
+import org.testng.annotations.DataProvider;%0A
 import o
@@ -129,16 +129,44 @@
 Suite;%0A%0A
+import java.util.Iterator;%0A%0A
 import t
@@ -397,15 +397,14 @@
 est(
-boolean
+String
  par
@@ -468,32 +468,40 @@
     if (parallel
+ != null
 ) %7B%0A      setPar
@@ -510,33 +510,16 @@
 lel(
-XmlSuite.PARALLEL_METHODS
+parallel
 );%0A 
@@ -861,36 +861,487 @@
 sts());%0A  %7D%0A%0A  @
-Test
+DataProvider(name = %22parallelModes%22)%0A  public Iterator%3CObject%5B%5D%3E createData() %7B%0A    final Iterator%3CString%3E parallelModes = XmlSuite.PARALLEL_MODES.iterator();%0A    return new Iterator%3CObject%5B%5D%3E() %7B%0A      @Override%0A      public boolean hasNext() %7B%0A        return parallelModes.hasNext();%0A      %7D%0A%0A      @Override%0A      public Object%5B%5D next() %7B%0A        return new Object%5B%5D%7B parallelModes.next() %7D;%0A      %7D%0A    %7D;%0A  %7D%0A%0A%0A  @Test(dataProvider = %22parallelModes%22)
 %0A  public void t
@@ -1349,32 +1349,51 @@
 meOutInParallel(
+String parallelMode
 ) %7B%0A    privateT
@@ -1407,11 +1407,19 @@
 est(
-tru
+parallelMod
 e);%0A
@@ -1497,13 +1497,12 @@
 est(
-false
+null
 );%0A 

Test each parallel mode