1 package org.sapia.ubik.rmi.interceptor; 2 3 import junit.framework.*; 4 5 6 14 public class SingleDispatcherTest extends TestCase { 15 19 public SingleDispatcherTest(String arg0) { 20 super(arg0); 21 } 22 23 public void testRegister() throws Exception { 24 SingleDispatcher d = new SingleDispatcher(); 25 TestInterceptor t = new TestInterceptor(); 26 d.registerInterceptor(TestEvent.class, t); 27 } 28 29 public void testDuplicateRegister() throws Exception { 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 ("duplicate registration not signaled"); 38 } catch (InvalidInterceptorException e) { 39 } 41 } 42 43 public void testDispatch() throws Exception { 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 |