1 package test.ant; 2 3 import org.testng.Assert; 4 import org.testng.annotations.AfterClass; 5 import org.testng.annotations.BeforeClass; 6 import org.testng.annotations.Test; 7 8 import java.util.Collections; 9 import java.util.HashSet; 10 import java.util.Set; 11 /** 12 * Tests that more than one thread is used for running tests 13 * @author micheb10 2 Oct 2006 14 * 15 */ 16 public class MultipleThreadTest { 17 public static Set<Thread> _threads; 18 19 @BeforeClass prepareHashSet()20 public void prepareHashSet() { 21 _threads=Collections.synchronizedSet(new HashSet<Thread>()); 22 } 23 24 @Test recordThread00()25 public void recordThread00() { 26 _threads.add(Thread.currentThread()); 27 } 28 29 @Test recordThread01()30 public void recordThread01() { 31 _threads.add(Thread.currentThread()); 32 } 33 34 @Test recordThread02()35 public void recordThread02() { 36 _threads.add(Thread.currentThread()); 37 } 38 39 @Test recordThread03()40 public void recordThread03() { 41 _threads.add(Thread.currentThread()); 42 } 43 44 @Test recordThread04()45 public void recordThread04() { 46 _threads.add(Thread.currentThread()); 47 } 48 49 @Test recordThread05()50 public void recordThread05() { 51 _threads.add(Thread.currentThread()); 52 } 53 54 @Test recordThread06()55 public void recordThread06() { 56 _threads.add(Thread.currentThread()); 57 } 58 59 @Test recordThread07()60 public void recordThread07() { 61 _threads.add(Thread.currentThread()); 62 } 63 64 @Test recordThread08()65 public void recordThread08() { 66 _threads.add(Thread.currentThread()); 67 } 68 69 @Test recordThread09()70 public void recordThread09() { 71 _threads.add(Thread.currentThread()); 72 } 73 74 @Test recordThread10()75 public void recordThread10() { 76 _threads.add(Thread.currentThread()); 77 } 78 79 @Test recordThread11()80 public void recordThread11() { 81 _threads.add(Thread.currentThread()); 82 } 83 84 @Test recordThread12()85 public void recordThread12() { 86 _threads.add(Thread.currentThread()); 87 } 88 89 @Test recordThread13()90 public void recordThread13() { 91 _threads.add(Thread.currentThread()); 92 } 93 94 @Test recordThread14()95 public void recordThread14() { 96 _threads.add(Thread.currentThread()); 97 } 98 99 @Test recordThread15()100 public void recordThread15() { 101 _threads.add(Thread.currentThread()); 102 } 103 104 @Test recordThread16()105 public void recordThread16() { 106 _threads.add(Thread.currentThread()); 107 } 108 109 @Test recordThread17()110 public void recordThread17() { 111 _threads.add(Thread.currentThread()); 112 } 113 114 @Test recordThread18()115 public void recordThread18() { 116 _threads.add(Thread.currentThread()); 117 } 118 119 @Test recordThread19()120 public void recordThread19() { 121 _threads.add(Thread.currentThread()); 122 } 123 124 @AfterClass confirmMultipleThreads()125 public void confirmMultipleThreads() { 126 Assert.assertTrue(_threads.size()>1,"More than one thread should have been used for running the tests - "+_threads.size()+" was used"); 127 } 128 } 129