01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.object;
05:
06: import java.util.HashMap;
07: import java.util.HashSet;
08: import java.util.Map;
09: import java.util.Set;
10:
11: import junit.framework.TestCase;
12:
13: public class ObjectIDTest extends TestCase {
14:
15: public void testIdentity() {
16: int idValue = 1001;
17: ObjectID id = new ObjectID(idValue);
18: ObjectID clone = new ObjectID(idValue);
19:
20: assertNotSame(id, clone);
21: assertEquals(id, clone);
22:
23: Set set = new HashSet();
24: set.add(clone);
25:
26: assertTrue(set.contains(id));
27: set.remove(id);
28: assertEquals(0, set.size());
29:
30: Map map = new HashMap();
31: Object o = new Object();
32: map.put(id, o);
33: assertEquals(o, map.get(clone));
34: }
35: }
|