KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > ubik > mcast > EventConsumerTest


1 package org.sapia.ubik.mcast;
2
3 import junit.framework.TestCase;
4
5
6 /**
7  * @author Yanick Duchesne
8  *
9  * <dl>
10  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
11  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
12  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
13  * </dl>
14  */

15 public class EventConsumerTest extends TestCase {
16   public EventConsumerTest(String JavaDoc arg0) {
17     super(arg0);
18   }
19
20   public void testMatchesAll() throws Exception JavaDoc {
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 JavaDoc {
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 JavaDoc {
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 JavaDoc {
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