KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gui > action > CreateNewFile


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 gui.action;
21
22 import gui.Utils;
23 import org.netbeans.jellytools.EditorOperator;
24 import org.netbeans.jellytools.MainWindowOperator;
25 import org.netbeans.jellytools.NbDialogOperator;
26 import org.netbeans.jellytools.NewFileWizardOperator;
27 import org.netbeans.jellytools.ProjectsTabOperator;
28 import org.netbeans.jellytools.TopComponentOperator;
29 import org.netbeans.jellytools.actions.NewFileAction;
30 import org.netbeans.jellytools.actions.OpenAction;
31 import org.netbeans.jellytools.nodes.Node;
32
33 import org.netbeans.jemmy.operators.ComponentOperator;
34 import org.netbeans.jemmy.operators.JComboBoxOperator;
35 import org.netbeans.jemmy.operators.JMenuBarOperator;
36 import org.netbeans.jemmy.operators.JTextFieldOperator;
37
38
39 /**
40  * Test of Open File Dialog
41  *
42  * @author lmartinek@netbeans.org
43  */

44 public class CreateNewFile extends org.netbeans.performance.test.utilities.PerformanceTestCase {
45     
46     private NewFileWizardOperator wizard;
47     
48     private String JavaDoc project;
49     private String JavaDoc category;
50     private String JavaDoc fileType;
51     private String JavaDoc fileName;
52     private String JavaDoc packageName;
53     
54     /**
55      * Creates a new instance of CreateNewFile
56      */

57     public CreateNewFile(String JavaDoc testName) {
58         super(testName);
59         expectedTime = 5000;
60     }
61     
62     /**
63      * Creates a new instance of CreateNewFile
64      */

65     public CreateNewFile(String JavaDoc testName, String JavaDoc performanceDataName) {
66         super(testName,performanceDataName);
67         expectedTime = 5000;
68     }
69     
70     public void testCreateNewSessionBean() {
71         WAIT_AFTER_OPEN = 10000;
72         project = "TestApplication-ejb";
73         category = "Enterprise";
74         fileType = "Session Bean";
75         fileName = "NewTestSession";
76         packageName = "test.newfiles";
77         doMeasurement();
78     }
79     
80     public void testCreateNewEntityBean() {
81         WAIT_AFTER_OPEN = 10000;
82         project = "TestApplication-ejb";
83         category = "Enterprise";
84         fileType = "Entity Bean";
85         fileName = "NewTestEntity";
86         packageName = "test.newfiles";
87         doMeasurement();
88     }
89     
90     public void testCreateNewWebService() {
91         WAIT_AFTER_OPEN = 10000;
92         project = "TestApplication-ejb";
93         category = "Web Services";
94         fileType = "Web Service";
95         fileName = "NewTestWebService";
96         packageName = "test.newfiles";
97         doMeasurement();
98     }
99      
100     public void initialize() {
101         new OpenAction().performAPI(new Node(new ProjectsTabOperator().getProjectRootNode("TestApplication-EJBModule"), "Source Packages|test|TestSessionRemote.java"));
102     }
103     
104     public void shutdown() {
105         new EditorOperator("TestSessionRemote.java").closeDiscard();
106     }
107     
108     public void prepare() {
109         // do nothing
110
gui.Utilities.workarroundMainMenuRolledUp();
111         new NewFileAction().performMenu();
112         wizard = new NewFileWizardOperator();
113         wizard.selectProject(project);
114         wizard.selectCategory(category);
115         wizard.selectFileType(fileType);
116         wizard.next();
117         new JTextFieldOperator(wizard).setText(fileName+Utils.getTimeIndex());
118         new JComboBoxOperator(wizard,1).clearText();
119         new JComboBoxOperator(wizard,1).typeText(packageName);
120     }
121
122     public ComponentOperator open() {
123         wizard.finish();
124         return new EditorOperator(fileName);
125     }
126     
127     public void close() {
128         if (testedComponentOperator != null){
129             ((EditorOperator)testedComponentOperator).save();
130             ((EditorOperator)testedComponentOperator).close();
131         }
132     }
133     
134 }
135
Popular Tags