1 4 package com.tc.objectserver.tx; 5 6 import com.tc.net.protocol.tcm.ChannelID; 7 import com.tc.object.tx.ServerTransactionID; 8 import com.tc.object.tx.TransactionID; 9 import com.tc.test.TCTestCase; 10 11 import java.util.HashMap ; 12 import java.util.Map ; 13 14 15 public class ServerTransactionIDTest extends TCTestCase { 16 17 private ServerTransactionID get(int channel, int txn) { 18 return new ServerTransactionID(new ChannelID(channel), new TransactionID(txn)); 19 } 20 21 public void test() { 22 ServerTransactionID id1 = get(1, 1); 23 ServerTransactionID id2 = get(2, 2); 24 ServerTransactionID idNull = ServerTransactionID.NULL_ID; 25 26 assertEquals(id1, get(1, 1)); 27 assertEquals(id2, get(2, 2)); 28 assertEquals(get(1, 1).hashCode(), id1.hashCode()); 29 assertEquals(get(2, 2).hashCode(), id2.hashCode()); 30 31 assertNotEquals(idNull, id1); 32 assertNotEquals(idNull, id2); 33 34 35 Map map = new HashMap (); 36 assertEquals(0, map.size()); 37 map.put(id1, "one"); 38 assertEquals(1, map.size()); 39 map.put(id2, "two"); 40 assertEquals(2, map.size()); 41 42 assertEquals("one", map.remove(id1)); 43 assertEquals("two", map.remove(id2)); 44 assertEquals(0, map.size()); 45 } 46 47 48 } 49 | Popular Tags |