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 startup;
043:
044: import java.io.File;
045: import org.netbeans.jellytools.*;
046: import org.netbeans.jellytools.actions.OpenAction;
047: import org.netbeans.jellytools.nodes.Node;
048: import org.netbeans.jemmy.operators.*;
049: import junit.framework.Test;
050: import junit.framework.TestSuite;
051: import org.netbeans.junit.NbTestSuite;
052: import org.netbeans.junit.ide.ProjectSupport;
053:
054: /**
055: * Prepare user directory for measurement of startup time of IDE with opened files.
056: * Open 10 java files and shut down ide.
057: * Created user directory will be used to measure startup time of IDE with opened files.
058: *
059: * @author Martin.Schovanek@sun.com
060: */
061: public class MeasureJ2EEStartupTimeWithWeb extends JellyTestCase {
062: /** Define testcase
063: * @param testName name of the testcase
064: */
065: public MeasureJ2EEStartupTimeWithWeb(String testName) {
066: super (testName);
067: }
068:
069: /** Testsuite
070: * @return testuite
071: */
072: public static Test suite() {
073: TestSuite suite = new NbTestSuite();
074: suite.addTest(new IDESetupTest("testCloseMemoryToolbar"));
075: suite.addTest(new IDESetupTest("closeAllDocuments"));
076: suite.addTest(new MeasureJ2EEStartupTimeWithWeb(
077: "testOpenProjects"));
078: suite.addTest(new MeasureJ2EEStartupTimeWithWeb("openFiles"));
079: return suite;
080: }
081:
082: @Override
083: public void setUp() {
084: System.out.println("######## " + getName() + " ########");
085: }
086:
087: public void testOpenProjects() {
088: String prjsDir = System.getProperty("xtest.tmpdir")
089: + "/startup/";
090: assertTrue(new File(prjsDir).canRead());
091: String[] projects = { "TestStartupWeb1", "TestStartupWeb2",
092: "TestStartupWeb3" };
093: for (String prj : projects) {
094: assertTrue("Cannot read project folder: " + prj, new File(
095: prjsDir + prj).canRead());
096: assertNotNull("Cannot open project: " + prj, ProjectSupport
097: .openProject(prjsDir + prj));
098: ProjectSupport.waitScanFinished();
099: }
100: }
101:
102: /**
103: * Open 10 selected files from jEdit project.
104: */
105: public void openFiles() {
106: new org.netbeans.jemmy.EventTool().waitNoEvent(10000);
107: String[][] files_path = {
108: { "TestStartupWeb1", "Web Pages|index.jsp" },
109: { "TestStartupWeb2", "Web Pages|index.jsp" },
110: { "TestStartupWeb3", "Web Pages|index.jsp" }, };
111: Node[] openFileNodes = new Node[files_path.length];
112:
113: for (int i = 0; i < files_path.length; i++) {
114: Node root = new ProjectsTabOperator()
115: .getProjectRootNode(files_path[i][0]);
116: root.setComparator(new Operator.DefaultStringComparator(
117: true, true));
118: openFileNodes[i] = new Node(root, files_path[i][1]);
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: // try to come back and open all files at-once, rises another problem with refactoring, if you do open file and next expand folder,
123: // it doesn't finish in the real-time -> hard to reproduced by hand
124: new OpenAction().performAPI(openFileNodes);
125: new org.netbeans.jemmy.EventTool().waitNoEvent(15000);
126: }
127:
128: public static void main(java.lang.String[] args) {
129: junit.textui.TestRunner.run(suite());
130: }
131: }
|