KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > projects > TestFreeformProject


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * TestFreeformProject.java
22  * NetBeans JUnit based test
23  *
24  * Created on July 16, 2004, 2:56 PM
25  */

26
27 package projects;
28
29 import junit.framework.*;
30 import org.netbeans.jellytools.Bundle;
31 import org.netbeans.jellytools.JellyTestCase;
32 import org.netbeans.jellytools.NbDialogOperator;
33 import org.netbeans.jellytools.NewProjectNameLocationStepOperator;
34 import org.netbeans.jellytools.NewProjectWizardOperator;
35 import org.netbeans.jellytools.ProjectsTabOperator;
36 import org.netbeans.jellytools.WizardOperator;
37 import org.netbeans.jemmy.JemmyProperties;
38 import org.netbeans.jemmy.TimeoutExpiredException;
39 import org.netbeans.jemmy.operators.JComboBoxOperator;
40 import org.netbeans.jemmy.operators.JTextFieldOperator;
41 import org.netbeans.junit.*;
42 import org.netbeans.junit.ide.ProjectSupport;
43
44
45 /**
46  *
47  */

48 public class TestFreeformProject extends JellyTestCase {
49     
50     public TestFreeformProject(java.lang.String JavaDoc testName) {
51         super(testName);
52     }
53     
54     public static void main(java.lang.String JavaDoc[] args) {
55         junit.textui.TestRunner.run(suite());
56     }
57     
58     public static Test suite() {
59         TestSuite suite = new NbTestSuite(TestFreeformProject.class);
60         return suite;
61     }
62     
63     public void setUp() {
64         System.out.println("######## " + getName() + " #######"); // NOI18N
65
}
66     
67     // -------------------------------------------------------------------------
68

69     public void testCreateProject_1() throws Exception JavaDoc {
70         
71         String JavaDoc projName = "FreeForm_1"; // NOI18N
72

73         createFreeformProject(projName, getWorkDir().getAbsolutePath() + java.io.File.separator + "freeform",
74                 getDataDir() + java.io.File.separator + "freeform1",
75                 getDataDir() + java.io.File.separator + "freeform1" + java.io.File.separator + "build.xml");
76         
77         // Opening Projects
78
String JavaDoc openingProjectsTitle = Bundle.getString("org.netbeans.modules.project.ui.Bundle", "LBL_Opening_Projects_Progress");
79         try {
80             // wait at most 60 second until progress dialog dismiss
81
JemmyProperties.setCurrentTimeout("ComponentOperator.WaitStateTimeout", 60000);
82             new NbDialogOperator(openingProjectsTitle).waitClosed();
83         } catch (TimeoutExpiredException e) {
84             // ignore when progress dialog was closed before we started to wait for it
85
}
86        // JemmyProperties.setCurrentTimeout("ComponentOperator.WaitStateTimeout", 60000);
87
// wait project appear in projects view
88
new ProjectsTabOperator().getProjectRootNode(projName);
89         // wait classpath scanning finished
90
ProjectSupport.waitScanFinished();
91         //new ProjectsTabOperator().getProjectRootNode(projName);
92

93         // Verify that correct project has been created
94
TestProjectUtils.verifyProjectExists(projName);
95         
96         // Verify that created project can be built
97
TestProjectUtils.verifyProjectBuilds(projName);
98         
99     }
100     
101     // -------------------------------------------------------------------------
102

103     private void createFreeformProject(String JavaDoc projName, String JavaDoc projFolder,
104             String JavaDoc projLocation, String JavaDoc buildScript) {
105         
106         // select the right template
107
NewProjectWizardOperator npwo = NewProjectWizardOperator.invoke();
108         String JavaDoc standardLabel = Bundle.getStringTrimmed("org.netbeans.modules.java.j2seproject.ui.wizards.Bundle",
109                 "Templates/Project/Standard");
110         npwo.selectCategory(standardLabel);
111         String JavaDoc freeformLabel = Bundle.getStringTrimmed("org.netbeans.modules.java.freeform.resources.Bundle",
112                 "Templates/Project/Standard/j2sefreeform.xml");
113         npwo.selectProject(freeformLabel);
114         npwo.next();
115         
116         WizardOperator wo = new WizardOperator("New Java Project with Existing Ant Script");
117         NewProjectNameLocationStepOperator npnlso = new NewProjectNameLocationStepOperator();
118         
119         // ERROR - returns null
120
//npnlso.txtLocation().setText(projLocation);
121

122         JTextFieldOperator locationOper = new JTextFieldOperator(wo, 3);
123         locationOper.setText(projLocation);
124         
125         //npnlso.txtAntScript().setText(buildScript); // Wrong label: 'Ant Script:'
126
JTextFieldOperator scriptOper = new JTextFieldOperator(wo, 0);
127         scriptOper.setText(buildScript);
128         
129         // ERROR - returns null
130
npnlso.txtProjectName().setText(projName);
131         //JTextFieldOperator nameOper = new JTextFieldOperator(wo, 1);
132
//nameOper.setText(projName);
133

134         // ERROR - returns null
135
npnlso.txtProjectFolder().setText(projFolder);
136         //JTextFieldOperator folderOper = new JTextFieldOperator(wo, 2);
137
//folderOper.setText(projFolder);
138

139         wo.next();
140         
141         JComboBoxOperator buildTarget = new JComboBoxOperator(wo);
142         buildTarget.enterText("jar"); // NOI18N
143

144         wo.next();
145         wo.finish();
146         
147     }
148     
149 }
150
Popular Tags