Source Code Cross Referenced for RubyValidation.java in  » IDE-Netbeans » ide » org » netbeans » test » ruby » 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 » ide » org.netbeans.test.ruby 
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-2008 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.test.ruby;
042:
043:        import javax.swing.JTextField;
044:        import junit.textui.TestRunner;
045:        import org.netbeans.jellytools.Bundle;
046:        import org.netbeans.jellytools.EditorOperator;
047:        import org.netbeans.jellytools.JellyTestCase;
048:        import org.netbeans.jellytools.NbDialogOperator;
049:        import org.netbeans.jellytools.NewProjectNameLocationStepOperator;
050:        import org.netbeans.jellytools.NewProjectWizardOperator;
051:        import org.netbeans.jellytools.OutputTabOperator;
052:        import org.netbeans.jellytools.ProjectsTabOperator;
053:        import org.netbeans.jellytools.TopComponentOperator;
054:        import org.netbeans.jellytools.actions.Action;
055:        import org.netbeans.jellytools.actions.ActionNoBlock;
056:        import org.netbeans.jellytools.nodes.Node;
057:        import org.netbeans.jellytools.nodes.ProjectRootNode;
058:
059:        import org.netbeans.jemmy.JemmyProperties;
060:        import org.netbeans.jemmy.operators.JLabelOperator;
061:        import org.netbeans.jemmy.operators.JTextFieldOperator;
062:
063:        import org.netbeans.junit.NbTestSuite;
064:        import org.netbeans.junit.ide.ProjectSupport;
065:
066:        /**
067:         * Overall validation suite for ruby cluster.
068:         *
069:         * @author Jiri.Skrivanek@sun.com
070:         */
071:        public class RubyValidation extends JellyTestCase {
072:
073:            /** Need to be defined because of JUnit */
074:            public RubyValidation(String name) {
075:                super (name);
076:            }
077:
078:            public static NbTestSuite suite() {
079:                NbTestSuite suite = new NbTestSuite();
080:                suite.addTest(new RubyValidation("testCreateRubyProject"));
081:                suite.addTest(new RubyValidation("testRunRubyFile"));
082:                suite.addTest(new RubyValidation("testCreateRailsProject"));
083:                suite.addTest(new RubyValidation("testRailsGenerate"));
084:                suite.addTest(new RubyValidation("testIrbShell"));
085:                return suite;
086:            }
087:
088:            /** Use for execution inside IDE */
089:            public static void main(java.lang.String[] args) {
090:                // run whole suite
091:                TestRunner.run(suite());
092:                // run only selected test case
093:                //junit.textui.TestRunner.run(new RubyValidation("testCreateRubyProject"));
094:            }
095:
096:            /** Setup before every test case. */
097:            @Override
098:            public void setUp() {
099:                System.out.println("########  " + getName() + "  #######");
100:            }
101:
102:            /** Teardown after every test case. */
103:            @Override
104:            public void tearDown() {
105:            }
106:
107:            // name of sample projects
108:            private static final String SAMPLE_RUBY_PROJECT_NAME = "SampleRubyApplication"; //NOI18N
109:            private static final String SAMPLE_RAILS_PROJECT_NAME = "SampleRailsApplication"; //NOI18N
110:
111:            /** Test IRB shell
112:             * - open IRB shell window 
113:             * - close it
114:             */
115:            public void testIrbShell() throws Exception {
116:                String rubyproject_packagename = "org.netbeans.modules.ruby.rubyproject.Bundle";
117:                String irb_action = Bundle.getStringTrimmed(
118:                        rubyproject_packagename, "CTL_IrbAction");
119:                String irb_TC = Bundle.getString(rubyproject_packagename,
120:                        "CTL_IrbTopComponent");
121:                new Action("Window|Other|" + irb_action, null).perform(); //NOI18N
122:                TopComponentOperator tco = new TopComponentOperator(irb_TC);
123:                tco.close();
124:            }
125:
126:            /** Test Ruby Application
127:             * - open new project wizard
128:             * - choose Ruby|Ruby Application
129:             * - click Next
130:             * - type name and location and finish the wizard
131:             * - wait until project is in Projects view
132:             * - wait classpath scanning finished
133:             */
134:            public void testCreateRubyProject() {
135:                // create new web application project
136:                NewProjectWizardOperator npwo = NewProjectWizardOperator
137:                        .invoke();
138:                // "Ruby"
139:                String rubyLabel = Bundle
140:                        .getString(
141:                                "org.netbeans.modules.ruby.rubyproject.ui.wizards.Bundle",
142:                                "Templates/Project/Ruby");
143:                npwo.selectCategory(rubyLabel);
144:                // "Ruby Application"
145:                String rubyApplicationLabel = Bundle
146:                        .getString(
147:                                "org.netbeans.modules.ruby.rubyproject.ui.wizards.Bundle",
148:                                "TXT_NewJavaApp");
149:                npwo.selectProject(rubyApplicationLabel);
150:                npwo.next();
151:                NewProjectNameLocationStepOperator npnlso = new NewProjectNameLocationStepOperator();
152:                npnlso.txtProjectName().setText(SAMPLE_RUBY_PROJECT_NAME);
153:                npnlso.txtProjectLocation().setText(
154:                        System.getProperty("netbeans.user")); // NOI18N
155:                npnlso.finish();
156:                // wait project appear in projects view
157:                // wait 30 second
158:                JemmyProperties.setCurrentTimeout(
159:                        "JTreeOperator.WaitNextNodeTimeout", 30000); // NOI18N
160:                new ProjectsTabOperator()
161:                        .getProjectRootNode(SAMPLE_RUBY_PROJECT_NAME);
162:                // wait classpath scanning finished
163:                ProjectSupport.waitScanFinished();
164:            }
165:
166:            /** Test run Ruby file
167:             * - find main.rb in editor
168:             * - call "Run File" popup action in editor
169:             * - wait for main.rb output tab
170:             * - check "Hello World" is printed out
171:             */
172:            public void testRunRubyFile() {
173:                // wait main.rb is opened in editor
174:                EditorOperator editor = new EditorOperator("main.rb"); // NOI18N
175:                // "Run File"
176:                String runFileItem = Bundle.getStringTrimmed(
177:                        "org.netbeans.modules.project.ui.actions.Bundle",
178:                        "LBL_RunSingleAction_Name", new Integer[] { 0 });
179:                // call "Run File" in editor
180:                new Action(null, runFileItem).perform(editor);
181:                // check message in output tab
182:                new OutputTabOperator("main.rb").waitText("Hello World"); // NOI18N
183:            }
184:
185:            /** Test Ruby on Rails Application
186:             * - create new Ruby on Rails Application project
187:             * - wait until project is in Projects view
188:             * - wait classpath scanning finished
189:             */
190:            public void testCreateRailsProject() {
191:                // create new web application project
192:                NewProjectWizardOperator npwo = NewProjectWizardOperator
193:                        .invoke();
194:                // "Ruby"
195:                String rubyLabel = Bundle
196:                        .getString(
197:                                "org.netbeans.modules.ruby.rubyproject.ui.wizards.Bundle",
198:                                "Templates/Project/Ruby");
199:                npwo.selectCategory(rubyLabel);
200:                // "Ruby on Rails Application"
201:                String railsApplicationLabel = Bundle
202:                        .getString(
203:                                "org.netbeans.modules.ruby.railsprojects.ui.wizards.Bundle",
204:                                "Templates/Project/Ruby/railsApp.xml");
205:                npwo.selectProject(railsApplicationLabel);
206:                npwo.next();
207:                NewProjectNameLocationStepOperator npnlso = new NewProjectNameLocationStepOperator();
208:                npnlso.txtProjectName().setText(SAMPLE_RAILS_PROJECT_NAME);
209:                npnlso.txtProjectLocation().setText(
210:                        System.getProperty("netbeans.user")); // NOI18N
211:                npnlso.finish();
212:                // wait project appear in projects view
213:                // wait 30 second
214:                JemmyProperties.setCurrentTimeout(
215:                        "JTreeOperator.WaitNextNodeTimeout", 30000); // NOI18N
216:                new ProjectsTabOperator()
217:                        .getProjectRootNode(SAMPLE_RAILS_PROJECT_NAME);
218:                // wait classpath scanning finished
219:                ProjectSupport.waitScanFinished();
220:            }
221:
222:            /** Test Rails Generator
223:             * - call "Generate..." action on project node
224:             * - wait for Rails Generator dialog
225:             * - type "myapp" in Name text field
226:             * - type "myview" in Views: text field
227:             * - click OK button in dialog
228:             * - check files myapp_controller.rb, myapp_helper.rb, myview.rhtml, 
229:             * myapp_controller_test.rb are opened in editor and available in Projects view
230:             */
231:            public void testRailsGenerate() {
232:                ProjectRootNode projectRootNode = new ProjectsTabOperator()
233:                        .getProjectRootNode(SAMPLE_RAILS_PROJECT_NAME);
234:
235:                // "Generate..."
236:                String generateItem = Bundle.getStringTrimmed(
237:                        "org.netbeans.modules.ruby.railsprojects.Bundle",
238:                        "rails-generator");
239:                new ActionNoBlock(null, generateItem).perform(projectRootNode);
240:                // "Rails Generator"
241:                String generatorTitle = Bundle.getStringTrimmed(
242:                        "org.netbeans.modules.ruby.railsprojects.Bundle",
243:                        "RailsGenerator");
244:                NbDialogOperator generatorOper = new NbDialogOperator(
245:                        generatorTitle);
246:                // "Name:"
247:                String nameLabel = Bundle.getStringTrimmed(
248:                        "org.netbeans.modules.ruby.railsprojects.Bundle",
249:                        "Name");
250:                JTextFieldOperator nameOper = new JTextFieldOperator(
251:                        (JTextField) new JLabelOperator(generatorOper,
252:                                nameLabel).getLabelFor());
253:                nameOper.setText("myapp"); // NOI18N
254:                // "Views:"
255:                String viewsTextFieldLabel = Bundle.getStringTrimmed(
256:                        "org.netbeans.modules.ruby.railsprojects.Bundle",
257:                        "Views");
258:                JTextFieldOperator viewsOper = new JTextFieldOperator(
259:                        (JTextField) new JLabelOperator(generatorOper,
260:                                viewsTextFieldLabel).getLabelFor());
261:                viewsOper.setText("myview");
262:                generatorOper.ok();
263:
264:                // wait 60 second
265:                JemmyProperties.setCurrentTimeout(
266:                        "ComponentOperator.WaitComponentTimeout", 60000);
267:
268:                String filename = "myapp_controller.rb"; // NOI18N
269:                new EditorOperator(filename);
270:                // "Controllers"
271:                String controllersLabel = Bundle.getString(
272:                        "org.netbeans.modules.ruby.railsprojects.Bundle",
273:                        "app_controllers");
274:                new Node(projectRootNode, controllersLabel + "|" + filename);
275:
276:                filename = "myapp_helper.rb"; // NOI18N
277:                new EditorOperator(filename);
278:                // "Helpers"
279:                String helpersLabel = Bundle.getString(
280:                        "org.netbeans.modules.ruby.railsprojects.Bundle",
281:                        "app_helpers");
282:                new Node(projectRootNode, helpersLabel + "|" + filename);
283:
284:                filename = "myview.html.erb"; // NOI18N
285:                new EditorOperator(filename);
286:                // "Views"
287:                String viewsLabel = Bundle.getString(
288:                        "org.netbeans.modules.ruby.railsprojects.Bundle",
289:                        "app_views");
290:                new Node(projectRootNode, viewsLabel + "|myapp|" + filename);
291:
292:                filename = "myapp_controller_test.rb"; // NOI18N
293:                new EditorOperator(filename);
294:                // "Functional Tests"
295:                String functionalTestsLabel = Bundle.getString(
296:                        "org.netbeans.modules.ruby.railsprojects.Bundle",
297:                        "test_functional");
298:                new Node(projectRootNode, functionalTestsLabel + "|" + filename);
299:            }
300:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.