Source Code Cross Referenced for NewProjectFileTest.java in  » IDE-Netbeans » mobility » org » netbeans » test » mobility » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » mobility » org.netbeans.test.mobility 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:
042:        package org.netbeans.test.mobility;
043:
044:        import java.io.File;
045:        import java.io.IOException;
046:        import java.util.HashSet;
047:        import javax.swing.JDialog;
048:        import org.netbeans.jellytools.Bundle;
049:        import org.netbeans.jellytools.EditorOperator;
050:        import org.netbeans.jellytools.MainWindowOperator;
051:        import org.netbeans.jellytools.NewProjectWizardOperator;
052:        import org.netbeans.jellytools.nodes.Node;
053:        import org.netbeans.jellytools.properties.PropertySheetOperator;
054:        import org.netbeans.jemmy.operators.DialogOperator;
055:        import org.netbeans.jemmy.operators.JButtonOperator;
056:        import org.netbeans.jemmy.operators.JMenuBarOperator;
057:        import org.netbeans.jemmy.operators.JTextFieldOperator;
058:        import org.netbeans.jemmy.operators.JTreeOperator;
059:        import org.netbeans.junit.NbTestSuite;
060:        import org.netbeans.jellytools.JellyTestCase;
061:        import org.netbeans.jellytools.NbDialogOperator;
062:        import org.netbeans.jellytools.NewFileNameLocationStepOperator;
063:        import org.netbeans.jellytools.NewFileWizardOperator;
064:        import org.netbeans.jellytools.NewProjectNameLocationStepOperator;
065:        import org.netbeans.jellytools.ProjectsTabOperator;
066:        import org.netbeans.jellytools.TopComponentOperator;
067:        import org.netbeans.jellytools.actions.CompileAction;
068:        import org.netbeans.jellytools.nodes.SourcePackagesNode;
069:        import org.netbeans.jemmy.operators.JDialogOperator;
070:
071:        //import org.netbeans.jemmy.operators.JToggleButtonOperator;
072:        /**
073:         */
074:        public class NewProjectFileTest extends JellyTestCase {
075:
076:            public static final String ITEM_VISUALMIDLET = Bundle
077:                    .getStringTrimmed(
078:                            "org.netbeans.modules.vmd.midp.resources.Bundle",
079:                            "Templates/MIDP/VisualMIDlet.java");
080:            public static final String ITEM_MIDLET = Bundle.getStringTrimmed(
081:                    "org.netbeans.modules.mobility.project.ui.wizard.Bundle",
082:                    "Templates/MIDP/Midlet.java");
083:            public static final String ITEM_MIDPCANVAS = Bundle
084:                    .getStringTrimmed(
085:                            "org.netbeans.modules.mobility.project.ui.wizard.Bundle",
086:                            "Templates/MIDP/MIDPCanvas.java");
087:            public static final String ITEM_LOCALIZATIONSUPPORTCLASS = "Localization Support Class";
088:            //public static final String ITEM_HELLOVISUALMIDLET = "Hello Visual Midlet"; //template removed
089:
090:            public static final String CATEGORY_MIDP = Bundle.getStringTrimmed(
091:                    "org.netbeans.modules.mobility.project.ui.wizard.Bundle",
092:                    "Templates/MIDP");
093:            public static final String CATEGORY_CDC = "CDC"; //TODO I18N
094:
095:            public static final String PROJECT_MOBILE_APP = Bundle
096:                    .getStringTrimmed(
097:                            "org.netbeans.modules.mobility.project.ui.wizard.Bundle",
098:                            "Templates/Project/J2ME/MobileApplication");
099:            public static final String PROJECT_CDC_APP = "CDC Application";//Bundle.getStringTrimmed("org.netbeans.modules.mobility.project.ui.wizard.Bundle", "Templates/Project/J2ME/MobileApplication");
100:
101:            public static final HashSet disabledNodes = new HashSet();
102:            private static String projectDirectory;
103:
104:            public static final String SAMPLE_MOBILE_PROJECT = "SampleMobileApplication";
105:            public static final String PROJECT_TO_BE_CREATED = "NewCreatedMobileProject";
106:            public static final String PROJECT_TO_BE_CLOSED = "ProjectToBeClosedMobile";
107:            public static final String PROJECT_TO_BE_OPENED = "OpenMobileProject";
108:            public static final String PROJECT_FOR_NEW_FILES = "CreateNewFilesMobile";
109:            public static final String PROJECT_OPENED = "MobileApplicationVisualMIDlet";
110:
111:            public NewProjectFileTest(String name) {
112:                super (name);
113:            }
114:
115:            /*
116:            public static NbTestSuite suite() {
117:                NbTestSuite suite = new NbTestSuite();
118:                //suite.addTest(new NewProjectFileTest("testNewProject"));//TODO can be used only when a J2ME platform is available
119:                suite.addTest(new NewProjectFileTest("testCreateNewFiles"));
120:                suite.addTest(new NewProjectFileTest("testOpenProject"));
121:                suite.addTest(new NewProjectFileTest("testCloseProject")); //must be last. It close the SampleMobileApplication project that is used in other tests.
122:                return suite;
123:            }
124:             */
125:
126:            /** Use for execution inside IDE */
127:            public static void main(java.lang.String[] args) {
128:
129:                junit.textui.TestRunner.run(new NewProjectFileTest(
130:                        "testCreateNewMIDPFilesValidation"));
131:            }
132:
133:            public void setUp() {
134:                System.out.println("########  " + getName() + "  #######");
135:            }
136:
137:            public void tearDown() {
138:            }
139:
140:            public void testNewProject() throws IOException {
141:                //TODO it's necessary to have a J2ME platform to be able create Mobile Project
142:                //TODO we need a fake platform that can be used even when the mobility pack is built from sources and no regular platform is available
143:                createNewProject(PROJECT_MOBILE_APP, PROJECT_TO_BE_CREATED);
144:                // wait project appear in projects view
145:                new ProjectsTabOperator()
146:                        .getProjectRootNode(PROJECT_TO_BE_CREATED);
147:            }
148:
149:            public String createNewFile(String category, String template,
150:                    String name, String packageName) {
151:                NewFileWizardOperator newFile = NewFileWizardOperator.invoke();
152:                newFile.selectCategory(category);
153:                newFile.selectFileType(template);
154:                newFile.next();
155:                NewFileNameLocationStepOperator op = new NewFileNameLocationStepOperator();
156:                op.setObjectName(name); //TODO doesn't work with New > MIDP Canvas. It doesn;t change the name
157:                if (packageName != null)
158:                    op.setPackage(packageName);
159:                String fileLocation = op.txtCreatedFile().getText();
160:                op.finish();
161:                return fileLocation;
162:            }
163:
164:            public String createNewProject(String projectType,
165:                    String projectName) {
166:                MainWindowOperator mainWindow = MainWindowOperator.getDefault();
167:                NewProjectWizardOperator npwop = NewProjectWizardOperator
168:                        .invoke();
169:                npwop
170:                        .selectCategory(Bundle
171:                                .getStringTrimmed(
172:                                        "org.netbeans.modules.mobility.project.ui.wizard.Bundle",
173:                                        "Templates/Project/J2ME"));
174:                npwop.selectProject(projectType);
175:                npwop.next();
176:                NewProjectNameLocationStepOperator step = new NewProjectNameLocationStepOperator();
177:                step.txtProjectLocation().setText(getWorkDirPath());
178:                step.txtProjectName().setText(projectName);//NOI18N
179:                String projectLocation = step.txtProjectFolder().getText();
180:                sleep(1000);
181:                step.finish();
182:                return projectLocation;
183:            }
184:
185:            public void testCloseProject() {
186:                //EditorOperator.closeDiscardAll();
187:                //select projects tab
188:                ProjectsTabOperator pto = ProjectsTabOperator.invoke();
189:                JTreeOperator tree = pto.tree();
190:                //select the project node
191:                Node projectNode = pto.getProjectRootNode(PROJECT_TO_BE_CLOSED);
192:                projectNode.select();
193:                //close it
194:                projectNode.performPopupAction("Close Project"); //TODO - I18N - get it from bundle
195:                //check that project is closed
196:                pto.getProjectRootNode(PROJECT_TO_BE_CLOSED);
197:
198:            }
199:
200:            public void testOpenProject() throws IOException {
201:                MainWindowOperator mainWindow = MainWindowOperator.getDefault();
202:                mainWindow.getToolbarButton(mainWindow.getToolbar("File"),
203:                        "Open Project").push();//TODO I18N
204:
205:                DialogOperator dia = new DialogOperator("Open Project"); //TODO I18N
206:                JTextFieldOperator text = new JTextFieldOperator(dia, 1);
207:                text.setText(getDataDir().getPath() + File.separator
208:                        + PROJECT_TO_BE_OPENED);
209:                new JButtonOperator(dia, "Open Project Folder").push();//TODO I18N
210:                sleep(2000);
211:                JDialog resolveDialog = NbDialogOperator.findJDialog(
212:                        "Open Project", true, true);//TODO I18N
213:                if (resolveDialog != null) {
214:                    new JButtonOperator(new JDialogOperator(resolveDialog),
215:                            "Close").push();//TODO I18N
216:                }
217:
218:                JMenuBarOperator menubar = mainWindow.menuBar();
219:
220:                ProjectsTabOperator pto = ProjectsTabOperator.invoke();
221:
222:                // get the tree if needed
223:                JTreeOperator tree = pto.tree();
224:
225:                // Open HelloMidlet and Inspector
226:                Node projectNode = pto
227:                        .getProjectRootNode("MobileApplication|hello|HelloMidlet.java");
228:                projectNode.select();
229:                projectNode.performPopupActionNoBlock("Open");
230:                sleep(2000);
231:
232:                new PropertySheetOperator().close();
233:                EditorOperator.closeDiscardAll();
234:
235:            }
236:
237:            public void testCreateNewFiles() {
238:                //select the project in project view
239:                new ProjectsTabOperator().getProjectRootNode(
240:                        PROJECT_FOR_NEW_FILES).select();
241:                //create all new files in the project
242:                createNewFile(CATEGORY_MIDP, ITEM_VISUALMIDLET,
243:                        "NewVisualMidlet", "myPackage"); // NOI18N
244:                createNewFile(CATEGORY_MIDP, ITEM_MIDLET, "NewMIDlet",
245:                        "myPackage"); // NOI18N
246:                createNewFile(CATEGORY_MIDP, ITEM_MIDPCANVAS, "MIDPCanvas",
247:                        "myPackage"); // NOI18N
248:
249:                //test that files are created and opened in editor
250:                new TopComponentOperator("NewVisualMidlet.java").close(); // NOI18N
251:                new EditorOperator("NewMIDlet.java").close(); // NOI18N
252:                new EditorOperator("MIDPCanvas.java").close(); // NOI18N    
253:
254:            }
255:
256:            public void testCreateNewMobileApplication() {
257:                //by default is the "Create HelloMidlet" checked when creating new project 
258:                String projectName = "NewMobileApplication"; // NOI18N
259:                //create
260:                String location = createNewProject(PROJECT_MOBILE_APP,
261:                        projectName);
262:                System.out.println("project created : " + location); // NOI18N
263:                //check
264:                new ProjectsTabOperator().getProjectRootNode(projectName);
265:            }
266:
267:            public void testCreateNewCDCApplication() {
268:                String projectName = "NewCDCApplication"; // NOI18N
269:                //create
270:                String location = createNewProject(PROJECT_CDC_APP, projectName);
271:                System.out.println("project created : " + location); // NOI18N
272:                //check
273:                new ProjectsTabOperator().getProjectRootNode(projectName);
274:            }
275:
276:            ////------------------------------------- validation --------------
277:
278:            public void testCreateNewMIDPFilesValidation() {
279:                //select the project in project view
280:                new ProjectsTabOperator().getProjectRootNode(
281:                        "NewMobileApplication").select(); // NOI18N
282:                //create all new files in the project
283:
284:                createNewFile(CATEGORY_MIDP, ITEM_MIDLET, "NewMIDlet",
285:                        "validation"); // NOI18N
286:                createNewFile(CATEGORY_MIDP, ITEM_MIDPCANVAS, "NewMIDPCanvas",
287:                        "validation"); // NOI18N
288:                createNewFile(CATEGORY_MIDP, ITEM_VISUALMIDLET,
289:                        "NewVisualMidlet", "validation"); // NOI18N
290:
291:                //test that files are created and opened in editor
292:                new EditorOperator("NewMIDlet.java").close(); // NOI18N
293:                new EditorOperator("MIDPCanvas.java").close(); // NOI18N  //TODO: workaround for unchanged canvas name
294:                new TopComponentOperator("NewVisualMidlet.java").close(); // NOI18N //TODO: seems that this doesn't work :(
295:            }
296:
297:            public void testCompileMobileMIDPProject() {
298:                // start to track Main Window status bar
299:                MainWindowOperator.StatusTextTracer stt = MainWindowOperator
300:                        .getDefault().getStatusTextTracer();
301:                stt.start();
302:                // call Build on project node
303:                new ProjectsTabOperator().getProjectRootNode(
304:                        "NewMobileApplication").buildProject(); // NOI18N
305:
306:                // wait message "Building NewMobileApplication (compile-single)..."
307:                stt.waitText("Building", true); // NOI18N
308:                // wait message "Finished building NewMobileApplication (compile-single)"
309:                stt.waitText("Finished building", true); // NOI18N
310:                stt.stop();
311:            }
312:
313:            ////---------------------------------------------------------------
314:            public void testCreateNewMIDPCanvas() {
315:                //select the project in project view
316:                new ProjectsTabOperator().getProjectRootNode(
317:                        "NewMobileApplication").select(); // NOI18N
318:                //create new Canvas in the project
319:
320:                createNewFile(CATEGORY_MIDP, ITEM_MIDPCANVAS, "NewMIDPCanvas",
321:                        "validation"); // NOI18N
322:
323:                //test that files are created and opened in editor
324:                new EditorOperator("NewMIDPCanvas.java").close(); // NOI18N
325:            }
326:
327:            public void testCreateNewProjectIssue95668() {
328:                String projectName = PROJECT_TO_BE_CREATED
329:                        + System.currentTimeMillis();
330:                System.out.println("creating project " + projectName); // NOI18N
331:                System.out.println("project created "
332:                        + createNewProject(PROJECT_MOBILE_APP, projectName)); // NOI18N
333:                for (int i = 0; i < 50; i++) {
334:                    new ProjectsTabOperator().getProjectRootNode(projectName)
335:                            .select();
336:                    createNewFile(CATEGORY_MIDP, ITEM_VISUALMIDLET, "file" + i,
337:                            "issue95668"); // NOI18N
338:                }
339:            }
340:
341:            //        public void testCreateNewProjectIssue95668() {
342:            //        String projectName = PROJECT_TO_BE_CREATED + System.currentTimeMillis() ;
343:            //        System.out.println("creating project " + projectName);
344:            //        System.out.println("project created " + createNewProject(projectName));
345:            //        for(int i=0;i<50;i++) {
346:            //           new ProjectsTabOperator().getProjectRootNode(projectName).select();
347:            //           createNewFile(ITEM_VISUALMIDLET, "file"+i);
348:            //        }
349:            //    }
350:
351:            public void testVMClosesImmediatellyIssue101539() {
352:                createNewProject(PROJECT_MOBILE_APP, "issue101539"); // NOI18N
353:                for (int i = 0; i < 20; i++) {
354:                    createNewFile(CATEGORY_MIDP, ITEM_VISUALMIDLET,
355:                            "issue101539_" + i, "testing"); // NOI18N
356:                }
357:                //EditorOperator.
358:            }
359:
360:            public void sleep(int millis) {
361:                try {
362:                    Thread.sleep(millis);
363:                } catch (InterruptedException ex) {
364:                    ex.printStackTrace();
365:                }
366:            }
367:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.