KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > exceptions > ExceptionsHandlerTest


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.exceptions;
21
22 import java.util.logging.Level JavaDoc;
23 import java.util.logging.LogRecord JavaDoc;
24 import junit.framework.TestCase;
25
26 /**
27  *
28  * @author jindra
29  */

30 public class ExceptionsHandlerTest extends TestCase {
31     
32     public ExceptionsHandlerTest(String JavaDoc testName) {
33         super(testName);
34     }
35     
36     /**
37      * Test of publish method, of class org.netbeans.modules.exceptions.ExceptionsHandler.
38      */

39     public void testPublish() {
40         System.out.println("publish");
41         ExceptionsHandler instance = ExceptionsHandler.getInstance();
42         
43         LogRecord JavaDoc rec = new LogRecord JavaDoc(Level.SEVERE, "severe message");
44         instance.publish(rec);
45         assertTrue(Collector.getDefault().getQueue().contains(rec));
46         rec = new LogRecord JavaDoc(Level.WARNING, "warning message");
47         instance.publish(rec);
48         assertTrue(Collector.getDefault().getQueue().contains(rec));
49         rec = new LogRecord JavaDoc(Level.INFO, "warning message");
50         instance.publish(rec);
51         assertFalse(Collector.getDefault().getQueue().contains(rec));
52     }
53     
54     /**
55      * Test of showNotifyDialog method, of class org.netbeans.modules.exceptions.ExceptionsHandler.
56      */

57 // public void testShowNotifyDialog() {
58
// System.out.println("showNotifyDialog");
59
// ExceptionsHandler.getInstance().showNotifyDialog();
60
// }
61

62     /**
63      * Test of equalsThrows method, of class org.netbeans.modules.exceptions.ExceptionsHandler.
64      */

65     public void testEqualsThrows() {
66         System.out.println("equalsThrows");
67         
68         Throwable JavaDoc t1 = new NullPointerException JavaDoc("exception");
69         Throwable JavaDoc t2 = new ClassCastException JavaDoc("class cast");
70         
71         assertTrue(ExceptionsHandler.equalsThrows(t1, t1));
72         assertFalse(ExceptionsHandler.equalsThrows(t1, t2));
73         assertTrue(ExceptionsHandler.equalsThrows(t2, t2));
74         Throwable JavaDoc t3 = new NullPointerException JavaDoc("exception");
75         t3.initCause(t1);
76         assertTrue(ExceptionsHandler.equalsThrows(t3, t3));
77         assertFalse(ExceptionsHandler.equalsThrows(t3, t1));
78     }
79     
80     /**
81      * Test of getInstance method, of class org.netbeans.modules.exceptions.ExceptionsHandler.
82      */

83     public void testGetInstance() {
84         System.out.println("getInstance");
85         ExceptionsHandler result = ExceptionsHandler.getInstance();
86         assertNotNull(result);
87     }
88 }
89
Popular Tags