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 gui.scanclasspath;
043:
044: import java.util.ArrayList;
045:
046: import org.netbeans.junit.NbTestSuite;
047: import org.netbeans.jemmy.operators.ComponentOperator;
048: import org.netbeans.performance.test.utilities.LoggingScanClasspath;
049:
050: /**
051: * Test provide measured time of scanning classpth for some classpath roots.
052: * We measure classpath scanning during openieng jEdit project.
053: *
054: * @author mmirilovic@netbeans.org
055: */
056: public class ScanClasspath extends
057: org.netbeans.performance.test.utilities.PerformanceTestCase {
058:
059: // list of classpath roots we are interesting to measure
060: protected static ArrayList<String> reportCPR = new ArrayList<String>();
061:
062: // measure whole classpath scan time together
063: protected static long wholeClasspathScan = 0;
064:
065: static {
066: reportCPR.add("rt.jar"); // JDK/jre/lib/rt.jar
067: reportCPR.add("jEdit41/src"); // jEdit41/src
068: }
069:
070: /**
071: * Creates a new instance of ScanClasspath
072: * @param testName the name of the test
073: */
074: public ScanClasspath(String testName) {
075: super (testName);
076: expectedTime = 10000;
077: WAIT_AFTER_OPEN = 20000;
078: }
079:
080: /**
081: * Creates a new instance of ScanClasspath
082: * @param testName the name of the test
083: * @param performanceDataName measured values will be saved under this name
084: */
085: public ScanClasspath(String testName, String performanceDataName) {
086: super (testName, performanceDataName);
087: expectedTime = 10000;
088: WAIT_AFTER_OPEN = 20000;
089: }
090:
091: public static NbTestSuite suite() {
092: NbTestSuite suite = new NbTestSuite();
093:
094: suite.addTest(new ScanClasspath("openJEditProject"));
095:
096: return suite;
097: }
098:
099: public void openJEditProject() {
100: gui.Utilities.waitProjectOpenedScanFinished(System
101: .getProperty("xtest.tmpdir")
102: + "/jEdit41");
103: measureClassPathScan();
104: reportPerformance("Scanning Java Project Classpath",
105: wholeClasspathScan, "ms", 1);
106: }
107:
108: protected void measureClassPathScan() {
109:
110: LoggingScanClasspath.printMeasuredValues(getLog());
111:
112: for (LoggingScanClasspath.PerformanceScanData data : LoggingScanClasspath
113: .getData()) {
114: // report only if we want to report it
115: if (reportCPR.contains((Object) data.getName())) {
116: if (data.getValue() > 0)
117: reportPerformance("Scanning " + data.getName(),
118: data.getValue(), "ms", 1);
119: else
120: fail("Measured value [" + data.getValue()
121: + "] is not > 0 !");
122: }
123:
124: // measure whole classpath scan
125: wholeClasspathScan = wholeClasspathScan + data.getValue();
126: }
127: }
128:
129: public ComponentOperator open() {
130: return null;
131: }
132:
133: public void close() {
134: }
135:
136: public void prepare() {
137: }
138:
139: @Override
140: public void setUp() {
141: // do nothing
142: }
143:
144: }
|