KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > startup > MeasureNB40StartupTimeWithWeb


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 MeasureNB40StartupTimeWithWeb extends JellyTestCase {
47     
48     /** Error output from the test. */
49     protected static PrintStream JavaDoc err;
50     
51     /** Logging output from the test. */
52     protected static PrintStream JavaDoc log;
53
54     
55     
56     /** Define testcase
57      * @param testName name of the testcase
58      */

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

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

105     public void openFiles(){
106         
107         new org.netbeans.jemmy.EventTool().waitNoEvent(10000);
108         
109         String JavaDoc[][] files_path = {
110             {"TestStartupWeb1","Web Pages|index.jsp"},
111             {"TestStartupWeb2","Web Pages|index.jsp"},
112             {"TestStartupWeb3","Web Pages|index.jsp"},
113         };
114         
115         Node[] openFileNodes = new Node[files_path.length];
116         
117         for(int i=0; i<files_path.length; i++) {
118                 Node root = new ProjectsTabOperator().getProjectRootNode(files_path[i][0]);
119                 root.setComparator(new Operator.DefaultStringComparator(true, true));
120                 openFileNodes[i] = new Node(root, files_path[i][1]);
121                 // open file one by one, opening all files at once causes never ending loop (java+mdr)
122
//new OpenAction().performAPI(openFileNodes[i]);
123
}
124         
125         // try to come back and open all files at-once, rises another problem with refactoring, if you do open file and next expand folder,
126
// it doesn't finish in the real-time -> hard to reproduced by hand
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