1 4 package org.oddjob.jmx.server; 5 6 import javax.management.Notification ; 7 8 import junit.framework.TestCase; 9 10 import org.oddjob.Iconic; 11 import org.oddjob.images.IconEvent; 12 import org.oddjob.images.IconListener; 13 import org.oddjob.images.IconTip; 14 import org.oddjob.util.ThreadManager; 15 16 public class IconicInfoTest extends TestCase { 17 19 public void test1() throws Exception { 20 class MyIconic implements Iconic { 21 IconListener l; 22 public void addIconListener(IconListener listener) { 23 l = listener; 24 } 25 public IconTip iconForId(String id) { 26 return new IconTip((byte[]) null, "test"); 27 } 28 public void removeIconListener(IconListener listener) { 29 l = null; 30 } 31 } 32 MyIconic i = new MyIconic(); 33 34 InterfaceManagerFactory imf = new InterfaceManagerFactory(); 35 imf.addInterfaceInfo(new IconicInfo()); 36 ServerModel sm = new ServerModel( 37 "//test/", 38 new ThreadManager(), 39 imf); 40 sm.setRoot(i); 41 42 OddjobMBean ojmb = new OddjobMBean(i, null, new ServerContext(sm)); 43 44 IconicInfo ii = new IconicInfo(); 45 InterfaceHandler h = ii.attach(i, ojmb); 46 47 i.l.iconEvent(new IconEvent(i, "test")); 48 Notification n = h.getLastNotifications()[0]; 49 assertEquals(IconicInfo.ICON_CHANGED_NOTIF_TYPE, n.getType()); 50 51 IconTip it = (IconTip) ojmb.invoke("iconForId", new Object [] { "whatever" }, 52 new String [] { String .class.getName() } ); 53 54 assertEquals("test", it.getToolTip()); 55 } 56 } 57 | Popular Tags |