1 package test.thread;
2 
3 import org.testng.TestListenerAdapter;
4 import org.testng.TestNG;
5 import org.testng.annotations.Test;
6 
7 import junit.framework.Assert;
8 
9 public class ThreadPoolSizeWithTimeOutTest extends ThreadPoolSizeBase {
10 
11   @Test(invocationCount = 5, threadPoolSize = 3, timeOut = 1000)
f1()12   public void f1() {
13     logThread();
14   }
15 
16   @Test(dependsOnMethods = {"f1"})
verify()17   public void verify() {
18     verifyThreads(3);
19   }
20 
21   @Test
threadPoolAndTimeOutShouldFail()22   public void threadPoolAndTimeOutShouldFail() {
23     TestNG tng = create(ThreadPoolSizeSampleTest.class);
24     TestListenerAdapter tla = new TestListenerAdapter();
25     tng.addListener(tla);
26     tng.run();
27 
28     Assert.assertEquals(0, tla.getPassedTests().size());
29     Assert.assertEquals(1, tla.getFailedTests().size());
30   }
31 }
32