KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ide > j2ee > runtime > nodes > PluginNodeTest


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.j2ee.sun.ide.j2ee.runtime.nodes;
21
22 import junit.framework.*;
23 import org.openide.nodes.*;
24 import org.openide.util.HelpCtx;
25 import org.openide.util.NbBundle;
26 import org.openide.util.actions.*;
27 import javax.enterprise.deploy.spi.factories.DeploymentFactory JavaDoc;
28 import javax.enterprise.deploy.spi.DeploymentManager JavaDoc;
29 import javax.enterprise.deploy.spi.Target JavaDoc;
30 import org.netbeans.modules.j2ee.sun.ide.j2ee.runtime.actions.RegisterServerAction;
31 import java.util.Collection JavaDoc;
32 import org.netbeans.modules.j2ee.sun.share.SecurityMasterListModel;
33
34 import java.util.Arrays JavaDoc;
35
36 import org.netbeans.modules.j2ee.sun.share.SunDeploymentFactory;
37 /**
38  *
39  * @author vkraemer
40  */

41 public class PluginNodeTest extends TestCase {
42     
43     public void testHasRequiredChildren() {
44         String JavaDoc startingPoint = System.getProperty("java.home");
45         java.io.File JavaDoc f = new java.io.File JavaDoc(startingPoint);
46         assertTrue(PluginNode.hasRequiredChildren(f,null));
47         java.util.Collection JavaDoc l = new java.util.ArrayList JavaDoc();
48         assertTrue(PluginNode.hasRequiredChildren(f, l));
49         l.add("lib");
50         assertTrue(PluginNode.hasRequiredChildren(f, l));
51         l.add("bin");
52         assertTrue(PluginNode.hasRequiredChildren(f, l));
53         l.add("foobaloo");
54         assertTrue(!PluginNode.hasRequiredChildren(f, l));
55         f = new java.io.File JavaDoc(startingPoint+java.io.File.separator+
56             "COPYRIGHT");
57         assertTrue(!PluginNode.hasRequiredChildren(f, l));
58     }
59     
60  /*obsolete with nb4.1, now j2ee platofmr manager is used
61   public void testStaticGetters() {
62         java.io.File fo = PluginNode.getInstallRootStatic();
63         assertNotNull(fo);
64         String path = fo.getAbsolutePath();
65         if (java.io.File.separator.equals("/"))
66             assertEquals(PluginNode.UNIX_DEFAULT_INSTALL_ROOT, path);
67         else
68             assertEquals(PluginNode.WINDOWS_DEFAULT_INSTALL_ROOT, path);
69         assertEquals(path, System.getProperty(PluginNode.INSTALL_ROOT_PROP_NAME));
70         PluginNode pn = new PluginNode(new SunDeploymentFactory());
71         fo = new java.io.File(".");
72         pn.setInstallRoot(fo);
73         fo = PluginNode.getInstallRootStatic();
74         assertEquals(fo.getAbsolutePath(), System.getProperty(PluginNode.INSTALL_ROOT_PROP_NAME));
75     }
76  */

77 /* public void testContainsSameElements() {
78         PluginNode node = new PluginNode(new SunDeploymentFactory());
79         String[] newValues = new String[] { "a", "b", "c" };
80         SecurityMasterListModel pModel =
81             SecurityMasterListModel.getGroupMasterModel();
82         assertTrue(!node.containsSameElements(pModel, newValues));
83         node.setGroupList(newValues);
84         assertTrue(node.containsSameElements(pModel,newValues));
85     }
86   */

87     public void testCreateSheet() {
88         PluginNode node = new PluginNode(new SunDeploymentFactory());
89         node.createSheet();
90     }
91         
92     
93     public void testChangeListener() {
94         PluginNode node = new PluginNode(new SunDeploymentFactory());
95         node.addPCL();
96         node.setLogLevel("INFO");
97     }
98         
99     
100     public void testSetLogLevel() {
101         PluginNode node = new PluginNode(new SunDeploymentFactory());
102         node.setLogLevel("foo");
103         assertEquals("OFF", node.getLogLevel());
104         node.setLogLevel("SEVERE");
105         assertEquals("SEVERE", node.getLogLevel());
106     }
107     
108     public void testCreate() {
109         PluginNode node = new PluginNode(new SunDeploymentFactory());
110         assertEquals("OFF", node.getLogLevel());
111     }
112         
113     
114     /** Test of getUserList method, of class org.netbeans.modules.j2ee.sun.ide.j2ee.runtime.nodes.PluginNode. */
115     public void testUserListRoutines() {
116         PluginNode node = new PluginNode(new SunDeploymentFactory());
117         String JavaDoc[] values = node.getUserList();
118         String JavaDoc[] newValues = new String JavaDoc[] { "a", "b", "c" };
119         node.setUserList(newValues);
120         String JavaDoc[] read = node.getUserList();
121         assertTrue("wrong length: " + read.length, read.length == 3);
122         assertEquals("a", read[0]);
123         assertEquals("b", read[1]);
124         assertEquals("c", read[2]);
125         newValues[0] = "x";
126         newValues[2] = "z";
127         node.setUserList(newValues);
128         read = node.getUserList();
129         assertTrue("arry length is wrong: " + read.length, read.length == 3);
130         assertEquals("x", read[0]);
131         assertEquals("b", read[1]);
132         assertEquals("z", read[2]);
133     }
134
135     public void testGroupListRoutines() {
136         PluginNode node = new PluginNode(new SunDeploymentFactory());
137         String JavaDoc[] values = node.getGroupList();
138         String JavaDoc[] newValues = new String JavaDoc[] { "a", "b", "c" };
139         node.setGroupList(newValues);
140         String JavaDoc[] read = node.getGroupList();
141         assertTrue(read.length == 3);
142         assertEquals("a", read[0]);
143         assertEquals("b", read[1]);
144         assertEquals("c", read[2]);
145         newValues[0] = "x";
146         newValues[2] = "z";
147         node.setGroupList(newValues);
148         read = node.getGroupList();
149         assertTrue("arry length is wrong: " + read.length, read.length == 3);
150         assertEquals("x", read[0]);
151         assertEquals("b", read[1]);
152         assertEquals("z", read[2]);
153     }
154     
155     public PluginNodeTest(java.lang.String JavaDoc testName) {
156         super(testName);
157     }
158     
159 }
160
Popular Tags