1 5 package com.tc.objectserver.lockmanager.api; 6 7 import com.tc.net.protocol.tcm.ChannelID; 8 import com.tc.object.lockmanager.api.LockContext; 9 import com.tc.object.lockmanager.api.LockID; 10 import com.tc.object.lockmanager.api.ThreadID; 11 12 import java.util.HashSet ; 13 import java.util.Set ; 14 15 import junit.framework.TestCase; 16 17 public class NotifiedWaitersTest extends TestCase { 18 19 public void testBasics() throws Exception { 20 ChannelID channel1 = new ChannelID(1); 21 ChannelID channel2 = new ChannelID(2); 22 23 Set forChannel1 = new HashSet (); 24 Set forChannel2 = new HashSet (); 25 26 LockID lockID = new LockID("me"); 27 ThreadID txID1 = new ThreadID(1); 28 ThreadID txID2 = new ThreadID(2); 29 ThreadID txID3 = new ThreadID(3); 30 31 NotifiedWaiters ns = new NotifiedWaiters(); 32 33 LockContext lr1 = new LockContext(lockID, channel1, txID1, 0); 34 forChannel1.add(lr1); 35 ns.addNotification(lr1); 36 37 LockContext lr2 = new LockContext(lockID, channel1, txID2, 0); 38 forChannel1.add(lr2); 39 ns.addNotification(lr2); 40 41 LockContext lr3 = new LockContext(lockID, channel2, txID3, 0); 42 forChannel2.add(lr3); 43 ns.addNotification(lr3); 44 45 assertEquals(forChannel1, ns.getNotifiedFor(channel1)); 46 assertEquals(forChannel2, ns.getNotifiedFor(channel2)); 47 48 ns = new NotifiedWaiters(); 49 assertTrue(ns.isEmpty()); 50 ns.getNotifiedFor(new ChannelID(1)); 51 assertTrue(ns.isEmpty()); 52 } 53 54 } 55 | Popular Tags |