Source Code Cross Referenced for ProfilerValidation.java in  » IDE-Netbeans » ide » org » netbeans » test » profiler » 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.profiler 
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-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.test.profiler;
042:
043:        import junit.textui.TestRunner;
044:        import org.netbeans.jellytools.Bundle;
045:        import org.netbeans.jellytools.JellyTestCase;
046:        import org.netbeans.jellytools.MainWindowOperator;
047:        import org.netbeans.jellytools.NbDialogOperator;
048:        import org.netbeans.jellytools.NewProjectNameLocationStepOperator;
049:        import org.netbeans.jellytools.NewProjectWizardOperator;
050:        import org.netbeans.jellytools.OptionsOperator;
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.ProjectRootNode;
057:        import org.netbeans.jemmy.JemmyProperties;
058:        import org.netbeans.jemmy.TimeoutExpiredException;
059:        import org.netbeans.jemmy.Waitable;
060:        import org.netbeans.jemmy.Waiter;
061:        import org.netbeans.jemmy.operators.JButtonOperator;
062:        import org.netbeans.jemmy.operators.JCheckBoxOperator;
063:        import org.netbeans.jemmy.operators.JComboBoxOperator;
064:        import org.netbeans.jemmy.operators.JLabelOperator;
065:        import org.netbeans.jemmy.operators.JRadioButtonOperator;
066:        import org.netbeans.jemmy.operators.JTabbedPaneOperator;
067:        import org.netbeans.junit.NbTestSuite;
068:        import org.netbeans.junit.ide.ProjectSupport;
069:
070:        /** Validation test of profiler.
071:         *
072:         * @author Alexandr Scherbatiy, Jiri Skrivanek
073:         */
074:        public class ProfilerValidation extends JellyTestCase {
075:
076:            private static final String SAMPLE_PROJECT_NAME = "AnagramGame";
077:
078:            protected static final String MENU_ITEM_PROFILE_MAIN_PROJECT = "Profile Main Project...";
079:            protected static final String MENU_ITEM_ATTACH_PROFILE = "Attach Profiler...";
080:            protected static final String MENU_ITEM_TAKE_SNAPSHOT = "Take Snapshot of Collected Results";
081:            protected static final String MENU_ITEM_STOP_PROFILING_SESSION = "Stop Profiling Session";
082:
083:            protected static final String LABEL_JAVA_PLATFORM = "Profiler Java Platform";
084:            protected static final String LABEL_COMMUNICATION_PORT = "Communication Port";
085:
086:            protected static final String LABEL_OPEN_THREADS_VIEW = "Open Threads View";
087:            protected static final String LABEL_CPU = "CPU";
088:            protected static final String LABEL_MEMORY = "Memory";
089:
090:            protected static final String LABEL_OPEN_NEW_SNAPSHOT = "Open New Snapshot";
091:
092:            protected static final String LABEL_SAVE_HEAP_DUMP = "Save heap dump to";
093:            protected static final String LABEL_ENABLE_HEAP_ANALYSIS = "Enable Rule-Based Heap Analysis";
094:
095:            protected static final String BUTTON_RUN = "Run";
096:            protected static final String BUTTON_RESET = "Reset";
097:
098:            protected static final String TEXT_OUTPUT = "Established local connection with the tool";
099:
100:            /** Default constructor.
101:             * @param name test case name
102:             */
103:            public ProfilerValidation(String name) {
104:                super (name);
105:            }
106:
107:            /** Defaine order of test cases.
108:             * @return NbTestSuite instance
109:             */
110:            public static NbTestSuite suite() {
111:                NbTestSuite suite = new NbTestSuite();
112:                suite.addTest(new ProfilerValidation("testProfilerMenus"));
113:                suite.addTest(new ProfilerValidation("testProfilerProperties"));
114:                //suite.addTest(new ProfilerValidation("testCreateProject"));
115:                //suite.addTest(new ProfilerValidation("testProfiler"));
116:                return suite;
117:            }
118:
119:            /** Use for execution inside IDE */
120:            public static void main(java.lang.String[] args) {
121:                // run whole suite
122:                TestRunner.run(suite());
123:                // run only selected test case
124:                //TestRunner.run(new ProfilerValidation("testProfiler"));
125:            }
126:
127:            /** Setup before every test case. */
128:            public void setUp() {
129:                System.out.println("########  " + getName() + "  #######");
130:            }
131:
132:            /** Test Profiler Menus. */
133:            public void testProfilerMenus() {
134:
135:                new ActionNoBlock("Profile|" + MENU_ITEM_PROFILE_MAIN_PROJECT,
136:                        null).isEnabled();
137:                new ActionNoBlock("Profile|" + MENU_ITEM_ATTACH_PROFILE, null)
138:                        .isEnabled();
139:                new ActionNoBlock("Profile|" + MENU_ITEM_TAKE_SNAPSHOT, null)
140:                        .isEnabled();
141:                new ActionNoBlock(
142:                        "Profile|" + MENU_ITEM_STOP_PROFILING_SESSION, null)
143:                        .isEnabled();
144:
145:            }
146:
147:            /** Test Profiler Properties. */
148:            public void testProfilerProperties() {
149:                new ActionNoBlock("Tools|Options", null).perform();
150:
151:                OptionsOperator options = new OptionsOperator();
152:                options.selectCategory("Miscellaneous");
153:
154:                JTabbedPaneOperator tabbedPane = new JTabbedPaneOperator(
155:                        options);
156:                tabbedPane.selectPage("Profiler");
157:
158:                JLabelOperator javaPlatform = new JLabelOperator(options,
159:                        LABEL_JAVA_PLATFORM);
160:
161:                JLabelOperator communicationPort = new JLabelOperator(options,
162:                        LABEL_COMMUNICATION_PORT);
163:
164:                JLabelOperator openThreads = new JLabelOperator(options,
165:                        LABEL_OPEN_THREADS_VIEW);
166:                JCheckBoxOperator cpu = new JCheckBoxOperator(options,
167:                        LABEL_CPU);
168:                JCheckBoxOperator memory = new JCheckBoxOperator(options,
169:                        LABEL_MEMORY);
170:
171:                JComboBoxOperator openNewSnapshot = new JComboBoxOperator(
172:                        options, LABEL_OPEN_NEW_SNAPSHOT);
173:
174:                JCheckBoxOperator enableHeapAnalisys = new JCheckBoxOperator(
175:                        options, LABEL_ENABLE_HEAP_ANALYSIS);
176:
177:                JButtonOperator reset = new JButtonOperator(options,
178:                        BUTTON_RESET);
179:
180:                new JButtonOperator(options, "OK").push();
181:
182:            }
183:
184:            /** Create project to be tested. */
185:            public void testCreateProject() {
186:                NewProjectWizardOperator npwo = NewProjectWizardOperator
187:                        .invoke();
188:                npwo.selectCategory("Samples|Java");
189:                npwo.selectProject("Anagram Game");
190:                npwo.next();
191:                NewProjectNameLocationStepOperator npnlso = new NewProjectNameLocationStepOperator();
192:                npnlso.txtProjectLocation().setText(
193:                        System.getProperty("netbeans.user")); // NOI18N
194:                npnlso.btFinish().pushNoBlock();
195:                npnlso.getTimeouts().setTimeout(
196:                        "ComponentOperator.WaitStateTimeout", 120000);
197:                npnlso.waitClosed();
198:                // Opening Projects
199:                String openingProjectsTitle = Bundle.getString(
200:                        "org.netbeans.modules.project.ui.Bundle",
201:                        "LBL_Opening_Projects_Progress");
202:                waitProgressDialog(openingProjectsTitle, 120000);
203:                // wait project appear in projects view
204:                ProjectRootNode projectNode = new ProjectsTabOperator()
205:                        .getProjectRootNode(SAMPLE_PROJECT_NAME);
206:                // wait classpath scanning finished
207:                ProjectSupport.waitScanFinished();
208:                projectNode.buildProject();
209:                MainWindowOperator.getDefault().waitStatusText(
210:                        "Finished Building");
211:
212:            }
213:
214:            /** Test profiler
215:             * - run profiler calibration Profile|Advanced Commands|Run Profiler Calibration
216:             * - wait for calibration results and confirm information dialog
217:             * - call Profile|Profile Main Project
218:             * - confirm changes in project when profiled for the first time
219:             * - click Run in Profile AnagramGame dialog
220:             * - wait for Profiler view
221:             * - wait until text "Established local connection with the tool" appears in output window
222:             * - wait until "Profile|Take Snapshot of Collected Results" is enabled
223:             * - call Profile|Take Snapshot of Collected Results
224:             * - maximaze results view
225:             * - save collected results
226:             * - call "Profile|Stop Profiling Session"
227:             */
228:            public void testProfiler() throws Exception {
229:                new ActionNoBlock(
230:                        "Profile|Advanced Commands|Run Profiler Calibration",
231:                        null).perform();
232:                new NbDialogOperator("Select Java Platform to calibrate").ok();
233:                // increase timeout for calibration
234:                JemmyProperties.setCurrentTimeout(
235:                        "DialogWaiter.WaitDialogTimeout", 120000); // NOI18N
236:                new NbDialogOperator("Information").ok();
237:                new ActionNoBlock("Profile|Profile Main Project", null)
238:                        .perform();
239:                new NbDialogOperator("Question").ok();
240:                NbDialogOperator profileOper = new NbDialogOperator("Profile "
241:                        + SAMPLE_PROJECT_NAME);
242:                new JButtonOperator(profileOper, "Run").push();
243:                profileOper.waitClosed();
244:                waitProgressDialog("Progress", 5000);
245:                new TopComponentOperator("Profiler");
246:                new OutputTabOperator(SAMPLE_PROJECT_NAME)
247:                        .waitText("Established local connection with the tool");
248:                Action takeSnapshotAction = new Action(
249:                        "Profile|Take Snapshot of Collected Results", null);
250:                new Waiter(new Waitable() {
251:                    public Object actionProduced(Object takeSnapshotAction) {
252:                        return ((Action) takeSnapshotAction).isEnabled() ? Boolean.TRUE
253:                                : null;
254:                    }
255:
256:                    public String getDescription() {
257:                        return ("Wait menu item enabled."); // NOI18N
258:                    }
259:                }).waitAction(takeSnapshotAction);
260:                takeSnapshotAction.perform();
261:                TopComponentOperator collectedResults = new TopComponentOperator(
262:                        "CPU");
263:                //collectedResults.maximize();
264:                collectedResults.saveDocument();
265:                new Action("Profile|Stop Profiling Session", null).perform();
266:            }
267:
268:            public void waitProgressDialog(String title, int milliseconds) {
269:                try {
270:                    // wait at most 120 second until progress dialog dismiss
271:                    NbDialogOperator openingOper = new NbDialogOperator(title);
272:                    openingOper.getTimeouts().setTimeout(
273:                            "ComponentOperator.WaitStateTimeout", milliseconds);
274:                    openingOper.waitClosed();
275:                } catch (TimeoutExpiredException e) {
276:                    // ignore when progress dialog was closed before we started to wait for it
277:                }
278:            }
279:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.