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.web;
043:
044: import java.io.File;
045: import java.io.IOException;
046: import org.netbeans.jellytools.*;
047: import org.netbeans.jellytools.actions.ActionNoBlock;
048: import org.netbeans.jellytools.actions.NewProjectAction;
049: import org.netbeans.jellytools.nodes.Node;
050: import org.netbeans.jemmy.EventTool;
051: import org.netbeans.jemmy.Timeouts;
052: import org.netbeans.jemmy.operators.JButtonOperator;
053: import org.netbeans.jemmy.operators.JComboBoxOperator;
054: import org.netbeans.jemmy.operators.JListOperator;
055: import org.netbeans.jemmy.operators.JTextFieldOperator;
056: import org.netbeans.jemmy.operators.JTreeOperator;
057: import org.netbeans.junit.NbTestSuite;
058: import org.netbeans.junit.ide.ProjectSupport;
059:
060: /**
061: *
062: * @author lm97939
063: */
064: public class WebProjectValidation13 extends WebProjectValidation {
065: static {
066: PROJECT_NAME = "SampleProject13"; // NOI18N
067: PROJECT_FOLDER = PROJECT_LOCATION + File.separator
068: + PROJECT_NAME;
069: }
070:
071: /** Need to be defined because of JUnit */
072: public WebProjectValidation13(String name) {
073: super (name);
074: }
075:
076: /** Use for execution inside IDE */
077: public static void main(java.lang.String[] args) {
078: // run whole suite
079: junit.textui.TestRunner.run(suite());
080: // run only selected test case
081: //junit.textui.TestRunner.run(new MyModuleValidation("testT2"));
082: }
083:
084: public static NbTestSuite suite() {
085: NbTestSuite suite = new NbTestSuite();
086: suite.addTest(new WebProjectValidation13("testNewWebProject"));
087: suite.addTest(new WebProjectValidation13("testNewJSP"));
088: suite.addTest(new WebProjectValidation13("testNewJSP2"));
089: suite.addTest(new WebProjectValidation13("testNewServlet"));
090: suite.addTest(new WebProjectValidation13("testNewServlet2"));
091: suite.addTest(new WebProjectValidation13("testBuildProject"));
092: suite.addTest(new WebProjectValidation13("testCompileAllJSP"));
093: suite.addTest(new WebProjectValidation13("testCompileJSP"));
094: suite.addTest(new WebProjectValidation13("testCleanProject"));
095: suite.addTest(new WebProjectValidation13("testRunProject"));
096: suite.addTest(new WebProjectValidation13("testRunJSP"));
097: suite.addTest(new WebProjectValidation13("testRunServlet"));
098: suite.addTest(new WebProjectValidation13("testCreateTLD"));
099: suite
100: .addTest(new WebProjectValidation13(
101: "testCreateTagHandler"));
102: suite.addTest(new WebProjectValidation13("testRunTag"));
103: suite.addTest(new WebProjectValidation13("testNewHTML"));
104: suite.addTest(new WebProjectValidation13("testRunHTML"));
105: suite.addTest(new WebProjectValidation13("testNewSegment"));
106: suite.addTest(new WebProjectValidation13("testNewDocument"));
107: suite.addTest(new WebProjectValidation13("testStopServer"));
108: suite.addTest(new WebProjectValidation13("testStartServer"));
109: suite.addTest(new WebProjectValidation13("testFinish"));
110: return suite;
111: }
112:
113: /** Test creation of web project.
114: * - open New Project wizard from main menu (File|New Project)
115: * - select Web|Web Application
116: * - in the next panel type project name and project location
117: * - finish the wizard
118: * - wait until scanning of java files is finished
119: * - check index.jsp is opened
120: */
121: @Override
122: public void testNewWebProject() throws IOException {
123: installJemmyQueue();
124: new NewProjectAction().perform();
125: NewProjectWizardOperator projectWizard = new NewProjectWizardOperator();
126: String sWeb = Bundle.getStringTrimmed(
127: "org.netbeans.modules.web.core.Bundle",
128: "Templates/JSP_Servlet");
129: projectWizard.selectCategory(sWeb);
130: String sWeb_Application = Bundle.getStringTrimmed(
131: "org.netbeans.modules.web.project.ui.wizards.Bundle",
132: "Templates/Project/Web/emptyWeb.xml");
133: projectWizard.selectProject(sWeb_Application);
134: projectWizard.next();
135: NewWebProjectNameLocationStepOperator nameStep = new NewWebProjectNameLocationStepOperator();
136: nameStep.txtProjectName().setText("");
137: nameStep.txtProjectName().typeText(PROJECT_NAME);
138: nameStep.txtProjectLocation().setText("");
139: nameStep.txtProjectLocation().typeText(PROJECT_LOCATION);
140: String sJ2EE_1_3 = Bundle.getStringTrimmed(
141: "org.netbeans.modules.web.project.ui.wizards.Bundle",
142: "J2EESpecLevel_13");
143: nameStep.selectJ2EEVersion(sJ2EE_1_3);
144: nameStep.finish();
145: Timeouts timeouts = nameStep.getTimeouts().cloneThis();
146: nameStep.getTimeouts().setTimeout(
147: "ComponentOperator.WaitStateTimeout", 60000);
148: nameStep.waitClosed();
149: nameStep.setTimeouts(timeouts);
150: // wait for project creation
151: sleep(5000);
152: ProjectSupport.waitScanFinished();
153: // wait for project creation
154: new EditorWindowOperator().getEditor("index.jsp");//NOI18N
155: // HACK
156: Node webPages = new Node(new ProjectsTabOperator()
157: .getProjectRootNode(PROJECT_NAME), "Web Pages");
158: new Node(webPages, "index.jsp");//NOI18N
159: new Node(webPages, "WEB-INF|web.xml");//NOI18N
160: new Node(webPages, "META-INF|context.xml");//NOI18N
161: ref(Util.dumpProjectView(PROJECT_NAME));
162: compareReferenceFiles();
163: }
164:
165: @Override
166: protected String getTagHandlerCode() {
167: return "try { JspWriter out = pageContext.getOut();\n out.print(\"TagOutput\");\n} catch (java.io.IOException e) {} \n";
168: }
169:
170: @Override
171: public void testCreateTagHandler() {
172: // workaround due to issue #46073
173: new ProjectsTabOperator().getProjectRootNode(PROJECT_NAME)
174: .select();
175:
176: new ActionNoBlock("File|New File", null).perform();
177: // WORKAROUND
178: new EventTool().waitNoEvent(1000);
179: WizardOperator newFileWizard = new WizardOperator("New File");
180: new JComboBoxOperator(newFileWizard).selectItem(PROJECT_NAME);
181: new Node(new JTreeOperator(newFileWizard), "Web").select();
182: new JListOperator(newFileWizard, 1).selectItem("Tag Handler");
183: newFileWizard.next();
184: JTextFieldOperator txtName = new JTextFieldOperator(
185: newFileWizard);
186: // clear text field
187: txtName.setText("");
188: txtName.typeText("MyTag");
189: JComboBoxOperator pkg = new JComboBoxOperator(newFileWizard, 1);
190: pkg.clearText();
191: pkg.typeText("tags");
192: newFileWizard.next();
193: new JButtonOperator(newFileWizard).push();
194: NbDialogOperator dialog = new NbDialogOperator("Browse Files");
195: new Node(new JTreeOperator(dialog),
196: "Web Pages|WEB-INF|tlds|MyTags.tld").select();
197: new JButtonOperator(dialog, "Select File").push();
198: newFileWizard.finish();
199: // HACK
200: new Node(phelper.getSourceNode(), "tags|MyTag.java");
201: // check class is opened in Editor and then close it
202: EditorOperator editor = new EditorOperator("MyTag.java");
203: editor
204: .replace(
205: "// TODO: code that performs other operations in doStartTag",
206: getTagHandlerCode());
207: editor.saveDocument();
208: editor.close();
209: ref(Util.dumpProjectView(PROJECT_NAME));
210: //compareReferenceFiles();
211: }
212: }
|