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 = Long.valueOf(System.currentTimeMillis());
  }

  @Test
  public void timeOutInParallel() {
    addClass("test.timeout.TimeOutSampleTest");
    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 timeOutInNonParallel() {
    addClass("test.timeout.TimeOutSampleTest");
    run();
    String[] passed = {
        "timeoutShouldPass",
      };
      String[] failed = {
          "timeoutShouldFailByException", "timeoutShouldFailByTimeOut"
      };
      verifyTests("Passed", passed, getPassedTests());
      verifyTests("Failed", failed, getFailedTests());
  }

  @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;
  }


}

@@ -307,46 +307,56 @@
 %0A%0A  
-@Test%0A  public void timeOutInP
+private void privateTimeOutTest(boolean p
 arallel
-(
 ) %7B%0A
@@ -399,24 +399,46 @@
 mpleTest%22);%0A
+    if (parallel) %7B%0A  
     setParal
@@ -469,16 +469,22 @@
 THODS);%0A
+    %7D%0A
     run(
@@ -853,11 +853,8 @@
 utIn
-Non
 Para
@@ -870,338 +870,114 @@
     
-addClass(%22test.timeout.TimeOutSampleTest%22);%0A    run();%0A    String%5B%5D passed = %7B%0A        %22
+privateTimeOutTest(true);%0A  %7D%0A%0A  @Test%0A  public void 
 time
-outShouldPass%22,%0A      %7D;%0A      String%5B%5D failed = %7B%0A          %22timeoutShouldFailByException%22, %22timeoutShouldFailByTimeOut%22%0A      %7D;%0A      verifyTests(%22Passed%22, passed, getPassedTests());%0A      verifyTests(%22Failed%22, failed, getFailedTests()
+OutInNonParallel() %7B%0A    privateTimeOutTest(false
 );%0A 

Test refactoring.