1 19 20 package org.netbeans.core; 21 22 import java.util.Arrays ; 23 import java.util.List ; 24 import java.util.concurrent.Callable ; 25 import java.util.logging.Handler ; 26 import java.util.logging.LogRecord ; 27 import java.util.logging.Logger ; 28 import javax.swing.JButton ; 29 import org.netbeans.junit.NbTestCase; 30 31 35 public class NotifyExcPanelTest extends NbTestCase { 36 Logger main; 37 38 public NotifyExcPanelTest(String testName) { 39 super(testName); 40 } 41 42 protected void setUp() throws Exception { 43 main = Logger.getLogger(""); 44 for (Handler h : main.getHandlers()) { 45 main.removeHandler(h); 46 } 47 } 48 49 public void testHandlesThatImplementCallableForJButtonAreIncluded() throws Exception { 50 class H extends Handler 51 implements Callable <JButton > { 52 public JButton button = new JButton ("Extra"); 53 54 public void publish(LogRecord arg0) { 55 } 56 57 public void flush() { 58 } 59 60 public void close() throws SecurityException { 61 } 62 63 public JButton call() throws Exception { 64 return button; 65 } 66 } 68 H handler = new H(); 69 70 main.addHandler(handler); 71 72 List <Object > options = Arrays.asList(NotifyExcPanel.computeOptions("prev", "next")); 73 74 assertTrue("Contains our button: " + options, options.contains(handler.button)); 75 } 76 77 public void testHandlesThatImplementCallableForOtherObjectsAreNotIncluded() throws Exception { 78 class H extends Handler 79 implements Callable <Object > { 80 public JButton button = new JButton ("Extra"); 81 82 public void publish(LogRecord arg0) { 83 } 84 85 public void flush() { 86 } 87 88 public void close() throws SecurityException { 89 } 90 91 public JButton call() throws Exception { 92 return button; 93 } 94 } 96 H handler = new H(); 97 98 main.addHandler(handler); 99 100 List <Object > options = Arrays.asList(NotifyExcPanel.computeOptions("prev", "next")); 101 102 assertFalse("Does not contain our button: " + options, options.contains(handler.button)); 103 } 104 } 105 | Popular Tags |