KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > startup > MeasureJ2EEStartupTimeWithWeb


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 MeasureJ2EEStartupTimeWithWeb 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 MeasureJ2EEStartupTimeWithWeb(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("closeAllDocuments"));
70         suite.addTest(new IDESetupTest("testAddAppServer"));
71         suite.addTest(new MeasureJ2EEStartupTimeWithWeb("testOpenProjects"));
72         suite.addTest(new MeasureJ2EEStartupTimeWithWeb("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     public void testOpenProjects() {
85         ProjectSupport.openProject(System.getProperty("xtest.tmpdir")+"/startup/TestStartupWeb1");
86         ProjectSupport.waitScanFinished();
87         ProjectSupport.openProject(System.getProperty("xtest.tmpdir")+"/startup/TestStartupWeb2");
88         ProjectSupport.waitScanFinished();
89         ProjectSupport.openProject(System.getProperty("xtest.tmpdir")+"/startup/TestStartupWeb3");
90         ProjectSupport.waitScanFinished();
91         //waitForScan();
92
}
93     
94     private void waitForScan() {
95         // "Scanning Project Classpaths"
96
String JavaDoc titleScanning = Bundle.getString("org.netbeans.modules.javacore.Bundle", "TXT_ApplyingPathsTitle");
97         NbDialogOperator scanningDialogOper = new NbDialogOperator(titleScanning);
98         // scanning can last for a long time => wait max. 5 minutes
99
scanningDialogOper.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 300000);
100         scanningDialogOper.waitClosed();
101     }
102     
103     /**
104      * Open 10 selected files from jEdit project.
105      */

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