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-2006 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: package org.netbeans.jellytools;
042:
043: import java.io.File;
044: import java.io.IOException;
045: import junit.framework.Test;
046: import junit.framework.TestSuite;
047: import junit.textui.TestRunner;
048: import org.netbeans.jellytools.nodes.Node;
049: import org.netbeans.jemmy.JemmyException;
050: import org.netbeans.junit.NbTestSuite;
051: import org.netbeans.jemmy.operators.JComboBoxOperator;
052: import org.netbeans.jellytools.NbDialogOperator;
053:
054: /**
055: * Test of org.netbeans.jellytools.NameLocationStepOperator.
056: * @author tb115823
057: */
058: public class NewProjectNameLocationStepOperatorTest extends
059: JellyTestCase {
060:
061: /** Use for internal test execution inside IDE
062: * @param args command line arguments
063: */
064: public static void main(java.lang.String[] args) {
065: TestRunner.run(suite());
066: }
067:
068: /** Method used for explicit testsuite definition
069: * @return created suite
070: */
071: public static Test suite() {
072: TestSuite suite = new NbTestSuite();
073: suite.addTest(new NewProjectNameLocationStepOperatorTest(
074: "testJavaApplicationPanel"));
075: suite.addTest(new NewProjectNameLocationStepOperatorTest(
076: "testJavaAntProjectPanel"));
077: suite.addTest(new NewProjectNameLocationStepOperatorTest(
078: "testJavaLibraryPanel"));
079: suite.addTest(new NewProjectNameLocationStepOperatorTest(
080: "testJavaWithExistingSourcesPanel"));
081: suite.addTest(new NewProjectNameLocationStepOperatorTest(
082: "testWebApplication"));
083: return suite;
084: }
085:
086: protected void setUp() {
087: System.out.println("### " + getName() + " ###");
088: }
089:
090: /** Constructor required by JUnit.
091: * @param testName method name to be used as testcase
092: */
093: public NewProjectNameLocationStepOperatorTest(String testName) {
094: super (testName);
095: }
096:
097: // Standard
098: private static final String standardLabel = Bundle.getString(
099: "org.netbeans.modules.java.j2seproject.ui.wizards.Bundle",
100: "Templates/Project/Standard");
101:
102: /** Test components on Java Application panel */
103: public void testJavaApplicationPanel() {
104: NewProjectWizardOperator op = NewProjectWizardOperator.invoke();
105: // Standard
106: op.selectCategory(standardLabel);
107: // Java Application
108: op
109: .selectProject(Bundle
110: .getString(
111: "org.netbeans.modules.java.j2seproject.ui.wizards.Bundle",
112: "Templates/Project/Standard/emptyJ2SE.xml"));
113: op.next();
114: NewProjectNameLocationStepOperator stpop = new NewProjectNameLocationStepOperator();
115: stpop.txtProjectName().setText("NewProject"); // NOI18N
116: stpop.btBrowseProjectLocation().pushNoBlock();
117: new NbDialogOperator("Select").cancel(); //TODO I18N
118: stpop.txtProjectLocation().setText("/tmp");
119: stpop.txtProjectFolder().getText();
120: stpop.cbCreateMainClass().setSelected(false);
121: stpop.cbSetAsMainProject().setSelected(false);
122:
123: stpop.cancel();
124: }
125:
126: /** Test components on Java Ant Project panel */
127: public void testJavaAntProjectPanel() {
128: NewProjectWizardOperator op = NewProjectWizardOperator.invoke();
129: op.selectCategory(standardLabel);
130: // Java Project with Existing Ant Script
131: op.selectProject(Bundle.getString(
132: "org.netbeans.modules.java.freeform.resources.Bundle",
133: "Templates/Project/Standard/j2sefreeform.xml"));
134: op.next();
135: NewProjectNameLocationStepOperator stpop = new NewProjectNameLocationStepOperator();
136: stpop.txtLocation().setText("/tmp");
137: stpop.txtBuildScript().setText("/path/to/antscript");//TODO I18N
138: stpop.txtProjectName().setText("ant project");//TODO I18N
139: stpop.txtProjectFolder().setText("/ant/folder");//TODO I18N
140: stpop.cbSetAsMainProject().setSelected(true);
141: stpop.btBrowseLocation().pushNoBlock();
142: new NbDialogOperator("Browse Existing Ant Project Folder")
143: .cancel();//TODO I18N
144: stpop.btBrowseBuildScript().pushNoBlock();
145: new NbDialogOperator("Browse Existing Ant Build Script")
146: .cancel();//TODO I18N
147: stpop.btBrowseProjectFolder().pushNoBlock();
148: new NbDialogOperator("Browse New Project Folder").cancel();//TODO I18N
149: stpop.cancel();
150: }
151:
152: /** Test component on Java Library */
153: public void testJavaLibraryPanel() {
154: NewProjectWizardOperator op = NewProjectWizardOperator.invoke();
155: op.selectCategory(standardLabel);
156: // Java Class Library
157: op
158: .selectProject(Bundle
159: .getString(
160: "org.netbeans.modules.java.j2seproject.ui.wizards.Bundle",
161: "Templates/Project/Standard/emptyJ2SElibrary.xml"));
162: op.next();
163: NewProjectNameLocationStepOperator stpop = new NewProjectNameLocationStepOperator();
164: stpop.txtProjectLocation().setText("/tmp");
165: stpop.txtProjectName().setText("NewLibraryProject");
166: stpop.txtProjectFolder().getText();
167: stpop.btBrowseProjectLocation().pushNoBlock();
168: new NbDialogOperator("Select Project Location").cancel(); //TODO I18N
169: stpop.cancel();
170: }
171:
172: public void testJavaWithExistingSourcesPanel() {
173: NewProjectWizardOperator op = NewProjectWizardOperator.invoke();
174: op.selectCategory(standardLabel);
175: // "Java Project with Existing Sources"
176: op
177: .selectProject(Bundle
178: .getString(
179: "org.netbeans.modules.java.j2seproject.ui.wizards.Bundle",
180: "Templates/Project/Standard/existingJ2SE.xml"));
181: op.next();
182:
183: NewProjectNameLocationStepOperator stpop = new NewProjectNameLocationStepOperator();
184: stpop.txtProjectName().setText("MyNewProject");
185: stpop.txtProjectFolder().setText("D:\\tmp");
186: stpop.txtProjectFolder().getText();
187: stpop.cbSetAsMainProject().setSelected(false);
188: stpop.btBrowseProjectLocation().pushNoBlock();
189: new NbDialogOperator("Select Project Location").cancel(); //TODO I18N
190: stpop.cancel();
191: }
192:
193: public void testWebApplication() {
194: NewProjectWizardOperator op = NewProjectWizardOperator.invoke();
195: // Web
196: String webLabel = Bundle.getString(
197: "org.netbeans.modules.web.core.Bundle",
198: "Templates/JSP_Servlet");
199: op.selectCategory(webLabel);
200: // Web Application
201: String webApplicationLabel = Bundle.getString(
202: "org.netbeans.modules.web.project.ui.wizards.Bundle",
203: "Templates/Project/Web/emptyWeb.xml");
204: op.selectProject(webApplicationLabel);
205: op.next();
206:
207: NewWebProjectNameLocationStepOperator stpop = new NewWebProjectNameLocationStepOperator();
208: stpop.txtProjectName().setText("NewProject");
209: stpop.btBrowseProjectLocation().pushNoBlock();
210: new NbDialogOperator("Select Project Location").cancel(); //TODO I18N
211: stpop.txtProjectLocation().setText("/tmp");//TODO I18N
212: stpop.txtProjectFolder().getText();
213: stpop.cbSetAsMainProject().setSelected(false);
214: assertEquals(stpop.txtContextPath().getText(), "/NewProject"); //NOI18N
215: stpop.selectJ2EEVersion("J2EE 1.4"); // NOI18N
216: stpop.cancel();
217: }
218: }
|