01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.objectserver.tx;
06:
07: import com.tc.net.groups.ClientID;
08: import com.tc.net.protocol.tcm.ChannelID;
09: import com.tc.object.tx.ServerTransactionID;
10: import com.tc.object.tx.TransactionID;
11: import com.tc.test.TCTestCase;
12:
13: import java.util.HashMap;
14: import java.util.Map;
15:
16: public class ServerTransactionIDTest extends TCTestCase {
17:
18: private ServerTransactionID get(int channel, int txn) {
19: return new ServerTransactionID(new ClientID(new ChannelID(
20: channel)), new TransactionID(txn));
21: }
22:
23: public void test() {
24: ServerTransactionID id1 = get(1, 1);
25: ServerTransactionID id2 = get(2, 2);
26: ServerTransactionID idNull = ServerTransactionID.NULL_ID;
27:
28: assertEquals(id1, get(1, 1));
29: assertEquals(id2, get(2, 2));
30: assertEquals(get(1, 1).hashCode(), id1.hashCode());
31: assertEquals(get(2, 2).hashCode(), id2.hashCode());
32:
33: assertNotEquals(idNull, id1);
34: assertNotEquals(idNull, id2);
35:
36: Map map = new HashMap();
37: assertEquals(0, map.size());
38: map.put(id1, "one");
39: assertEquals(1, map.size());
40: map.put(id2, "two");
41: assertEquals(2, map.size());
42:
43: assertEquals("one", map.remove(id1));
44: assertEquals("two", map.remove(id2));
45: assertEquals(0, map.size());
46: }
47:
48: }
|