| 1 package org.sapia.ubik.mcast; 2 3 import junit.framework.TestCase; 4 5 6 15 public class EventConsumerTest extends TestCase { 16 public EventConsumerTest(String arg0) { 17 super(arg0); 18 } 19 20 public void testMatchesAll() throws Exception { 21 EventConsumer cons = new EventConsumer("123", "default"); 22 DomainName other = DomainName.parse("local"); 23 DomainName thisDomain = DomainName.parse("default"); 24 super.assertTrue(!cons.matchesAll(other, "456")); 25 super.assertTrue(!cons.matchesAll(thisDomain, "456")); 26 super.assertTrue(cons.matchesAll(null, "456")); 27 super.assertTrue(!cons.matchesAll(null, "123")); 28 } 29 30 public void testMatchesThis() throws Exception { 31 EventConsumer cons = new EventConsumer("123", "default"); 32 DomainName other = DomainName.parse("local"); 33 DomainName thisDomain = DomainName.parse("default"); 34 super.assertTrue(!cons.matchesThis(other, "456")); 35 super.assertTrue(cons.matchesThis(thisDomain, "456")); 36 super.assertTrue(!cons.matchesThis(thisDomain, "123")); 37 } 38 39 public void testUnregisterAsyncListener() throws Exception { 40 EventConsumer cons = new EventConsumer("node", "domain"); 41 TestEventListener listener = new TestEventListener(); 42 cons.registerAsyncListener("test", listener); 43 cons.unregisterListener((AsyncEventListener) listener); 44 super.assertTrue(!cons.containsAsyncListener(listener)); 45 super.assertEquals(0, cons.getCount()); 46 } 47 48 public void testUnregisterSyncListener() throws Exception { 49 EventConsumer cons = new EventConsumer("node", "domain"); 50 SyncEventListener listener = new TestEventListener(); 51 cons.registerSyncListener("test", listener); 52 cons.unregisterListener(listener); 53 super.assertEquals(0, cons.getCount()); 54 } 55 } 56 | Popular Tags |