KickJava   Java API By Example, From Geeks To Geeks.

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


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.awt.event.ActionEvent JavaDoc;
23 import java.util.List JavaDoc;
24 import java.util.logging.Level JavaDoc;
25 import java.util.logging.Logger JavaDoc;
26 import javax.swing.AbstractAction JavaDoc;
27 import javax.swing.JButton JavaDoc;
28 import junit.framework.TestCase;
29 import java.util.logging.LogRecord JavaDoc;
30 import javax.swing.Action JavaDoc;
31
32 /**
33  *
34  * @author Jaroslav Tulach
35  */

36 public class UIHandlerTest extends TestCase {
37     private static Logger JavaDoc UILOG = Logger.getLogger("org.netbeans.ui.actions");
38
39     
40     public UIHandlerTest(String JavaDoc testName) {
41         super(testName);
42     }
43
44     protected void setUp() throws Exception JavaDoc {
45         Installer o = Installer.findObject(Installer.class, true);
46         assertNotNull("Installer created", o);
47         o.restored();
48     }
49
50     protected void tearDown() throws Exception JavaDoc {
51     }
52
53     public void testPublish() {
54         
55         MyAction a = new MyAction();
56         a.putValue(Action.NAME, "Tmp &Action");
57         JButton JavaDoc b = new JButton JavaDoc(a);
58         
59         LogRecord JavaDoc rec = new LogRecord JavaDoc(Level.FINER, "UI_ACTION_BUTTON_PRESS"); // NOI18N
60
rec.setParameters(new Object JavaDoc[] {
61             b,
62             b.getClass().getName(),
63             a,
64             a.getClass().getName(),
65             a.getValue(Action.NAME) }
66         );
67         UILOG.log(rec);
68         
69         List JavaDoc<LogRecord JavaDoc> logs = Installer.getLogs();
70         assertEquals("One log: " + logs, 1, logs.size());
71         LogRecord JavaDoc first = logs.get(0);
72         
73         assertSame("This is the logged record", rec, first);
74         
75         
76     }
77     
78     private static final class MyAction extends AbstractAction JavaDoc {
79         public void actionPerformed(ActionEvent JavaDoc e) {
80         }
81     }
82 }
83
Popular Tags