001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package gui.setup;
043:
044: import javax.swing.tree.TreePath;
045: import org.netbeans.jellytools.Bundle;
046: import org.netbeans.jellytools.NbDialogOperator;
047: import org.netbeans.jellytools.MainWindowOperator;
048: import org.netbeans.jellytools.ProjectsTabOperator;
049: import org.netbeans.jellytools.actions.BuildProjectAction;
050: import org.netbeans.junit.ide.ProjectSupport;
051: import org.netbeans.jellytools.RuntimeTabOperator;
052:
053: import org.netbeans.jemmy.TimeoutExpiredException;
054: import org.netbeans.jemmy.operators.JButtonOperator;
055: import org.netbeans.jemmy.operators.JCheckBoxOperator;
056: import org.netbeans.jemmy.operators.JListOperator;
057: import org.netbeans.jemmy.operators.JMenuBarOperator;
058: import org.netbeans.jemmy.operators.JMenuItemOperator;
059: import org.netbeans.jemmy.operators.JPopupMenuOperator;
060: import org.netbeans.jemmy.operators.JTextFieldOperator;
061: import org.netbeans.jemmy.operators.JTreeOperator;
062:
063: public class WebSetupTest extends org.netbeans.jellytools.JellyTestCase {
064:
065: public WebSetupTest(java.lang.String testName) {
066: super (testName);
067: }
068:
069: public void testOpenWebProject() {
070: ProjectSupport.openProject(System.getProperty("xtest.data")
071: + "/TestWebProject");
072: buildProject("TestWebProject");
073: }
074:
075: public void testOpenWebFoldersProject() {
076: ProjectSupport.openProject(System.getProperty("xtest.tmpdir")
077: + "/PerformanceTestFolderWebApp");
078: buildProject("PerformanceTestFolderWebApp");
079: }
080:
081: public void testAddAppServer() {
082:
083: String appServerPath = System
084: .getProperty("com.sun.aas.installRoot");
085: String addServerMenuItem = Bundle
086: .getStringTrimmed(
087: "org.netbeans.modules.j2ee.deployment.impl.ui.actions.Bundle",
088: "LBL_Add_Server_Instance"); // Add Server...
089: String addServerInstanceDialogTitle = Bundle
090: .getStringTrimmed(
091: "org.netbeans.modules.j2ee.deployment.impl.ui.wizard.Bundle",
092: "LBL_ASIW_Title"); //"Add Server Instance"
093: String serverItem = "Tomcat 6.0";
094: String nextButtonCaption = Bundle.getStringTrimmed(
095: "org.openide.Bundle", "CTL_NEXT");
096: String finishButtonCaption = Bundle.getStringTrimmed(
097: "org.openide.Bundle", "CTL_FINISH");
098:
099: RuntimeTabOperator rto = RuntimeTabOperator.invoke();
100: JTreeOperator runtimeTree = rto.tree();
101:
102: long oldTimeout = runtimeTree.getTimeouts().getTimeout(
103: "JTreeOperator.WaitNextNodeTimeout");
104: runtimeTree.getTimeouts().setTimeout(
105: "JTreeOperator.WaitNextNodeTimeout", 60000);
106:
107: TreePath path = runtimeTree.findPath("Servers");
108: runtimeTree.selectPath(path);
109:
110: try {
111: //log("Let's check whether GlassFish V2 is already added");
112: runtimeTree.findPath("Servers|Tomcat 6.0");
113: } catch (TimeoutExpiredException tee) {
114: //log("There is no GlassFish V2 node so we'll add it");
115:
116: new JPopupMenuOperator(runtimeTree.callPopupOnPath(path))
117: .pushMenuNoBlock(addServerMenuItem);
118: NbDialogOperator addServerInstanceDialog = new NbDialogOperator(
119: addServerInstanceDialogTitle);
120: new JListOperator(addServerInstanceDialog, 1)
121: .selectItem(serverItem);
122: new JButtonOperator(addServerInstanceDialog,
123: nextButtonCaption).push();
124: new JTextFieldOperator(addServerInstanceDialog, 1)
125: .enterText(appServerPath);
126: new JCheckBoxOperator(addServerInstanceDialog, 1)
127: .changeSelection(false);
128: new JButtonOperator(addServerInstanceDialog,
129: finishButtonCaption).push();
130: }
131:
132: runtimeTree.getTimeouts().setTimeout(
133: "JTreeOperator.WaitNextNodeTimeout", oldTimeout);
134:
135: }
136:
137: private void buildProject(String name) {
138: new BuildProjectAction().perform(new ProjectsTabOperator()
139: .getProjectRootNode(name));
140: MainWindowOperator.getDefault().waitStatusText(
141: "Finished building");
142: }
143: }
|