1 20 package org.enhydra.barracuda.core.event; 21 22 import java.util.*; 23 24 import junit.framework.*; 25 import org.apache.log4j.*; 26 27 import org.enhydra.barracuda.plankton.data.*; 28 import org.enhydra.barracuda.testbed.*; 29 30 35 public class TestDefaultEventBroker extends DefaultTestCase { 36 private static String testClass = TestDefaultEventBroker.class.getName(); 38 private static Logger logger = Logger.getLogger("test."+testClass); 39 40 42 46 public TestDefaultEventBroker(String name) { 47 super(name); 48 } 49 50 57 public static void main(String args[]) { 58 TestUtil.parseParams(args); 60 61 if (TestUtil.BATCH_MODE) junit.textui.TestRunner.main(new String [] {testClass}); 63 else junit.swingui.TestRunner.main(new String [] {testClass}); 64 } 65 66 67 73 76 public void testListeners() throws InvalidClassException { 77 if (logger.isInfoEnabled()) logger.info("testing event broker listeners"); 78 79 DefaultEventBroker eb = new DefaultEventBroker(null, ".event"); 81 List lAliases = null; 82 String id = null; 83 String result = null; 84 85 String classes[] = new String [] { 87 "foo.blah.event.Test", 88 "foo.blah.event.Blarney", 89 "foo.blah.event2.Test" 90 }; 91 for (int i=0; i<classes.length; i++) { 92 eb.addAliases(classes[i], eb.getAliases(classes[i]), eb.eventXref); 93 } 94 95 101 102 id = "Blarney"; 104 result = eb.matchEventClass(id); 105 assertTrue("failed to find id:"+id+", got:"+result, classes[1].equals(result)); 106 id = "event2.Test"; 107 result = eb.matchEventClass(id); 108 assertTrue("failed to find id:"+id+", got:"+result, classes[2].equals(result)); 109 id = "Test"; 110 try { 111 result = eb.matchEventClass(id); 112 fail("failed to throw exception on id:"+id+", got:"+result); 113 } catch (InvalidClassException e) { 114 } 116 id = "BLARNEY"; result = eb.matchEventClass(id); 118 assertTrue("failed to find id:"+id+", got:"+result, classes[1].equals(result)); 119 id = "blarney"; result = eb.matchEventClass(id); 121 assertTrue("failed to find id:"+id+", got:"+result, classes[1].equals(result)); 122 id = "fOo.BlAh.EvEnT.bLaRnEy"; result = eb.matchEventClass(id); 124 assertTrue("failed to find id:"+id+", got:"+result, classes[1].equals(result)); 125 } 126 } 127 | Popular Tags |