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