KickJava   Java API By Example, From Geeks To Geeks.

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


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.ActionNoBlock;
26 import org.netbeans.jellytools.actions.NewProjectAction;
27 import org.netbeans.jellytools.nodes.Node;
28 import org.netbeans.jellytools.nodes.SourcePackagesNode;
29 import org.netbeans.jemmy.EventTool;
30 import org.netbeans.jemmy.QueueTool;
31 import org.netbeans.jemmy.Timeouts;
32 import org.netbeans.jemmy.operators.*;
33 import org.netbeans.junit.NbTestSuite;
34 import org.netbeans.junit.ide.ProjectSupport;
35
36 /**
37  *
38  * @author lm97939
39  */

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

96     public void testNewWebProject() throws IOException JavaDoc {
97         installJemmyQueue();
98         new NewProjectAction().perform();
99         NewProjectWizardOperator projectWizard = new NewProjectWizardOperator();
100         projectWizard.selectCategory("Web");
101         projectWizard.selectProject("Web Application with Existing Sources");
102         projectWizard.next();
103         NewWebProjectNameLocationStepOperator
104                 nameStep = new NewWebProjectNameLocationStepOperator();
105         nameStep.txtLocation().setText(getDataDir().getAbsolutePath()+
106                 File.separator+PROJECT_NAME);
107         nameStep.txtProjectName().setText(PROJECT_NAME);
108         nameStep.txtProjectFolder().setText(System.getProperty("xtest.data")+
109                 File.separator+PROJECT_NAME+"Prj");
110         nameStep.next();
111         NewWebProjectSourcesStepOperator srcStep =
112                 new NewWebProjectSourcesStepOperator();
113         srcStep.finish();
114         Timeouts timeouts = nameStep.getTimeouts().cloneThis();
115         srcStep.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 90000);
116         srcStep.waitClosed();
117         srcStep.setTimeouts(timeouts);
118         sleep(5000);
119         // wait for project creation
120
ProjectSupport.waitScanFinished();
121         //new EditorWindowOperator().getEditor("index.jsp");
122
// HACK
123
Node webPages = new Node(new ProjectsTabOperator().
124                 getProjectRootNode(PROJECT_NAME),"Web Pages");
125         //new Node(webPages,"index.jsp");
126
new Node(webPages,"WEB-INF|web.xml");
127         new Node(webPages,"META-INF|context.xml");
128         new Node(webPages,"WEB-INF|classes|dummy");
129         new Node(webPages,"WEB-INF|lib|dummy");
130         new Node(new SourcePackagesNode(PROJECT_NAME),
131                 "<default package>|dummy");
132         ref(Util.dumpProjectView(PROJECT_NAME));
133         compareReferenceFiles();
134         //compareDD();
135
}
136     
137     /** Test new JSP wizard.
138      * - open New File wizard from main menu (File|New File)
139      * - select sample project as target
140      * - select Web|JSP file type
141      * - in the next panel type name
142      * - finish the wizard
143      * - check file is open in editor and close all opened documents
144      */

145     public void testNewJSP() throws IOException JavaDoc {
146         // workaround due to issue #46073
147
new ProjectsTabOperator().getProjectRootNode(PROJECT_NAME).select();
148         
149         new ActionNoBlock("File|New File", null).perform();
150         // WORKAROUND
151
new EventTool().waitNoEvent(1000);
152         WizardOperator newFileWizard = new WizardOperator("New File");
153         new JComboBoxOperator(newFileWizard).selectItem(PROJECT_NAME);
154         // workaround due to issue #46007
155
new Node(new JTreeOperator(newFileWizard), "Java Classes").select();
156         new Node(new JTreeOperator(newFileWizard), "Web").select();
157         new JListOperator(newFileWizard, 1).selectItem("JSP");
158         newFileWizard.next();
159         JTextFieldOperator txtPackageName = new JTextFieldOperator(newFileWizard);
160         // clear text field
161
//XXX <workaround issue='#61034 - wrond default destination'>
162
txtPackageName.setText("index");
163         JTextFieldOperator txtProjectFolder = new JTextFieldOperator(
164                 newFileWizard, 2);
165         txtProjectFolder.setText("");
166         //</workaround>
167
newFileWizard.finish();
168         // check class is opened in Editor and then close it
169
new EditorOperator("index.jsp").close();
170         ref(Util.dumpProjectView(PROJECT_NAME));
171         new Node(new ProjectsTabOperator().getProjectRootNode(PROJECT_NAME),"Web Pages|index.jsp");
172         //compareReferenceFiles();
173
//compareDD();
174
}
175     
176     
177     
178 }
179
Popular Tags