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: package org.netbeans.jellytools;
042:
043: import junit.framework.Test;
044: import junit.framework.TestSuite;
045: import junit.textui.TestRunner;
046: import org.netbeans.junit.NbTestSuite;
047:
048: /**
049: * Test of org.netbeans.jellytools.NewProjectWizardOperator.
050: * @author tb115823
051: */
052: public class NewProjectWizardOperatorTest extends JellyTestCase {
053:
054: public static NewProjectWizardOperator op;
055: // "Java Application"
056: private static final String javaApplicationLabel = Bundle
057: .getString(
058: "org.netbeans.modules.java.j2seproject.ui.wizards.Bundle",
059: "Templates/Project/Standard/emptyJ2SE.xml");
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 NewProjectWizardOperatorTest(
074: "testInvokeTitle"));
075: suite.addTest(new NewProjectWizardOperatorTest("testInvoke"));
076: suite.addTest(new NewProjectWizardOperatorTest(
077: "testSelectCategoryAndProject"));
078: suite.addTest(new NewProjectWizardOperatorTest("testVerify"));
079: suite.addTest(new NewProjectWizardOperatorTest(
080: "testGetDescription"));
081: return suite;
082: }
083:
084: protected void setUp() {
085: System.out.println("### " + getName() + " ###");
086: }
087:
088: /** Constructor required by JUnit.
089: * @param testName method name to be used as testcase
090: */
091: public NewProjectWizardOperatorTest(String testName) {
092: super (testName);
093: }
094:
095: /** Test of invoke method with title parameter. Opens new wizard, waits for the dialog and closes it. */
096: public void testInvokeTitle() {
097: // "New Project"
098: String title = Bundle.getString(
099: "org.netbeans.modules.project.ui.Bundle",
100: "LBL_NewProjectWizard_Title");
101: op = NewProjectWizardOperator.invoke(title);
102: op.close();
103: }
104:
105: /** Test of invoke method. Opens new wizard and waits for the dialog. */
106: public void testInvoke() {
107: op = NewProjectWizardOperator.invoke();
108: }
109:
110: /** Test of methods selectCategory and selectProject. */
111: public void testSelectCategoryAndProject() {
112: // Standard
113: String standardLabel = Bundle
114: .getString(
115: "org.netbeans.modules.java.j2seproject.ui.wizards.Bundle",
116: "Templates/Project/Standard");
117: op.selectCategory(standardLabel);
118: op.selectProject(javaApplicationLabel);
119: }
120:
121: /** Test of verify method. */
122: public void testVerify() {
123: op.verify();
124: }
125:
126: /** Test of getDescription method. */
127: public void testGetDescription() {
128: assertTrue("Wrong description.", op.getDescription().indexOf(
129: "Java SE application") > 0);
130: op.cancel();
131: }
132: }
|