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.jellytools.actions.DeleteAction;
047: import org.netbeans.jellytools.nodes.Node;
048: import org.netbeans.jellytools.nodes.SourcePackagesNode;
049: import org.netbeans.junit.NbTestSuite;
050: import org.netbeans.jemmy.operators.JComboBoxOperator;
051:
052: /**
053: * Test of org.netbeans.jellytools.NewFileWizardOperator.
054: * @author tb115823
055: */
056: public class NewFileWizardOperatorTest extends JellyTestCase {
057:
058: public static NewFileWizardOperator op;
059:
060: /** Use for internal test execution inside IDE
061: * @param args command line arguments
062: */
063: public static void main(java.lang.String[] args) {
064: TestRunner.run(suite());
065: }
066:
067: /** Method used for explicit testsuite definition
068: * @return created suite
069: */
070: public static Test suite() {
071: TestSuite suite = new NbTestSuite();
072: suite.addTest(new NewFileWizardOperatorTest("testInvokeTitle"));
073: suite.addTest(new NewFileWizardOperatorTest("testInvoke"));
074: suite.addTest(new NewFileWizardOperatorTest(
075: "testSelectProjectAndCategoryAndFileType"));
076: suite.addTest(new NewFileWizardOperatorTest(
077: "testGetDescription"));
078: suite.addTest(new NewFileWizardOperatorTest("testCreate"));
079: return suite;
080: }
081:
082: protected void setUp() {
083: System.out.println("### " + getName() + " ###");
084: }
085:
086: /** Constructor required by JUnit.
087: * @param testName method name to be used as testcase
088: */
089: public NewFileWizardOperatorTest(String testName) {
090: super (testName);
091: }
092:
093: /** Test of invoke method with title parameter. Opens New File wizard, waits for the dialog and closes it. */
094: public void testInvokeTitle() {
095: // "New File"
096: String title = Bundle.getString(
097: "org.netbeans.modules.project.ui.Bundle",
098: "LBL_NewFileWizard_Title");
099: op = NewFileWizardOperator.invoke(title);
100: op.close();
101: }
102:
103: /** Test of invoke method. Opens New File wizard and waits for the dialog. */
104: public void testInvoke() {
105: op = NewFileWizardOperator.invoke();
106: }
107:
108: /** Test components on New File Wizard panel
109: * sets category and filetype
110: */
111: public void testSelectProjectAndCategoryAndFileType() {
112: JComboBoxOperator cbo = op.cboProject();
113: cbo.selectItem(0);
114: // Java Classes
115: op.selectCategory(Bundle.getString(
116: "org.netbeans.modules.java.project.Bundle",
117: "Templates/Classes"));
118: // Java Class
119: op.selectFileType(Bundle.getString(
120: "org.netbeans.modules.java.project.Bundle",
121: "Templates/Classes/Class.java"));
122: }
123:
124: /** Test description component on New File Wizard panel
125: * gets description of selected filetype
126: */
127: public void testGetDescription() {
128: assertTrue("Description should contain Java class sub string.",
129: op.getDescription().indexOf("Java class") > 0);
130: op.cancel();
131: }
132:
133: public void testCreate() {
134: // Java Classes
135: String javaClassesLabel = Bundle.getString(
136: "org.netbeans.modules.java.project.Bundle",
137: "Templates/Classes");
138: // Java Class
139: String javaClassLabel = Bundle.getString(
140: "org.netbeans.modules.java.project.Bundle",
141: "Templates/Classes/Class.java");
142: NewFileWizardOperator.create("SampleProject", javaClassesLabel,
143: javaClassLabel, "sample1", "TempClass"); // NOI18N
144: Node classNode = new Node(new SourcePackagesNode(
145: "SampleProject"), "sample1|TempClass"); // NOI18N
146: DeleteAction deleteAction = new DeleteAction();
147: deleteAction.perform(classNode);
148: // "Safe Delete"
149: String safeDeleteTitle = Bundle.getString(
150: "org.netbeans.modules.refactoring.spi.impl.Bundle",
151: "LBL_SafeDel"); // NOI18N
152: new NbDialogOperator(safeDeleteTitle).ok();
153: }
154: }
|