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 gui.action;
043:
044: import footprint.VWPFootprintUtilities;
045: import gui.window.WebFormDesignerOperator;
046: import org.netbeans.jellytools.NbDialogOperator;
047: import org.netbeans.jellytools.NewProjectNameLocationStepOperator;
048: import org.netbeans.jellytools.NewProjectWizardOperator;
049: import org.netbeans.jellytools.actions.CloseAllDocumentsAction;
050: import org.netbeans.jemmy.JemmyProperties;
051: import org.netbeans.jemmy.TimeoutExpiredException;
052:
053: import org.netbeans.jemmy.operators.ComponentOperator;
054: import org.netbeans.jemmy.operators.JTableOperator;
055:
056: /**
057: * Test create Web Pack projects
058: *
059: * @author mkhramov@netbeans.org, mmirilovic@netbeans.org
060: */
061: public class CreateWebPackProjectSBS extends
062: org.netbeans.performance.test.utilities.PerformanceTestCase {
063:
064: private NewProjectNameLocationStepOperator wizard_location;
065:
066: private String category, project, project_name, project_type;
067:
068: /**
069: * Creates a new instance of CreateWebPackProject
070: * @param testName the name of the test
071: */
072: public CreateWebPackProjectSBS(String testName) {
073: super (testName);
074: expectedTime = 10000;
075: WAIT_AFTER_OPEN = 20000;
076: }
077:
078: /**
079: * Creates a new instance of CreateWebPackProject
080: * @param testName the name of the test
081: * @param performanceDataName measured values will be saved under this name
082: */
083: public CreateWebPackProjectSBS(String testName,
084: String performanceDataName) {
085: super (testName, performanceDataName);
086: expectedTime = 10000;
087: WAIT_AFTER_OPEN = 20000;
088: }
089:
090: public void testCreateWebPackProject() {
091: category = org.netbeans.jellytools.Bundle.getStringTrimmed(
092: "org.netbeans.modules.web.project.ui.wizards.Bundle",
093: "Templates/Project/Web"); // Web
094: project = "Web Application";
095: project_type = "JSFWebProject";
096:
097: doMeasurement();
098: }
099:
100: public void initialize() {
101: log("::initialize::");
102: PerformanceCounters.initPerformanceCounters(this );
103: }
104:
105: public void prepare() {
106: log("::prepare");
107: createProject();
108: }
109:
110: private void createProject() {
111: NewProjectWizardOperator wizard = NewProjectWizardOperator
112: .invoke();
113: wizard.selectCategory(category);
114: wizard.selectProject(project);
115: wizard.next();
116: wizard_location = new NewProjectNameLocationStepOperator();
117:
118: String directory = System.getProperty("xtest.tmpdir");
119: log("================= Destination directory={" + directory
120: + "}");
121: wizard_location.txtProjectLocation().setText("");
122: waitNoEvent(1000);
123: wizard_location.txtProjectLocation().setText(directory);
124:
125: project_name = project_type + "_" + System.currentTimeMillis();
126: log("================= Project name=" + project_name + "}");
127: wizard_location.txtProjectName().setText("");
128: waitNoEvent(1000);
129: wizard_location.txtProjectName().typeText(project_name);
130:
131: wizard_location.next();
132: wizard_location.next();
133:
134: JTableOperator frameworkselector = new JTableOperator(wizard);
135: frameworkselector.selectCell(0, 0);
136:
137: }
138:
139: public ComponentOperator open() {
140: log("::open");
141: PerformanceCounters.addPerformanceCounter("Wait Wizard closed");
142: wizard_location.finish();
143:
144: long oldTimeout = JemmyProperties.getCurrentTimeouts()
145: .getTimeout("ComponentOperator.WaitStateTimeout");
146: JemmyProperties.getCurrentTimeouts().setTimeout(
147: "ComponentOperator.WaitStateTimeout", 120000);
148: wizard_location.waitClosed();
149: PerformanceCounters.endPerformanceCounter("Wait Wizard closed");
150:
151: PerformanceCounters
152: .addPerformanceCounter("Wait Project Creation Box");
153: waitProjectCreatingDialogClosed();
154: PerformanceCounters
155: .endPerformanceCounter("Wait Project Creation Box");
156:
157: JemmyProperties.getCurrentTimeouts().setTimeout(
158: "ComponentOperator.WaitStateTimeout", oldTimeout);
159:
160: PerformanceCounters.addPerformanceCounter("Wait document");
161: WebFormDesignerOperator.findWebFormDesignerOperator("Page1");
162:
163: PerformanceCounters.endPerformanceCounter("Wait document");
164: return null;
165: }
166:
167: public void close() {
168: log("::close");
169: PerformanceCounters.reportPerformanceCounters();
170: try {
171: new CloseAllDocumentsAction().performAPI(); //avoid issue 68671 - editors are not closed after closing project by ProjectSupport
172: } catch (Exception ex) {
173: log("Exception catched on CloseAllDocuments action: "
174: + ex.getMessage());
175: }
176: VWPFootprintUtilities.deleteProject(project_name);
177: }
178:
179: private void waitProjectCreatingDialogClosed() {
180: String dlgName = org.netbeans.jellytools.Bundle.getString(
181: "org.netbeans.modules.visualweb.project.jsf.ui.Bundle",
182: "CAP_Opening_Projects");
183: try {
184: NbDialogOperator dlg = new NbDialogOperator(dlgName);
185: dlg.waitClosed();
186: } catch (TimeoutExpiredException tex) {
187: //
188: }
189:
190: }
191:
192: public static void main(java.lang.String[] args) {
193: junit.textui.TestRunner.run(new CreateWebPackProject(
194: "testCreateWebPackProject"));
195: }
196:
197: }
|