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.action;
043:
044: import org.netbeans.jellytools.Bundle;
045: import org.netbeans.jellytools.NewProjectNameLocationStepOperator;
046: import org.netbeans.jellytools.NewProjectWizardOperator;
047: import org.netbeans.jellytools.actions.CloseAllDocumentsAction;
048:
049: import org.netbeans.jemmy.EventTool;
050: import org.netbeans.jemmy.operators.ComponentOperator;
051:
052: import org.netbeans.junit.ide.ProjectSupport;
053:
054: /**
055: * Test create projects
056: *
057: * @author mmirilovic@netbeans.org
058: */
059: public class CreateProject extends
060: org.netbeans.performance.test.utilities.PerformanceTestCase {
061:
062: private static final Object PROJECT_REFS = new Object();
063:
064: private NewProjectNameLocationStepOperator wizard_location;
065:
066: private String category, project, project_name, project_type;
067:
068: private int index;
069:
070: /**
071: * Creates a new instance of CreateProject
072: * @param testName the name of the test
073: */
074: public CreateProject(String testName) {
075: super (testName);
076: expectedTime = 10000;
077: WAIT_AFTER_OPEN = 20000;
078: }
079:
080: /**
081: * Creates a new instance of CreateProject
082: * @param testName the name of the test
083: * @param performanceDataName measured values will be saved under this name
084: */
085: public CreateProject(String testName, String performanceDataName) {
086: super (testName, performanceDataName);
087: expectedTime = 10000;
088: WAIT_AFTER_OPEN = 20000;
089: }
090:
091: public void testCreateJavaApplicationProject() {
092: category = Bundle
093: .getStringTrimmed(
094: "org.netbeans.modules.java.j2seproject.ui.wizards.Bundle",
095: "Templates/Project/Standard"); // "Standard"
096: project = Bundle
097: .getStringTrimmed(
098: "org.netbeans.modules.java.j2seproject.ui.wizards.Bundle",
099: "Templates/Project/Standard/emptyJ2SE.xml"); // "Java Application"
100: project_type = "JavaApplication";
101: index = 1;
102: doMeasurement();
103: }
104:
105: public void testCreateJavaLibraryProject() {
106: category = Bundle
107: .getStringTrimmed(
108: "org.netbeans.modules.java.j2seproject.ui.wizards.Bundle",
109: "Templates/Project/Standard"); // "Standard"
110: project = Bundle
111: .getStringTrimmed(
112: "org.netbeans.modules.java.j2seproject.ui.wizards.Bundle",
113: "Templates/Project/Standard/emptyJ2SElibrary.xml"); // "Java Class Library"
114: project_type = "JavaLibrary";
115: index = 1;
116: doMeasurement();
117: }
118:
119: public void testCreateWebApplicationProject() {
120: category = Bundle.getStringTrimmed(
121: "org.netbeans.modules.web.project.ui.wizards.Bundle",
122: "Templates/Project/Web"); //"Web"
123: project = Bundle.getStringTrimmed(
124: "org.netbeans.modules.web.project.ui.wizards.Bundle",
125: "Templates/Project/Web/emptyWeb.xml"); //"Web Application"
126: project_type = "WebProject";
127: index = 1;
128: doMeasurement();
129: }
130:
131: /* TODO
132: public void testCreateJavaProjectWithExistingSources(){
133: category="Standard";
134: project="Java Project with Existing Sources";
135: doMeasurement();
136: }*/
137:
138: public void initialize() {
139: }
140:
141: public void prepare() {
142: NewProjectWizardOperator wizard = NewProjectWizardOperator
143: .invoke();
144: wizard.selectCategory(category);
145: wizard.selectProject(project);
146: wizard.next();
147: wizard_location = new NewProjectNameLocationStepOperator();
148:
149: String directory = System.getProperty("xtest.tmpdir")
150: + java.io.File.separator + "createdProjects";
151: log("================= Destination directory={" + directory
152: + "}");
153: wizard_location.txtProjectLocation().setText("");
154: new EventTool().waitNoEvent(1000);
155: wizard_location.txtProjectLocation().setText(directory);
156:
157: project_name = project_type + "_" + (index++);
158: log("================= Project name=" + project_name + "}");
159: wizard_location.txtProjectName().setText("");
160: new EventTool().waitNoEvent(1000);
161: wizard_location.txtProjectName().typeText(project_name);
162: }
163:
164: public ComponentOperator open() {
165: wizard_location.finish();
166: ProjectSupport.waitScanFinished();
167: new EventTool().waitNoEvent(1000);
168: return null;
169: }
170:
171: public void close() {
172: if (index != repeat) { // ignore last round tha reports LRU caches
173: Object /* Project */prj = ProjectSupport
174: .openProject(System.getProperty("xtest.tmpdir")
175: + java.io.File.separator
176: + "createdProjects"
177: + java.io.File.separator + project_name);
178: reportReference("Project " + project_name
179: + " from CreateProject test", prj, PROJECT_REFS);
180: }
181: ProjectSupport.closeProject(project_name);
182: new CloseAllDocumentsAction().performAPI(); //avoid issue 68671 - editors are not closed after closing project by ProjectSupport
183: }
184:
185: /** Tests if created and later dclosed projects can be GCed from memory.
186: */
187: public void testGC() throws Exception {
188: runTestGC(PROJECT_REFS);
189: }
190:
191: public static void main(java.lang.String[] args) {
192: junit.textui.TestRunner.run(new CreateProject(
193: "testCreateJavaApplicationProject"));
194: }
195: }
|