KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > freeform > ui > ViewTest


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.java.freeform.ui;
21
22 import org.netbeans.modules.ant.freeform.TestBase;
23 import org.netbeans.modules.java.freeform.JavaProjectNature;
24 import org.netbeans.spi.project.ui.LogicalViewProvider;
25 import org.openide.loaders.DataObject;
26 import org.openide.nodes.Children;
27 import org.openide.nodes.Node;
28
29 /**
30  * Test just style="packages".
31  * @author Jesse Glick
32  */

33 public class ViewTest extends TestBase {
34
35     public ViewTest(String JavaDoc name) {
36         super(name);
37     }
38
39     private LogicalViewProvider lvp;
40
41     protected void setUp() throws Exception JavaDoc {
42         super.setUp();
43         lvp = extsrcroot.getLookup().lookup(LogicalViewProvider.class);
44         assertNotNull("found a LogicalViewProvider", lvp);
45     }
46     
47     public void testViewItemBasic() throws Exception JavaDoc {
48         Node root = lvp.createLogicalView();
49         Children ch = root.getChildren();
50         Node[] kids = ch.getNodes(true);
51         assertEquals("two child nodes", 2, kids.length);
52         assertEquals("correct code name #1", "../src", kids[0].getName());
53         assertEquals("correct display name #1", "External Sources", kids[0].getDisplayName());
54         assertEquals("correct cookie #1",
55             DataObject.find(egdirFO.getFileObject("extsrcroot/src")),
56             kids[0].getLookup().lookup(DataObject.class));
57         Node[] kids2 = kids[0].getChildren().getNodes(true);
58         assertEquals("one child of ../src", 1, kids2.length);
59         assertEquals("correct name of #1's kid", "org.foo", kids2[0].getName());
60         // Do not test node #2; supplied by ant/freeform.
61
}
62     
63     public void testFindPath() throws Exception JavaDoc {
64         LogicalViewProvider lvp2 = simple.getLookup().lookup(LogicalViewProvider.class);
65         assertNotNull(lvp2);
66         Node root = lvp2.createLogicalView();
67         org.netbeans.modules.ant.freeform.ui.ViewTest.doTestFindPathPositive(lvp2, root, simple, "src/org/foo/myapp/MyApp.java");
68         org.netbeans.modules.ant.freeform.ui.ViewTest.doTestFindPathPositive(lvp2, root, simple, "src/org/foo/myapp");
69         org.netbeans.modules.ant.freeform.ui.ViewTest.doTestFindPathNegative(lvp2, root, simple, "src/org/foo");
70         org.netbeans.modules.ant.freeform.ui.ViewTest.doTestFindPathNegative(lvp2, root, simple, "src/org");
71         org.netbeans.modules.ant.freeform.ui.ViewTest.doTestFindPathPositive(lvp2, root, simple, "src");
72         org.netbeans.modules.ant.freeform.ui.ViewTest.doTestFindPathPositive(lvp2, root, simple, "antsrc/org/foo/ant/SpecialTask.java");
73     }
74     
75     public void testIncludesExcludes() throws Exception JavaDoc {
76         org.netbeans.modules.ant.freeform.ui.ViewTest.doTestIncludesExcludes(this, JavaProjectNature.STYLE_PACKAGES,
77                 "prj{s{ignored{file} relevant.excluded{file} relevant.included{file}}}",
78                 "prj{s{relevant.included{file}}}",
79                 "prj{s{ignored{file} relevant.included{file}}}",
80                 "prj{s{relevant.included{file}}}");
81     }
82
83 }
84
Popular Tags