1 19 20 package org.netbeans.modules.exceptions; 21 22 import java.util.logging.Level ; 23 import java.util.logging.LogRecord ; 24 import junit.framework.TestCase; 25 26 30 public class ExceptionsHandlerTest extends TestCase { 31 32 public ExceptionsHandlerTest(String testName) { 33 super(testName); 34 } 35 36 39 public void testPublish() { 40 System.out.println("publish"); 41 ExceptionsHandler instance = ExceptionsHandler.getInstance(); 42 43 LogRecord rec = new LogRecord (Level.SEVERE, "severe message"); 44 instance.publish(rec); 45 assertTrue(Collector.getDefault().getQueue().contains(rec)); 46 rec = new LogRecord (Level.WARNING, "warning message"); 47 instance.publish(rec); 48 assertTrue(Collector.getDefault().getQueue().contains(rec)); 49 rec = new LogRecord (Level.INFO, "warning message"); 50 instance.publish(rec); 51 assertFalse(Collector.getDefault().getQueue().contains(rec)); 52 } 53 54 57 62 65 public void testEqualsThrows() { 66 System.out.println("equalsThrows"); 67 68 Throwable t1 = new NullPointerException ("exception"); 69 Throwable t2 = new ClassCastException ("class cast"); 70 71 assertTrue(ExceptionsHandler.equalsThrows(t1, t1)); 72 assertFalse(ExceptionsHandler.equalsThrows(t1, t2)); 73 assertTrue(ExceptionsHandler.equalsThrows(t2, t2)); 74 Throwable t3 = new NullPointerException ("exception"); 75 t3.initCause(t1); 76 assertTrue(ExceptionsHandler.equalsThrows(t3, t3)); 77 assertFalse(ExceptionsHandler.equalsThrows(t3, t1)); 78 } 79 80 83 public void testGetInstance() { 84 System.out.println("getInstance"); 85 ExceptionsHandler result = ExceptionsHandler.getInstance(); 86 assertNotNull(result); 87 } 88 } 89 | Popular Tags |