KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > xam > ui > category > DefaultCategoryPaneTest


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.xml.xam.ui.category;
21
22 import javax.swing.Icon JavaDoc;
23 import javax.swing.JLabel JavaDoc;
24 import junit.framework.TestCase;
25 import org.netbeans.modules.xml.xam.Component;
26 import org.openide.util.Lookup;
27
28 /**
29  * Tests DefaultCategoryPane class.
30  *
31  * @author Nathan Fiedler
32  */

33 public class DefaultCategoryPaneTest extends TestCase {
34
35     public DefaultCategoryPaneTest(String JavaDoc testName) {
36         super(testName);
37     }
38
39     public void testAddSetGet() {
40         DefaultCategoryPane pane = new DefaultCategoryPane();
41         Category c1 = new TestCategory();
42         Category c2 = new TestCategory();
43         Category c3 = new TestCategory();
44         pane.addCategory(c1);
45         pane.addCategory(c2);
46         pane.addCategory(c3);
47         pane.setCategory(c1);
48         assertTrue(pane.getCategory() == c1);
49         pane.setCategory(c3);
50         assertTrue(pane.getCategory() == c3);
51         pane.setCategory(c2);
52         assertTrue(pane.getCategory() == c2);
53     }
54
55     /**
56      * Dummy category for the purpose of testing.
57      */

58     private static class TestCategory extends AbstractCategory {
59
60         public void showComponent(Component component) {
61         }
62
63         public String JavaDoc getTitle() {
64             return "";
65         }
66
67         public Lookup getLookup() {
68             return Lookup.EMPTY;
69         }
70
71         public Icon JavaDoc getIcon() {
72             return null;
73         }
74
75         public String JavaDoc getDescription() {
76             return "";
77         }
78
79         public java.awt.Component JavaDoc getComponent() {
80             return new JLabel JavaDoc();
81         }
82
83         public void componentShown() {
84         }
85
86         public void componentHidden() {
87         }
88     }
89 }
90
Popular Tags