KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > uihandler > ExceptionsTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.uihandler;
21
22 import java.util.logging.Level JavaDoc;
23 import java.util.logging.LogRecord JavaDoc;
24 import java.util.logging.Logger JavaDoc;
25 import org.netbeans.junit.NbTestCase;
26 import org.netbeans.modules.exceptions.ReportPanel;
27
28 /**
29  *
30  * @author jindra
31  */

32 public class ExceptionsTest extends NbTestCase {
33     
34     public ExceptionsTest(String JavaDoc testName) {
35         super(testName);
36     }
37     
38     public void testSetReportPanelSummary(){
39         String JavaDoc 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 JavaDoc{
46         Logger JavaDoc uiLogger = Logger.getLogger("org.netbeans.ui");
47         LogRecord JavaDoc log1 = new LogRecord JavaDoc(Level.SEVERE, "TESTING MESSAGE");
48         LogRecord JavaDoc log2 = new LogRecord JavaDoc(Level.SEVERE, "TESTING MESSAGE");
49         LogRecord JavaDoc log3 = new LogRecord JavaDoc(Level.SEVERE, "NO EXCEPTION LOG");
50         Throwable JavaDoc t1 = new NullPointerException JavaDoc("TESTING THROWABLE");
51         Throwable JavaDoc t2 = new UnknownError JavaDoc("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 JavaDoc(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