1 19 20 package org.netbeans.test.j2ee.addmethod; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import org.netbeans.jellytools.Bundle; 25 import org.netbeans.jellytools.EditorOperator; 26 import org.netbeans.jellytools.EditorWindowOperator; 27 import org.netbeans.jellytools.JellyTestCase; 28 import org.netbeans.jellytools.NbDialogOperator; 29 import org.netbeans.jellytools.ProjectsTabOperator; 30 import org.netbeans.jellytools.actions.ActionNoBlock; 31 import org.netbeans.jellytools.actions.OpenAction; 32 import org.netbeans.jellytools.nodes.Node; 33 import org.netbeans.jemmy.JemmyException; 34 import org.netbeans.jemmy.Waitable; 35 import org.netbeans.jemmy.Waiter; 36 import org.netbeans.jemmy.operators.JButtonOperator; 37 import org.netbeans.jemmy.operators.JCheckBoxOperator; 38 import org.netbeans.jemmy.operators.JComboBoxOperator; 39 import org.netbeans.jemmy.operators.JRadioButtonOperator; 40 import org.netbeans.jemmy.operators.JTabbedPaneOperator; 41 import org.netbeans.jemmy.operators.JTextAreaOperator; 42 import org.netbeans.jemmy.operators.JTextFieldOperator; 43 import org.netbeans.jemmy.util.PNGEncoder; 44 import org.netbeans.test.j2ee.*; 45 46 50 public class AddFinderMethodTest extends AddMethodTest { 51 52 private boolean returnManyCardinality = true; 53 protected String ejbql = null; 54 private String toSearchFile; 55 56 57 public AddFinderMethodTest(String name) { 58 super(name); 59 } 60 61 62 public static void main(java.lang.String [] args) { 63 junit.textui.TestRunner.run(new AddFinderMethodTest("testAddFinderMethod2InEB")); 65 } 66 67 public void setUp() { 68 System.out.println("######## "+getName()+" #######"); 69 } 70 71 public void testAddFinderMethod1InEB() throws IOException { 72 beanName = "TestingEntity"; 73 editorPopup = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.action.Bundle", "LBL_EJBActionGroup") 74 +"|"+Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.action.Bundle", "LBL_AddFinderMethodAction"); 75 dialogTitle = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.action.Bundle", "LBL_AddFinderMethodAction"); 76 methodName = "findByTest1"; 77 returnManyCardinality = true; 78 parameters = null; 79 remote = Boolean.FALSE; 80 local = Boolean.TRUE; 81 ejbql = null; 82 toSearchFile = beanName+"LocalHome.java"; 83 isDDModified = true; 84 saveFile = true; 85 addMethod(); 86 } 87 88 public void testAddFinderMethod2InEB() throws IOException { 89 beanName = "TestingEntity"; 90 editorPopup = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.action.Bundle", "LBL_EJBActionGroup") 91 +"|"+Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.action.Bundle", "LBL_AddFinderMethodAction"); 92 dialogTitle = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.action.Bundle", "LBL_AddFinderMethodAction"); 93 methodName = "findByTest3"; 94 returnManyCardinality = false; 95 parameters = new String [][] {{"java.lang.String", "a"}}; 96 remote = Boolean.TRUE; 97 local = Boolean.TRUE; 98 ejbql = "SELECT OBJECT(o)\nFROM TestingEntity o\nWHERE o.key = ?1"; 99 toSearchFile = beanName+"LocalHome.java"; 100 isDDModified = true; 101 saveFile = true; 102 addMethod(); 103 } 104 105 protected void addMethod() throws IOException { 106 EditorOperator editor = new EditorWindowOperator().getEditor(beanName+"Bean.java"); 107 editor.select(11); 108 109 new ActionNoBlock(null,editorPopup).perform(editor); 111 NbDialogOperator dialog = new NbDialogOperator(dialogTitle); 112 new JTextFieldOperator(dialog).setText(methodName); 113 if (returnManyCardinality) { 114 new JRadioButtonOperator(dialog,"Many").setSelected(true); 115 } else { 116 new JRadioButtonOperator(dialog,"One").setSelected(true); 117 } 118 119 fillParameters(dialog); 120 setRemoteLocalCheckBox(dialog); 121 122 if (ejbql != null) { 123 new JTextAreaOperator(dialog).setText(ejbql); 124 } 125 dialog.ok(); 126 127 if (saveFile) 128 editor.save(); 129 130 if (toSearchFile != null) { 131 Node openFile2 = new Node(new ProjectsTabOperator().getProjectRootNode(EJBValidation.EJB_PROJECT_NAME), 132 "Source Packages|test|"+toSearchFile); 133 new OpenAction().performAPI(openFile2); 134 final EditorOperator editor2 = new EditorWindowOperator().getEditor(toSearchFile); 135 waitForEditorText(editor2, methodName); 136 editor2.closeDiscard(); 137 } 138 139 compareFiles(); 140 } 141 142 } 143 | Popular Tags |