KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > j2ee > addmethod > AddFinderMethodTest


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 package org.netbeans.test.j2ee.addmethod;
21
22 import java.io.File JavaDoc;
23 import java.io.IOException JavaDoc;
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 /**
47  *
48  * @author lm97939
49  */

50 public class AddFinderMethodTest extends AddMethodTest {
51     
52     private boolean returnManyCardinality = true;
53     protected String JavaDoc ejbql = null;
54     private String JavaDoc toSearchFile;
55     
56     /** Creates a new instance of AddMethodTest */
57     public AddFinderMethodTest(String JavaDoc name) {
58         super(name);
59     }
60     
61     /** Use for execution inside IDE */
62     public static void main(java.lang.String JavaDoc[] args) {
63         // run only selected test case
64
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 JavaDoc{
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 JavaDoc{
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 JavaDoc[][] {{"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 JavaDoc {
106         EditorOperator editor = new EditorWindowOperator().getEditor(beanName+"Bean.java");
107         editor.select(11);
108
109         // invoke Add Business Method dialog
110
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