KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > web > WebProjectValidation13


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 org.netbeans.test.web;
21
22 import java.io.File JavaDoc;
23 import java.io.IOException JavaDoc;
24 import org.netbeans.jellytools.*;
25 import org.netbeans.jellytools.actions.NewProjectAction;
26 import org.netbeans.jellytools.nodes.Node;
27 import org.netbeans.jemmy.QueueTool;
28 import org.netbeans.jemmy.Timeouts;
29 import org.netbeans.junit.NbTestSuite;
30 import org.netbeans.junit.ide.ProjectSupport;
31
32 /**
33  *
34  * @author lm97939
35  */

36 public class WebProjectValidation13 extends WebProjectValidation {
37     static {
38         PROJECT_NAME = "SampleProject13"; // NOI18N
39
PROJECT_FOLDER = PROJECT_LOCATION+File.separator+PROJECT_NAME;
40     }
41
42     /** Need to be defined because of JUnit */
43     public WebProjectValidation13(String JavaDoc name) {
44         super(name);
45     }
46     
47     /** Use for execution inside IDE */
48     public static void main(java.lang.String JavaDoc[] args) {
49         // run whole suite
50
junit.textui.TestRunner.run(suite());
51         // run only selected test case
52
//junit.textui.TestRunner.run(new MyModuleValidation("testT2"));
53
}
54     
55     public static NbTestSuite suite() {
56         NbTestSuite suite = new NbTestSuite();
57         suite.addTest(new WebProjectValidation13("testNewWebProject"));
58         suite.addTest(new WebProjectValidation13("testNewJSP"));
59         suite.addTest(new WebProjectValidation13("testNewJSP2"));
60         suite.addTest(new WebProjectValidation13("testNewServlet"));
61         suite.addTest(new WebProjectValidation13("testNewServlet2"));
62         suite.addTest(new WebProjectValidation13("testBuildProject"));
63         suite.addTest(new WebProjectValidation13("testCompileAllJSP"));
64         suite.addTest(new WebProjectValidation13("testCompileJSP"));
65         suite.addTest(new WebProjectValidation13("testCleanProject"));
66         suite.addTest(new WebProjectValidation13("testRunProject"));
67         suite.addTest(new WebProjectValidation13("testRunJSP"));
68         suite.addTest(new WebProjectValidation13("testRunServlet"));
69         suite.addTest(new WebProjectValidation13("testCreateTLD"));
70         suite.addTest(new WebProjectValidation13("testCreateTagHandler"));
71         suite.addTest(new WebProjectValidation13("testRunTag"));
72         suite.addTest(new WebProjectValidation13("testNewHTML"));
73         suite.addTest(new WebProjectValidation13("testRunHTML"));
74         suite.addTest(new WebProjectValidation13("testNewSegment"));
75         suite.addTest(new WebProjectValidation13("testNewDocument"));
76         suite.addTest(new WebProjectValidation13("testStopTomcat"));
77         suite.addTest(new WebProjectValidation13("testStartTomcat"));
78         suite.addTest(new WebProjectValidation13("testFinish"));
79         
80         return suite;
81     }
82     
83     /** Test creation of web project.
84      * - open New Project wizard from main menu (File|New Project)
85      * - select Web|Web Application
86      * - in the next panel type project name and project location
87      * - finish the wizard
88      * - wait until scanning of java files is finished
89      * - check index.jsp is opened
90      */

91     public void testNewWebProject() throws IOException JavaDoc {
92         installJemmyQueue();
93         new NewProjectAction().perform();
94         NewProjectWizardOperator projectWizard = new NewProjectWizardOperator();
95         String JavaDoc sWeb = Bundle.getStringTrimmed(
96                 "org.netbeans.modules.web.core.Bundle",
97                 "Templates/JSP_Servlet");
98         projectWizard.selectCategory(sWeb);
99         String JavaDoc sWeb_Application = Bundle.getStringTrimmed(
100                 "org.netbeans.modules.web.project.ui.wizards.Bundle",
101                 "Templates/Project/Web/emptyWeb.xml");
102         projectWizard.selectProject(sWeb_Application);
103         projectWizard.next();
104         NewWebProjectNameLocationStepOperator nameStep =
105                 new NewWebProjectNameLocationStepOperator();
106         nameStep.txtProjectName().setText("");
107         nameStep.txtProjectName().typeText(PROJECT_NAME);
108         nameStep.txtProjectLocation().setText("");
109         nameStep.txtProjectLocation().typeText(PROJECT_LOCATION);
110         String JavaDoc sJ2EE_1_3 = Bundle.getStringTrimmed(
111                 "org.netbeans.modules.web.project.ui.wizards.Bundle",
112                 "J2EESpecLevel_13");
113         nameStep.selectJ2EEVersion(sJ2EE_1_3);
114         nameStep.finish();
115         Timeouts timeouts = nameStep.getTimeouts().cloneThis();
116         nameStep.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 60000);
117         nameStep.waitClosed();
118         nameStep.setTimeouts(timeouts);
119         // wait for project creation
120
sleep(5000);
121         ProjectSupport.waitScanFinished();
122         // wait for project creation
123
new EditorWindowOperator().getEditor("index.jsp");//NOI18N
124
// HACK
125
Node webPages = new Node(new ProjectsTabOperator().
126                 getProjectRootNode(PROJECT_NAME),"Web Pages");
127         new Node(webPages,"index.jsp");//NOI18N
128
new Node(webPages,"WEB-INF|web.xml");//NOI18N
129
new Node(webPages,"META-INF|context.xml");//NOI18N
130
ref(Util.dumpProjectView(PROJECT_NAME));
131         compareReferenceFiles();
132     }
133     
134     protected String JavaDoc getTagHandlerCode() {
135         return "try { JspWriter out = pageContext.getOut(); " +
136                 "out.print(\"TagOutput\");} catch (IOException e) {} \n";
137     }
138 }
139
Popular Tags