01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.object.dmi;
06:
07: import java.util.HashSet;
08: import java.util.Set;
09:
10: import junit.framework.TestCase;
11:
12: public class DmiClassSpecTest extends TestCase {
13:
14: private DmiClassSpec dcsA1;
15: private DmiClassSpec dcsA2;
16: private DmiClassSpec dcsB1;
17: private DmiClassSpec dcsB2;
18:
19: public final void setUp() {
20: final String s1 = "s1";
21: final String s2 = "s2";
22: dcsA1 = new DmiClassSpec(s1, s1);
23: dcsA2 = new DmiClassSpec(s1, s1);
24: dcsB1 = new DmiClassSpec(s1, s2);
25: dcsB2 = new DmiClassSpec(s2, s1);
26: }
27:
28: public void testHashCode() {
29: final int hc = dcsA1.hashCode();
30: assertTrue(hc == dcsA2.hashCode());
31: assertFalse(hc == dcsB1.hashCode());
32: assertFalse(hc == dcsB2.hashCode());
33: }
34:
35: public void testEqualsObject() {
36: assertTrue(dcsA1.equals(dcsA2));
37: assertFalse(dcsA1.equals(dcsB1));
38: assertFalse(dcsA1.equals(dcsB2));
39: }
40:
41: public void testInSet() {
42: final Set set = new HashSet();
43: set.add(dcsA1);
44: set.add(dcsA2);
45: set.add(dcsB1);
46: set.add(dcsB2);
47: assertTrue(set.size() == 3);
48: }
49:
50: }
|