KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > startup > MeasureNB40WebStartupTimeOpenedFilesPrepare


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 startup;
21
22 import java.io.PrintStream JavaDoc;
23
24 import org.netbeans.jellytools.*;
25 import org.netbeans.jellytools.actions.EditAction;
26 import org.netbeans.jellytools.actions.OpenAction;
27 import org.netbeans.jellytools.nodes.Node;
28 import org.netbeans.jellytools.nodes.SourcePackagesNode;
29
30 import org.netbeans.jemmy.operators.*;
31
32 import junit.framework.Test;
33 import junit.framework.TestSuite;
34
35 import org.netbeans.junit.NbTestSuite;
36 import org.netbeans.junit.ide.ProjectSupport;
37
38
39 /**
40  * Prepare user directory for measurement of startup time of IDE with opened files.
41  * Open 10 java files and shut down ide.
42  * Created user directory will be used to measure startup time of IDE with opened files.
43  *
44  * @author Marian.Mirilovic@sun.com
45  */

46 public class MeasureNB40WebStartupTimeOpenedFilesPrepare extends JellyTestCase {
47     
48     
49     /** Error output from the test. */
50     protected static PrintStream JavaDoc err;
51     
52     /** Logging output from the test. */
53     protected static PrintStream JavaDoc log;
54
55     
56     
57     /** Define testcase
58      * @param testName name of the testcase
59      */

60     public MeasureNB40WebStartupTimeOpenedFilesPrepare(String JavaDoc testName) {
61         super(testName);
62     }
63
64     /** Testsuite
65      * @return testuite
66      */

67     public static Test suite() {
68         TestSuite suite = new NbTestSuite();
69         suite.addTest(new IDESetupTest("testCloseMemoryToolbar"));
70         suite.addTest(new IDESetupTest("testCloseWelcome"));
71         suite.addTest(new MeasureNB40WebStartupTimeOpenedFilesPrepare("testOpenProjects"));
72         suite.addTest(new MeasureNB40WebStartupTimeOpenedFilesPrepare("openFiles"));
73         return suite;
74     }
75     
76     
77     public void setUp() {
78 // err = System.out;
79
err = getLog();
80         log = getRef();
81     }
82
83     
84     
85     
86     public void testOpenProjects() {
87         ProjectSupport.openProject(System.getProperty("xtest.tmpdir")+"/startup_nb40/TestWebApp");
88         ProjectSupport.waitScanFinished();
89         //waitForScan();
90
}
91     
92     private void waitForScan() {
93         // "Scanning Project Classpaths"
94
String JavaDoc titleScanning = Bundle.getString("org.netbeans.modules.javacore.Bundle", "TXT_ApplyingPathsTitle");
95         NbDialogOperator scanningDialogOper = new NbDialogOperator(titleScanning);
96         // scanning can last for a long time => wait max. 5 minutes
97
scanningDialogOper.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 300000);
98         scanningDialogOper.waitClosed();
99     }
100     
101     /**
102      * Open 10 selected files from jEdit project.
103      */

104     public void openFiles(){
105         
106         new org.netbeans.jemmy.EventTool().waitNoEvent(10000);
107         
108         String JavaDoc[] files_path = {
109             "Web Pages|index.jsp",
110             "Source Packages|test|TestServlet.java"
111         };
112         
113         Node root = new ProjectsTabOperator().getProjectRootNode("TestWebApp");
114         Node[] openFileNodes = new Node[files_path.length];
115         
116         for(int i=0; i<files_path.length; i++) {
117                 
118                 openFileNodes[i] = new Node(root, files_path[i]);
119                 // open file one by one, opening all files at once causes never ending loop (java+mdr)
120
//new OpenAction().performAPI(openFileNodes[i]);
121
}
122         
123         // try to come back and open all files at-once, rises another problem with refactoring, if you do open file and next expand folder,
124
// it doesn't finish in the real-time -> hard to reproduced by hand
125
new EditAction().performAPI(new Node(root,"Web Pages|WEB-INF|web.xml"));
126         new org.netbeans.jemmy.EventTool().waitNoEvent(1000);
127         new OpenAction().performAPI(openFileNodes);
128         
129         new org.netbeans.jemmy.EventTool().waitNoEvent(60000);
130         
131     }
132     
133
134     public static void main(java.lang.String JavaDoc[] args) {
135         junit.textui.TestRunner.run(suite());
136     }
137 }
138
Popular Tags