1 19 20 package org.netbeans.modules.uihandler; 21 22 import java.util.logging.Level ; 23 import java.util.logging.LogRecord ; 24 import java.util.logging.Logger ; 25 import org.netbeans.junit.NbTestCase; 26 import org.netbeans.modules.exceptions.ReportPanel; 27 28 32 public class ExceptionsTest extends NbTestCase { 33 34 public ExceptionsTest(String testName) { 35 super(testName); 36 } 37 38 public void testSetReportPanelSummary(){ 39 String str = "RETEZEC SUMMARY"; 40 ReportPanel panel = new ReportPanel(); 41 panel.setSummary(str); 42 assertEquals(str, panel.getSummary()); 43 } 44 45 public void testExceptionThrown() throws Exception { 46 Logger uiLogger = Logger.getLogger("org.netbeans.ui"); 47 LogRecord log1 = new LogRecord (Level.SEVERE, "TESTING MESSAGE"); 48 LogRecord log2 = new LogRecord (Level.SEVERE, "TESTING MESSAGE"); 49 LogRecord log3 = new LogRecord (Level.SEVERE, "NO EXCEPTION LOG"); 50 Throwable t1 = new NullPointerException ("TESTING THROWABLE"); 51 Throwable t2 = new UnknownError ("TESTING ERROR"); 52 log1.setThrown(t1); 53 log2.setThrown(t2); 54 Installer installer = Installer.findObject(Installer.class, true); 55 assertNotNull(installer); 56 installer.restored(); 57 uiLogger.log(log1); 58 uiLogger.log(log2); 59 uiLogger.log(log3); 60 assertEquals(3, installer.getLogsSize()); 61 assertEquals(t2, installer.getThrown()); 62 log1 = new LogRecord (Level.SEVERE, "TESTING 2"); 63 log1.setThrown(t1); 64 uiLogger.log(log1); 65 assertEquals(4, installer.getLogsSize()); 66 assertEquals(t1, installer.getThrown()); 67 for (int i= 0; i < 10; i++){ 68 uiLogger.warning("MESSAGE "+Integer.toString(i)); 69 } 70 assertEquals(14, installer.getLogsSize()); 71 assertEquals(t1, installer.getThrown()); 72 } 73 } 74 | Popular Tags |