KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > ubik > rmi > interceptor > SingleDispatcherTest


1 package org.sapia.ubik.rmi.interceptor;
2
3 import junit.framework.*;
4
5
6 /**
7  * @author Yanick Duchesne
8  * <dl>
9  * <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>
10  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
11  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
12  * </dl>
13  */

14 public class SingleDispatcherTest extends TestCase {
15   /**
16    * Constructor for SingleDispatcherTest.
17    * @param arg0
18    */

19   public SingleDispatcherTest(String JavaDoc arg0) {
20     super(arg0);
21   }
22
23   public void testRegister() throws Exception JavaDoc {
24     SingleDispatcher d = new SingleDispatcher();
25     TestInterceptor t = new TestInterceptor();
26     d.registerInterceptor(TestEvent.class, t);
27   }
28
29   public void testDuplicateRegister() throws Exception JavaDoc {
30     SingleDispatcher d = new SingleDispatcher();
31     TestInterceptor t1 = new TestInterceptor();
32     TestInterceptor t2 = new TestInterceptor();
33     d.registerInterceptor(TestEvent.class, t1);
34
35     try {
36       d.registerInterceptor(TestEvent.class, t2);
37       throw new Exception JavaDoc("duplicate registration not signaled");
38     } catch (InvalidInterceptorException e) {
39       // ok
40
}
41   }
42
43   public void testDispatch() throws Exception JavaDoc {
44     SingleDispatcher d = new SingleDispatcher();
45     TestInterceptor t = new TestInterceptor();
46     d.registerInterceptor(TestEvent.class, t);
47     d.dispatch(new TestEvent());
48     super.assertEquals(1, t.count);
49   }
50 }
51
Popular Tags