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-2007 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 org.netbeans.test.deployment.generic;
043:
044: import org.netbeans.jemmy.operators.*;
045: import org.netbeans.junit.NbTestSuite;
046: import junit.framework.Test;
047:
048: import org.netbeans.modules.visualweb.gravy.dataconnectivity.ServerNavigatorOperator;
049: import org.netbeans.modules.visualweb.gravy.designer.DesignerPaneOperator;
050: import org.netbeans.modules.visualweb.gravy.plugins.PluginsOperator;
051: import org.netbeans.modules.visualweb.gravy.RaveWindowOperator;
052: import org.netbeans.modules.visualweb.gravy.RaveTestCase;
053: import org.netbeans.modules.visualweb.gravy.TestUtils;
054: import org.netbeans.modules.visualweb.gravy.Util;
055: import org.netbeans.modules.visualweb.gravy.model.components.DropDownListComponent;
056: import org.netbeans.modules.visualweb.gravy.model.components.WebComponent;
057: import org.netbeans.modules.visualweb.gravy.model.deployment.ApplicationServer;
058: import org.netbeans.modules.visualweb.gravy.model.deployment.DeploymentTarget;
059: import org.netbeans.modules.visualweb.gravy.model.deployment.DeploymentTargetDescriptor;
060: import org.netbeans.modules.visualweb.gravy.model.project.components.VisualEventHandlingComponent;
061: import org.netbeans.modules.visualweb.gravy.model.project.ProjectDescriptor;
062: import org.netbeans.modules.visualweb.gravy.model.project.Project;
063: import org.netbeans.modules.visualweb.gravy.model.project.WebPageFolder;
064: import org.netbeans.modules.visualweb.gravy.model.project.WebPage;
065: import org.netbeans.modules.visualweb.gravy.model.IDE;
066:
067: import com.meterware.httpunit.*;
068: import java.awt.*;
069:
070: /**
071: *
072: * @author Roman Mostyka
073: */
074:
075: public class RestartTest extends RaveTestCase {
076:
077: private ServerNavigatorOperator server;
078: private JTreeOperator sntree;
079: private DesignerPaneOperator designer;
080: private DeploymentAcceptanceTest dat;
081: public static String serverType = null;
082: static String AS_PREF;
083:
084: /** constructor required by JUnit
085: * @param testName method name to be used as testcase
086: */
087: public RestartTest(String testName) {
088: super (testName);
089: }
090:
091: public static Test suite() {
092: NbTestSuite suite = new NbTestSuite(
093: "Restart IDE and Deploy Tests");
094: suite.addTest(new RestartTest("testRestartIDEandDeploy_1"));
095: return suite;
096: }
097:
098: /** method called before each testcase
099: */
100: protected void setUp() {
101: }
102:
103: public void testRestartIDEandDeploy_1() {
104: PluginsOperator.getInstance().installAvailablePlugins(
105: dat.pluginName);
106: DeploymentTargetDescriptor dtd = new DeploymentTargetDescriptor();
107: dtd.load();
108: if (serverType != null)
109: dtd.setProperty(dtd.SERVER_TYPE_KEY, serverType);
110: DeploymentTarget dt = IDE.getIDE().addDeploymentTarget(dtd);
111: ApplicationServer as = (ApplicationServer) dt;
112: AS_PREF = as.getName().replace(' ', '_').replace('.', '_');
113: as.start();
114: TestUtils.wait(1000);
115: dat.path_to_applications = server.STR_SERVERS_PATH
116: + as.web_applications_path;
117: if (as.getName().indexOf("WebLogic") == -1) {
118: ProjectDescriptor pd = new ProjectDescriptor(AS_PREF + "_"
119: + dat._testProjectName + "1", dat._projectPath,
120: ProjectDescriptor.J2EE14, as.getName());
121: Project prj = IDE.getIDE().createProject(pd);
122: TestUtils.disableBrowser(AS_PREF + "_"
123: + dat._testProjectName + "1", true);
124: TestUtils.wait(1000);
125: WebPageFolder wpf = prj.getRoot().getWebPageRootFolder();
126: WebPage wp = wpf.getWebPage("Page1");
127: VisualEventHandlingComponent vehcmp = (VisualEventHandlingComponent) wp
128: .add(
129: (WebComponent) IDE
130: .getIDE()
131: .getDefaultComponentSet()
132: .getComponent(
133: DropDownListComponent.DROP_DOWN_LIST_ID),
134: new Point(48, 48));
135: dat.connectToDB(dat.testDBName);
136: TestUtils.wait(500);
137: designer = new DesignerPaneOperator(RaveWindowOperator
138: .getDefaultRave());
139: TestUtils.wait(1000);
140: server = ServerNavigatorOperator.showNavigatorOperator();
141: TestUtils.wait(4000);
142: sntree = server.getTree();
143: sntree.selectPath(sntree.findPath(dat.dbPath
144: + dat.testDBName + "|Tables|CUSTOMER"));
145: designer.requestFocus();
146: designer.clickMouse(50, 50, 1);
147: TestUtils.wait(2000);
148: designer.requestFocus();
149: designer.clickForPopup(50, 50);
150: JPopupMenuOperator popup = new JPopupMenuOperator();
151: popup.pushMenuNoBlock(dat.bindDBPopup);
152: JDialogOperator dataBind = new JDialogOperator(
153: dat.dlg_bindDB);
154: new JTabbedPaneOperator(dataBind).selectPage(dat.bindToDP);
155: TestUtils.wait(1000);
156: JListOperator valueList = new JListOperator(dataBind, 0);
157: TestUtils.wait(1000);
158: valueList.selectItem("CUSTOMER.CUSTOMER_ID");
159: TestUtils.wait(1000);
160: JListOperator displayList = new JListOperator(dataBind, 1);
161: TestUtils.wait(1000);
162: displayList.selectItem("CUSTOMER.NAME");
163: TestUtils.wait(1000);
164: new JButtonOperator(dataBind, dat.btn_OK).pushNoBlock();
165: TestUtils.wait(1000);
166: prj.run();
167: try {
168: WebConversation conversation = new WebConversation();
169: WebResponse response = null;
170: System.out.println("requestPrefix=" + as.requestPrefix);
171: response = conversation.getResponse(as.requestPrefix
172: + AS_PREF + "_" + dat._testProjectName + "1");
173: if (response.getText().indexOf("JumboCom") == -1)
174: fail("Application is not contained right data!");
175: } catch (Exception e) {
176: System.out.println("Exception occured: ");
177: e.printStackTrace();
178: fail("Excetion in HTTP check : " + e);
179: } finally {
180: dat.finishProject(prj, true, true);
181: TestUtils.wait(1000);
182: dat.disconnectFromDB(dat.testDBName);
183: TestUtils.wait(1000);
184: }
185: }
186: dat.stopDB();
187: TestUtils.wait(1000);
188: as.stop();
189: TestUtils.wait(1000);
190: }
191: }
|