1 19 20 package org.netbeans.test.j2ee; 21 22 import java.io.File ; 23 import java.io.FilenameFilter ; 24 import java.io.IOException ; 25 import junit.textui.TestRunner; 26 import org.netbeans.jellytools.*; 27 import org.netbeans.jellytools.actions.Action; 28 import org.netbeans.jellytools.actions.ActionNoBlock; 29 import org.netbeans.jellytools.actions.OpenAction; 30 import org.netbeans.jellytools.nodes.Node; 31 import org.netbeans.jemmy.JemmyException; 32 import org.netbeans.jemmy.Waitable; 33 import org.netbeans.jemmy.Waiter; 34 import org.netbeans.jemmy.operators.*; 35 import org.netbeans.junit.NbTestSuite; 36 import org.netbeans.junit.ide.ProjectSupport; 37 import org.netbeans.test.j2ee.*; 38 import org.netbeans.test.j2ee.lib.Utils; 39 40 44 public class FreeFormProjects extends JellyTestCase { 45 46 public static final String CMP2_PROJECT_PATH = System.getProperty("xtest.tmpdir") + File.separator + "freeform_projects" + File.separator + "cmp2"; 47 public static final String TRAVEL_PROJECT_PATH = System.getProperty("xtest.tmpdir") + File.separator + "freeform_projects" + File.separator + "travel"; 48 public static final String SECURE_PROJECT_PATH = System.getProperty("xtest.tmpdir") + File.separator + "freeform_projects" + File.separator + "Secure"; 49 50 51 public FreeFormProjects(String name) { 52 super(name); 53 } 54 55 public static NbTestSuite suite() { 56 NbTestSuite suite = new NbTestSuite(); 57 suite.addTest(new FreeFormProjects("testFreeFormEjb")); 58 suite.addTest(new FreeFormProjects("testEjbWithSources")); 59 suite.addTest(new FreeFormProjects("testEarWithSources")); 60 return suite; 61 } 62 63 64 public static void main(java.lang.String [] args) { 65 TestRunner.run(suite()); 67 } 68 69 public void setUp() { 70 System.out.println("######## "+getName()+" #######"); 71 } 72 73 public void testFreeFormEjb() { 74 createNewFreeFormEjbProject(CMP2_PROJECT_PATH, null, 75 new String [] {"Gangster Entity Bean", "Job Entity Bean", "Organization Entity Bean"}, 76 new String [] {"GangsterBean", "JobBean", "OrganizationBean"}); 77 } 78 79 public void testEjbWithSources() { 80 createNewEjbProjectFromExistingSources(TRAVEL_PROJECT_PATH, "Travel", TRAVEL_PROJECT_PATH+"-projects", 81 new String [] {"TravelAgentEJB", "CabinEJB"}, 82 new String [] {"TravelAgentBean", "CabinBean"}); 83 } 84 85 public void testEarWithSources() { 86 createNewEarProjectFromExistingSources(SECURE_PROJECT_PATH, "Secure", SECURE_PROJECT_PATH+"-projects"); 87 } 88 89 private void createNewFreeFormEjbProject(String location, String name, String beans[], String files[]) { 90 NewProjectWizardOperator npwo = NewProjectWizardOperator.invoke(); 91 npwo.selectCategory("Enterprise"); 92 npwo.selectProject("EJB Module with Existing Ant Script"); 93 npwo.next(); 94 NewProjectNameLocationStepOperator npnlso = new NewProjectNameLocationStepOperator(); 95 new JTextFieldOperator(npnlso,3).setText(location); if (name != null) 97 new JTextFieldOperator(npnlso,1).setText(name); 98 else 99 name = new JTextFieldOperator(npnlso,1).getText(); 100 npnlso.next(); 101 new NewProjectWizardOperator().next(); 102 new NewProjectWizardOperator().next(); 103 new NewProjectWizardOperator().next(); 104 new NewProjectWizardOperator().finish(); 105 Node rootNode = new ProjectsTabOperator().getProjectRootNode(name); 107 ProjectSupport.waitScanFinished(); 109 110 Node beansNode = new Node(rootNode, Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbjar.project.ui.Bundle", "LBL_node")); 111 if (beans != null) { 112 for (int i=0; i<beans.length; i++) { 113 Node node = new Node(beansNode, beans[i]); 114 node.expand(); 115 String children[] = node.getChildren(); 116 if (children == null || children.length <= 0) { 117 fail ("Bean node "+beans[i]+" has no children"); 118 } 119 if (beans != null) { 120 new OpenAction().perform(node); 121 new EditorOperator(files[i]).close(); 122 } 123 } 124 } 125 new Node(new ProjectsTabOperator().getProjectRootNode(name), 126 "Configuration Files|ejb-jar.xml"); 127 rootNode.performPopupAction(Bundle.getStringTrimmed("org.netbeans.core.Bundle", "Actions/Build")); 129 MainWindowOperator.getDefault().getTimeouts().setTimeout("Waiter.WaitingTime", 300000); 130 MainWindowOperator.getDefault().waitStatusText(Bundle.getString("org.apache.tools.ant.module.run.Bundle", "FMT_finished_target_status", new String [] {name+" (build)"})); 131 132 } 133 134 private void createNewEjbProjectFromExistingSources(String location, String name, String folder, String beans[], String files[]) { 135 NewProjectWizardOperator npwo = NewProjectWizardOperator.invoke(); 136 npwo.selectCategory("Enterprise"); 137 npwo.selectProject("EJB Module with Existing Sources"); 138 npwo.next(); 139 NewProjectNameLocationStepOperator npnlso = new NewProjectNameLocationStepOperator(); 140 new JTextFieldOperator(npnlso,0).setText(location); new JTextFieldOperator(npnlso,1).setText(name); new JTextFieldOperator(npnlso,2).setText(folder); new NewProjectWizardOperator().next(); 144 new NewProjectWizardOperator().finish(); 145 Node rootNode = new ProjectsTabOperator().getProjectRootNode(name); 147 ProjectSupport.waitScanFinished(); 149 Node beansNode = new Node(rootNode, Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbjar.project.ui.Bundle", "LBL_node")); 150 if (beans != null) { 151 for (int i=0; i<beans.length; i++) { 152 Node node = new Node(beansNode, beans[i]); 153 node.expand(); 154 String children[] = node.getChildren(); 155 if (children == null || children.length <= 0) { 156 fail ("Bean node "+beans[i]+" has no children"); 157 } 158 if (beans != null) { 159 new OpenAction().perform(node); 160 new EditorOperator(files[i]).close(); 161 } 162 } 163 } 164 new Node(new ProjectsTabOperator().getProjectRootNode(name), "Configuration Files|ejb-jar.xml"); 165 rootNode.performPopupAction(Bundle.getStringTrimmed("org.netbeans.core.Bundle", "Actions/Build")); 167 MainWindowOperator.getDefault().getTimeouts().setTimeout("Waiter.WaitingTime", 300000); 168 MainWindowOperator.getDefault().waitStatusText(Bundle.getString("org.apache.tools.ant.module.run.Bundle", "FMT_finished_target_status", new String [] {name+" (dist)"})); 169 } 170 171 private void createNewEarProjectFromExistingSources(String location, String name, String folder) { 172 NewProjectWizardOperator npwo = NewProjectWizardOperator.invoke(); 173 npwo.selectCategory("Enterprise"); 174 npwo.selectProject("Enterprise Application with Existing Sources"); 175 npwo.next(); 176 NewProjectNameLocationStepOperator npnlso = new NewProjectNameLocationStepOperator(); 177 new JTextFieldOperator(npnlso,1).setText(location); new JTextFieldOperator(npnlso,0).setText(name); new JTextFieldOperator(npnlso,2).setText(folder); new NewProjectWizardOperator().finish(); 181 new NbDialogOperator("Warning").ok(); 182 Node rootNode = new ProjectsTabOperator().getProjectRootNode(name); 184 ProjectSupport.waitScanFinished(); 186 187 } 192 193 } 194 | Popular Tags |