Source Code Cross Referenced for PrepareIDEForWebPackComplexMeasurements.java in  » IDE-Netbeans » performance » prepare » 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 » performance » prepare 
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:
042:        package prepare;
043:
044:        import java.util.ArrayList;
045:
046:        import junit.framework.Test;
047:        import junit.framework.TestSuite;
048:
049:        import org.netbeans.jellytools.Bundle;
050:        import org.netbeans.jellytools.MainWindowOperator;
051:        import org.netbeans.jellytools.ProjectsTabOperator;
052:        import org.netbeans.jellytools.TopComponentOperator;
053:        import org.netbeans.jellytools.actions.CloseAllDocumentsAction;
054:        import org.netbeans.jellytools.actions.OpenAction;
055:        import org.netbeans.jellytools.actions.Action;
056:        import org.netbeans.jellytools.nodes.Node;
057:        import org.netbeans.jellytools.nodes.ProjectRootNode;
058:
059:        import org.netbeans.jemmy.operators.JCheckBoxOperator;
060:        import org.netbeans.jemmy.operators.JMenuBarOperator;
061:        import org.netbeans.jemmy.operators.JMenuItemOperator;
062:        import org.netbeans.jemmy.operators.Operator;
063:
064:        import org.netbeans.junit.NbTestSuite;
065:
066:        import org.netbeans.performance.test.utilities.MeasureStartupTimeTestCase;
067:
068:        /**
069:         *
070:         * Prepare user directory for complex measurements (startup time and memory consumption) of IDE with opened VWP project.
071:         * Open Visual Web pack project (HugeApp) and shut down ide.
072:         * Created user directory will be used to measure startup time and memory consumption of IDE with opened files.*
073:         *
074:         * @author mkhramov@netbeans.org, mmirilovic@netbeans.org
075:         */
076:        public class PrepareIDEForWebPackComplexMeasurements extends
077:                org.netbeans.jellytools.JellyTestCase {
078:
079:            /** If true - at least one test failed */
080:            protected static boolean test_failed = false;
081:
082:            /** Error output from the test. */
083:            protected static java.io.PrintStream err;
084:
085:            /** Logging output from the test. */
086:            protected static java.io.PrintStream log;
087:
088:            /**
089:             * Creates a new instance of PrepareIDEForWebPackComplexMeasurements
090:             */
091:            public PrepareIDEForWebPackComplexMeasurements(String testName) {
092:                super (testName);
093:            }
094:
095:            /** Testsuite
096:             * @return testuite
097:             */
098:            public static Test suite() {
099:                TestSuite suite = new NbTestSuite();
100:                suite.addTest(new PrepareIDEForWebPackComplexMeasurements(
101:                        "closeWelcome"));
102:                suite.addTest(new PrepareIDEForWebPackComplexMeasurements(
103:                        "closeAllDocuments"));
104:                suite.addTest(new PrepareIDEForWebPackComplexMeasurements(
105:                        "closeMemoryToolbar"));
106:                suite.addTest(new PrepareIDEForWebPackComplexMeasurements(
107:                        "openFiles"));
108:                suite.addTest(new PrepareIDEForWebPackComplexMeasurements(
109:                        "saveStatus"));
110:                return suite;
111:            }
112:
113:            @Override
114:            public void setUp() {
115:                //        err = System.out;
116:                err = getLog();
117:                log = getRef();
118:            }
119:
120:            /**
121:             * Close Welcome.
122:             */
123:            public void closeWelcome() {
124:                try {
125:                    String TCOName = Bundle.getStringTrimmed(
126:                            "org.netbeans.modules.welcome.Bundle",
127:                            "LBL_Tab_Title");
128:                    TopComponentOperator tComponent = new TopComponentOperator(
129:                            "Start Page");
130:                    new JCheckBoxOperator(tComponent, Bundle.getStringTrimmed(
131:                            "org.netbeans.modules.welcome.resources.Bundle",
132:                            "LBL_ShowOnStartup")).changeSelection(false);
133:                    tComponent.close();
134:                } catch (Exception exc) {
135:                    test_failed = true;
136:                    fail(exc);
137:                }
138:            }
139:
140:            /**
141:             * Close All Documents.
142:             */
143:            public void closeAllDocuments() {
144:
145:                if (new Action("Window|Close All Documents", null).isEnabled())
146:                    try {
147:                        new CloseAllDocumentsAction().perform();
148:                    } catch (Exception exc) {
149:                        test_failed = true;
150:                        fail(exc);
151:                    }
152:            }
153:
154:            /**
155:             * Close Memory Toolbar.
156:             */
157:            public static void closeMemoryToolbar() {
158:                closeToolbar(Bundle.getStringTrimmed(
159:                        "org.netbeans.core.Bundle", "Menu/View")
160:                        + "|"
161:                        + Bundle.getStringTrimmed(
162:                                "org.netbeans.core.windows.actions.Bundle",
163:                                "CTL_ToolbarsListAction")
164:                        + "|"
165:                        + Bundle.getStringTrimmed("org.netbeans.core.Bundle",
166:                                "Toolbars/Memory"));
167:            }
168:
169:            private static void closeToolbar(String menu) {
170:                MainWindowOperator mainWindow = MainWindowOperator.getDefault();
171:                JMenuBarOperator menuBar = new JMenuBarOperator(mainWindow
172:                        .getJMenuBar());
173:                JMenuItemOperator menuItem = menuBar.showMenuItem(menu, "|");
174:
175:                if (menuItem.isSelected())
176:                    menuItem.push();
177:                else {
178:                    menuItem.pushKey(java.awt.event.KeyEvent.VK_ESCAPE);
179:                    mainWindow.pushKey(java.awt.event.KeyEvent.VK_ESCAPE);
180:                }
181:            }
182:
183:            /**
184:             * Open 10 selected files from Travel Reservation projects
185:             */
186:            public void openFiles() {
187:                String OPEN = "Open";
188:                String EDIT = "Edit";
189:
190:                try {
191:                    String[][] nodes_path = { { "Web Pages", "Page1.jsp",
192:                            "Page1", OPEN }
193:                    // TODO - NPE rises for CSS see IZ 101567                ,{"Web Pages|resources","stylesheet.css", null, OPEN},
194:                    };
195:
196:                    ArrayList<Node> openFileNodes = new ArrayList<Node>();
197:                    ArrayList<Node> editFileNodes = new ArrayList<Node>();
198:                    Node node, fileNode;
199:
200:                    // create exactly (full match) and case sensitively comparing comparator
201:                    Operator.DefaultStringComparator comparator = new Operator.DefaultStringComparator(
202:                            true, true);
203:
204:                    ProjectRootNode projectNode = new ProjectsTabOperator()
205:                            .getProjectRootNode("HugeApp");
206:                    projectNode.expand();
207:
208:                    for (int i = 0; i < nodes_path.length; i++) {
209:                        // try to workarround problems with tooltip on Win2K & WinXP - issue 56825
210:
211:                        node = new Node(projectNode, nodes_path[i][0]);
212:                        node.setComparator(comparator);
213:                        node.expand();
214:
215:                        fileNode = new Node(node, nodes_path[i][1]);
216:                        //try to avoid issue 56825
217:                        fileNode.select();
218:
219:                        if (nodes_path[i][3].equals(OPEN)) {
220:                            openFileNodes.add(fileNode);
221:                        } else if (nodes_path[i][3].equals(EDIT)) {
222:                            editFileNodes.add(fileNode);
223:                        } else
224:                            throw new Exception("Not supported operation ["
225:                                    + nodes_path[i][3] + "] for node: "
226:                                    + fileNode.getPath());
227:
228:                        // open file one by one, opening all files at once causes never ending loop (java+mdr)
229:                        //new OpenAction().performAPI(openFileNodes[i]);
230:                    }
231:
232:                    // try to come back and open all files at-once, rises another problem with refactoring, if you do open file and next expand folder,
233:                    // it doesn't finish in the real-time -> hard to reproduced by hand
234:                    try {
235:                        new OpenAction().performAPI(openFileNodes
236:                                .toArray(new Node[0]));
237:                        // new EditAction().performAPI(editFileNodes.toArray(new Node[0]));
238:                    } catch (Exception exc) {
239:                        err.println("---------------------------------------");
240:                        err
241:                                .println("issue 56825 : EXCEPTION catched during OpenAction");
242:                        exc.printStackTrace(err);
243:                        err.println("---------------------------------------");
244:                        err.println("issue 56825 : Try it again");
245:                        new OpenAction().performAPI(openFileNodes
246:                                .toArray(new Node[0]));
247:                        // new EditAction().performAPI(editFileNodes.toArray(new Node[0]));
248:                        err.println("issue 56825 : Success");
249:                    }
250:
251:                    // check whether files are opened in editor
252:                    for (int i = 0; i < nodes_path.length; i++) {
253:                        if (nodes_path[i][2] != null)
254:                            new TopComponentOperator(nodes_path[i][2]);
255:                        else
256:                            new TopComponentOperator(nodes_path[i][1]);
257:                    }
258:                    //        new org.netbeans.jemmy.EventTool().waitNoEvent(60000);
259:
260:                } catch (Exception exc) {
261:                    test_failed = true;
262:                    fail(exc);
263:                }
264:            }
265:
266:            /**
267:             * Save status, if one of the above defined test failed, this method creates
268:             * file in predefined path and it means the complex tests will not run.
269:             */
270:            public void saveStatus() throws java.io.IOException {
271:                if (test_failed)
272:                    MeasureStartupTimeTestCase.createStatusFile();
273:            }
274:
275:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.