KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > startup > IDESetupTest


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 startup;
21
22 import org.netbeans.jellytools.*;
23 import org.netbeans.jellytools.nodes.Node;
24 import org.netbeans.jemmy.operators.*;
25 import org.netbeans.jellytools.actions.CloseAllDocumentsAction;
26
27 import org.netbeans.junit.ide.ProjectSupport;
28
29 public class IDESetupTest extends org.netbeans.jellytools.JellyTestCase {
30     
31     public IDESetupTest(java.lang.String JavaDoc testName) {
32         super(testName);
33     }
34
35     
36     public void closeAllDocuments(){
37         new CloseAllDocumentsAction().perform();
38     }
39     
40     
41     /**
42      * Close Memory Toolbar.
43      */

44     public void testCloseMemoryToolbar(){
45         String JavaDoc MENU =
46             org.netbeans.jellytools.Bundle.getStringTrimmed("org.netbeans.core.Bundle","Menu/View") + "|" +
47             org.netbeans.jellytools.Bundle.getStringTrimmed("org.netbeans.core.windows.actions.Bundle","CTL_ToolbarsListAction") + "|" +
48             org.netbeans.jellytools.Bundle.getStringTrimmed("org.netbeans.core.Bundle","Toolbars/Memory");
49         
50         MainWindowOperator mainWindow = MainWindowOperator.getDefault();
51         JMenuBarOperator menuBar = new JMenuBarOperator(mainWindow.getJMenuBar());
52         JMenuItemOperator menuItem = menuBar.showMenuItem(MENU,"|");
53         
54         if(menuItem.isSelected())
55             menuItem.push();
56         else {
57             menuItem.pushKey(java.awt.event.KeyEvent.VK_ESCAPE);
58             mainWindow.pushKey(java.awt.event.KeyEvent.VK_ESCAPE);
59         }
60         
61     }
62     
63      public void testAddAppServer() {
64         String JavaDoc path = System.getProperty("j2ee.appserver.path");
65         if (path == null) {
66             if (System.getProperty("os.name").toLowerCase().indexOf("windows") >= 0) {
67                 path = "E:\\space\\AppServer";
68                 //path = "E:\\Sun\\AppServer-8.1_01_b04";
69
} else {
70                 path = "/space/appserver";
71             }
72         }
73         String JavaDoc username = System.getProperty("j2ee.appserver.username","admin");
74         String JavaDoc password = System.getProperty("j2ee.appserver.password","adminadmin");
75                     
76         Node node = new Node(new RuntimeTabOperator().getRootNode(),"Servers");
77         node.performPopupActionNoBlock("Add Server...");
78         NbDialogOperator dialog = new NbDialogOperator("Add Server");
79         new JComboBoxOperator(dialog).selectItem("Sun Java System Application Server");
80         new JButtonOperator(dialog,"Next").push();
81         
82         //"Enter the Application Server location" or "Define Application Server Instance Properties"
83
/* if (new JLabelOperator(dialog,1).getText().equalsIgnoreCase("Enter the Application Server location")) {
84             new JTextFieldOperator(dialog).setText("");
85             new JTextFieldOperator(dialog).typeText(path);
86             new JButtonOperator(dialog,"Next").push();
87         }*/

88          if (new JLabelOperator(dialog,1).getText().equalsIgnoreCase("Platform Folder Location")) {
89             new JTextFieldOperator(dialog).setText("");
90             new JTextFieldOperator(dialog).typeText(path);
91             new org.netbeans.jemmy.EventTool().waitNoEvent(5000);
92             new JButtonOperator(dialog,"Next").push();
93         }
94         new JTextFieldOperator(dialog,0).setText("");
95         new JTextFieldOperator(dialog,1).setText("");
96         new JTextFieldOperator(dialog,0).typeText(username);
97         new JTextFieldOperator(dialog,1).typeText(password);
98         new JButtonOperator(dialog,"Finish").push();
99         
100         
101         new ProjectsTabOperator();
102     }
103     
104
105     
106     
107 }
108
Popular Tags