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 org.netbeans.jellytools.*; 26 import org.netbeans.jellytools.actions.ActionNoBlock; 27 import org.netbeans.jellytools.actions.OpenAction; 28 import org.netbeans.jellytools.nodes.Node; 29 import org.netbeans.jemmy.JemmyException; 30 import org.netbeans.jemmy.Waitable; 31 import org.netbeans.jemmy.Waiter; 32 import org.netbeans.jemmy.operators.*; 33 import org.netbeans.test.j2ee.*; 34 import org.netbeans.test.j2ee.lib.Utils; 35 36 40 public class CreateCMPBeansFromDB extends JellyTestCase { 41 42 43 44 public CreateCMPBeansFromDB(String name) { 45 super(name); 46 } 47 48 public void setUp() { 49 System.out.println("######## "+getName()+" #######"); 50 } 51 52 public void testCreateCMPBeansFromDB() throws IOException { 53 final String FILE_TYPE = "CMP Entity Beans from Database"; 54 55 NewFileWizardOperator op = NewFileWizardOperator.invoke(); 56 op.selectProject(EJBValidation.EAR_PROJECT_NAME+"-ejb"); 57 op.selectCategory("Enterprise"); 58 op.selectFileType(FILE_TYPE); 59 op.next(); 60 WizardOperator wizard = new WizardOperator(FILE_TYPE); 61 new JComboBoxOperator(wizard).selectItem("/sample"); 62 new JComboBoxOperator(wizard,3).getTextField().enterText("cmpdb"); 64 wizard.next(); 65 wizard = new WizardOperator(FILE_TYPE); 69 new JButtonOperator(wizard, "Add All").push(); 70 wizard.finish(); 73 74 78 String beanNames[] = { 79 "Customer", "DiscountCode", "Manufacture", "MicroMarkets", 80 "Order", "ProductCode", "Product" 81 }; 83 Node beansNode = new Node(new ProjectsTabOperator().getProjectRootNode(EJBValidation.EJB_PROJECT_NAME), 84 Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbjar.project.ui.Bundle", "LBL_node")); 85 beansNode.tree().getTimeouts().setTimeout("JTreeOperator.WaitNextNodeTimeout", 300000); 86 for (int i=0; i<beanNames.length; i++) { 87 new Node(beansNode,beanNames[i]); 88 } 89 new org.netbeans.jemmy.EventTool().waitNoEvent(10000); 90 91 Utils utils = new Utils(this); 92 String ddNames[] = { "ejb-jar.xml", "sun-ejb-jar.xml", "sun-cmp-mappings.xml" }; 93 utils.assertFiles(new File (EJBValidation.EJB_PROJECT_PATH + File.separator + "src" + File.separator + "conf"), ddNames, getName()+"_"); 94 for (int i=0; i<beanNames.length; i++) { 95 Node openFile = new Node(new ProjectsTabOperator().getProjectRootNode(EJBValidation.EJB_PROJECT_NAME), 96 Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbjar.project.ui.Bundle", "LBL_node") 97 +"|"+beanNames[i]); 98 new OpenAction().performAPI(openFile); 99 EditorOperator editor = new EditorWindowOperator().getEditor(beanNames[i]); 100 editor.deleteLine(7); 101 editor.deleteLine(7); 102 editor.save(); 103 editor.close(); 104 } 105 File dbBeansDir = new File (EJBValidation.EJB_PROJECT_PATH + File.separator + "src" + File.separator + "java" + File.separator + "cmpdb"); 106 String beanFiles[] = dbBeansDir.list(new FilenameFilter () { 107 public boolean accept(File dir, String name) { 108 return name.endsWith(".java"); 109 } 110 }); 111 if (beanFiles.length != 28) 112 fail("28 generated db bean files are expected in "+dbBeansDir+" but "+String.valueOf(beanFiles.length)+" was found"); 113 utils.assertFiles(dbBeansDir, beanFiles, getName()+"_"); 114 } 115 116 } 117 | Popular Tags |