01: package test.tmp;
02:
03: import java.util.HashSet;
04: import java.util.LinkedHashSet;
05: import java.util.Random;
06: import java.util.Set;
07:
08: import org.testng.Assert;
09: import org.testng.Reporter;
10: import org.testng.annotations.Test;
11:
12: public class AssertEqualsTest {
13:
14: private void log(String s) {
15: System.out.println("[" + Thread.currentThread().getId() + "] "
16: + s);
17: }
18:
19: @Test(threadPoolSize=3,invocationCount=6)
20: public void f1() {
21: log("start");
22: try {
23: int sleepTime = new Random().nextInt(500);
24: Thread.sleep(sleepTime);
25: } catch (Exception e) {
26: log(" *** INTERRUPTED");
27: }
28: log("end");
29: }
30:
31: @Test(threadPoolSize=10,invocationCount=10000)
32: public void verifyMethodIsThreadSafe() {
33: // foo();
34: }
35:
36: @Test(dependsOnMethods="verifyMethodIsThreadSafe")
37: public void verify() {
38: // make sure that nothing was broken
39: }
40:
41: public static void main(String[] args) {
42: Set set1 = new LinkedHashSet();
43: Set set2 = new HashSet();
44:
45: set1.add(new Integer(5));
46: set2.add(new Integer(5));
47:
48: set1.add(new Integer(6));
49: set2.add(new Integer(6));
50:
51: set1.add(new Integer(1));
52: set2.add(new Integer(1));
53:
54: set1.add(new Integer(9));
55: set2.add(new Integer(9));
56:
57: System.out.println("set1 is:" + set1.toString());
58: System.out.println("set2 is:" + set2.toString());
59:
60: System.out.println("is set1 equals set2 :" + set1.equals(set2));
61:
62: try {
63: Assert.assertEquals(set1, set2,
64: "set1 must equals with set2");
65: } catch (Exception ex) {
66: ex.printStackTrace();
67: }
68: }
69: }
|