1 19 20 package org.netbeans.modules.uihandler; 21 22 import java.awt.event.ActionEvent ; 23 import java.util.List ; 24 import java.util.logging.Level ; 25 import java.util.logging.Logger ; 26 import javax.swing.AbstractAction ; 27 import javax.swing.JButton ; 28 import junit.framework.TestCase; 29 import java.util.logging.LogRecord ; 30 import javax.swing.Action ; 31 32 36 public class UIHandlerTest extends TestCase { 37 private static Logger UILOG = Logger.getLogger("org.netbeans.ui.actions"); 38 39 40 public UIHandlerTest(String testName) { 41 super(testName); 42 } 43 44 protected void setUp() throws Exception { 45 Installer o = Installer.findObject(Installer.class, true); 46 assertNotNull("Installer created", o); 47 o.restored(); 48 } 49 50 protected void tearDown() throws Exception { 51 } 52 53 public void testPublish() { 54 55 MyAction a = new MyAction(); 56 a.putValue(Action.NAME, "Tmp &Action"); 57 JButton b = new JButton (a); 58 59 LogRecord rec = new LogRecord (Level.FINER, "UI_ACTION_BUTTON_PRESS"); rec.setParameters(new Object [] { 61 b, 62 b.getClass().getName(), 63 a, 64 a.getClass().getName(), 65 a.getValue(Action.NAME) } 66 ); 67 UILOG.log(rec); 68 69 List <LogRecord > logs = Installer.getLogs(); 70 assertEquals("One log: " + logs, 1, logs.size()); 71 LogRecord first = logs.get(0); 72 73 assertSame("This is the logged record", rec, first); 74 75 76 } 77 78 private static final class MyAction extends AbstractAction { 79 public void actionPerformed(ActionEvent e) { 80 } 81 } 82 } 83 | Popular Tags |