01: package test.thread;
02:
03: import java.util.HashMap;
04: import java.util.Map;
05:
06: import org.testng.Assert;
07:
08: public class ThreadPoolSizeTest {
09: private static Map m_threadIds;
10:
11: /**
12: * @testng.before-class
13: */
14: public void setUp() {
15: ppp("INIT THREAD IDS");
16: m_threadIds = new HashMap();
17: }
18:
19: /**
20: * @testng.test invocationCount = "10" threadPoolSize = "3"
21: */
22: public void f1() {
23: Long n = new Long(Thread.currentThread().hashCode());
24: ppp("THREAD: " + n + " " + hashCode());
25: m_threadIds.put(n, n);
26: }
27:
28: /**
29: * @testng.test dependsOnMethods = "f1"
30: */
31: public void verify() {
32: int expected = 3;
33: Assert.assertEquals(m_threadIds.size(), expected,
34: "Should have run on " + expected
35: + " threads but ran on " + m_threadIds.size());
36: }
37:
38: private static void ppp(String s) {
39: if (false) {
40: System.out.println("[ThreadPoolSizeTest] " + s);
41: }
42: }
43: }
|