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 memory;
043:
044: import gui.window.WebFormDesignerOperator;
045: import org.netbeans.jellytools.EditorOperator;
046: import org.netbeans.jellytools.ProjectsTabOperator;
047: import org.netbeans.jellytools.actions.CloseAllDocumentsAction;
048: import org.netbeans.jellytools.nodes.Node;
049: import org.netbeans.jemmy.JemmyProperties;
050: import org.netbeans.jemmy.TimeoutExpiredException;
051: import org.netbeans.jemmy.operators.ComponentOperator;
052: import org.netbeans.junit.NbTestSuite;
053: import org.netbeans.junit.ide.ProjectSupport;
054:
055: /**
056: *
057: * @author mkhramov@@netbeans.org
058: */
059: public class BigPageCyclicOpenTest extends
060: org.netbeans.performance.test.utilities.MemoryFootprintTestCase {
061:
062: private Node pagesRoot = null;
063: private long oldTimeout;
064:
065: public BigPageCyclicOpenTest(String testName) {
066: super (testName);
067: repeat_memory = 1;
068: }
069:
070: public BigPageCyclicOpenTest(String testName,
071: String performanceDataName) {
072: super (testName, performanceDataName);
073: repeat_memory = 1;
074: }
075:
076: @Override
077: public void initialize() {
078:
079: ProjectSupport.openProject(System.getProperty("xtest.tmpdir")
080: + java.io.File.separatorChar + "UltraLargeWA");
081: }
082:
083: @Override
084: public void prepare() {
085: EditorOperator.closeDiscardAll();
086: ProjectsTabOperator.invoke();
087: Node projectRoot = new ProjectsTabOperator()
088: .getProjectRootNode("UltraLargeWA");
089: pagesRoot = new Node(projectRoot, "Web Pages");
090:
091: oldTimeout = JemmyProperties.getCurrentTimeouts().getTimeout(
092: "ComponentOperator.WaitComponentTimeout");
093: JemmyProperties.getCurrentTimeouts().setTimeout(
094: "ComponentOperator.WaitComponentTimeout", 120000);
095:
096: }
097:
098: @Override
099: public ComponentOperator open() {
100: log("Begin cyclic page open test");
101:
102: for (int bigloop = 0; bigloop < 3; bigloop++) {
103: log(bigloop + " pass");
104: for (int innerloop = 0; innerloop < 100; innerloop++) {
105: doPageOpenCloseAttempt(innerloop);
106: }
107: log(bigloop + " pass completed");
108: }
109: return null;
110: }
111:
112: private void doPageOpenCloseAttempt(int attempt) {
113: String openPage = "Page1_" + (attempt + 1);
114: log("Opening " + openPage + ".jsp ...");
115: System.out.println(" Opening Page1_" + (attempt + 1));
116:
117: Node PageNode = new Node(pagesRoot, openPage + ".jsp");
118: PageNode.select();
119: long timestart = System.currentTimeMillis();
120: PageNode.performPopupActionNoBlock("Open");
121: try {
122: WebFormDesignerOperator
123: .findWebFormDesignerOperator(openPage);
124: } catch (TimeoutExpiredException tex) {
125: log("timeout for Opening page expired");
126: }
127: long timestop = System.currentTimeMillis();
128: System.out.println("Page opened in: " + (timestop - timestart)
129: + " ms");
130: new CloseAllDocumentsAction().performAPI();
131: }
132:
133: @Override
134: public void close() {
135: JemmyProperties.getCurrentTimeouts().setTimeout(
136: "ComponentOperator.WaitComponentTimeout", oldTimeout);
137: new CloseAllDocumentsAction().performAPI();
138: }
139:
140: @Override
141: public void shutdown() {
142: ProjectSupport.closeProject("UltraLargeWA");
143:
144: }
145:
146: public void testMem() {
147: doMeasurement();
148: }
149:
150: /** Creates suite from particular test cases. You can define order of testcases here. */
151: public static NbTestSuite suite() {
152: NbTestSuite suite = new NbTestSuite();
153: suite.addTest(new BigPageCyclicOpenTest("testMem",
154: "Memory footprint test"));
155: return suite;
156: }
157:
158: /* Method allowing test execution directly from the IDE. */
159: public static void main(java.lang.String[] args) {
160: junit.textui.TestRunner.run(suite());
161:
162: }
163:
164: }
|