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 footprint;
043:
044: import org.netbeans.jellytools.NbDialogOperator;
045: import org.netbeans.jellytools.ProjectsTabOperator;
046: import org.netbeans.jellytools.TopComponentOperator;
047: import org.netbeans.jellytools.actions.EditAction;
048: import org.netbeans.jellytools.actions.SaveAllAction;
049: import org.netbeans.jellytools.nodes.Node;
050: import org.netbeans.jellytools.nodes.SourcePackagesNode;
051:
052: import org.netbeans.jemmy.operators.ComponentOperator;
053: import org.netbeans.jemmy.operators.JButtonOperator;
054: import org.netbeans.jemmy.operators.JComboBoxOperator;
055:
056: /**
057: * Measure J2EE Project Workflow Memory footprint
058: *
059: * @author mmirilovic@netbeans.org, mrkam@netbeans.org
060: */
061: public class J2EEProjectWorkflow extends
062: org.netbeans.performance.test.utilities.MemoryFootprintTestCase {
063:
064: private String j2eeproject, j2eeproject_ejb, j2eeproject_war,
065: j2eeproject_app;
066:
067: /**
068: * Creates a new instance of J2EEProjectWorkflow
069: *
070: * @param testName the name of the test
071: */
072: public J2EEProjectWorkflow(String testName) {
073: super (testName);
074: prefix = "J2EE Project Workflow |";
075: }
076:
077: /**
078: * Creates a new instance of J2EEProjectWorkflow
079: *
080: * @param testName the name of the test
081: * @param performanceDataName measured values will be saved under this name
082: */
083: public J2EEProjectWorkflow(String testName,
084: String performanceDataName) {
085: super (testName, performanceDataName);
086: prefix = "J2EE Project Workflow |";
087: }
088:
089: @Override
090: public void setUp() {
091: // do nothing
092: }
093:
094: public void prepare() {
095: }
096:
097: public void initialize() {
098: super .initialize();
099: EPFootprintUtilities.closeAllDocuments();
100: EPFootprintUtilities.closeMemoryToolbar();
101: }
102:
103: public ComponentOperator open() {
104: // Create, edit, build and execute a sample J2EE project
105: // Create, edit, build and execute a sample J2EE project
106: j2eeproject = EPFootprintUtilities.creatJ2EEeproject(
107: "Enterprise", "Enterprise Application", true); // NOI18N
108: j2eeproject_ejb = j2eeproject + "-ejb";
109: j2eeproject_war = j2eeproject + "-war";
110: j2eeproject_app = j2eeproject + "-app-client";
111:
112: EPFootprintUtilities.openFile(new Node(
113: new ProjectsTabOperator()
114: .getProjectRootNode(j2eeproject_war),
115: EPFootprintUtilities.WEB_PAGES + "|index.jsp"),
116: "index.jsp", true);
117: EPFootprintUtilities.insertToFile("index.jsp", 11,
118: "Hello World", true);
119:
120: new EditAction().perform(new Node(new ProjectsTabOperator()
121: .getProjectRootNode(j2eeproject_war),
122: "Configuration Files|sun-web.xml")); // NOI18N
123: TopComponentOperator xmlEditor = new TopComponentOperator(
124: "sun-web.xml");
125:
126: EPFootprintUtilities.insertToFile("sun-web.xml", 10,
127: " <property name=\"javaEncoding\" value=\"UTF8\">",
128: true);
129: EPFootprintUtilities
130: .insertToFile(
131: "sun-web.xml",
132: 10,
133: " <description>Encoding for generated Java servlet.</description>",
134: true);
135: EPFootprintUtilities.insertToFile("sun-web.xml", 10,
136: " </property>", true);
137:
138: if (xmlEditor.isModified())
139: xmlEditor.saveDocument();
140:
141: Node node = new Node(
142: new SourcePackagesNode(j2eeproject_app),
143: new SourcePackagesNode(j2eeproject_app).getChildren()[0]
144: + "|Main.java");
145: EPFootprintUtilities.openFile(node, "Main.java", true);
146: EPFootprintUtilities.insertToFile("Main.java", 19,
147: "System.out.println(\"Hello World\");", true);
148:
149: new SaveAllAction().performAPI();
150:
151: EPFootprintUtilities.buildproject(j2eeproject);
152: //runProject(j2seproject,true);
153: //debugProject(j2seproject,true);
154: //testProject(j2seproject);
155: //collapseProject(j2seproject);
156:
157: return null;
158: }
159:
160: public void close() {
161: if (j2eeproject != null) {
162: EPFootprintUtilities.deleteProject(j2eeproject);
163: EPFootprintUtilities.deleteProject(j2eeproject_war);
164: EPFootprintUtilities.deleteProject(j2eeproject_ejb);
165: EPFootprintUtilities.deleteProject(j2eeproject_app, false);
166: }
167: }
168:
169: public static void main(java.lang.String[] args) {
170: junit.textui.TestRunner.run(new J2EEProjectWorkflow(
171: "measureMemoryFooprint"));
172: }
173:
174: }
|