KickJava   Java API By Example, From Geeks To Geeks.

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


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 AddSelectMethodTest extends AddMethodTest {
51     
52     protected String JavaDoc ejbql = null;
53     private String JavaDoc toSearchFile;
54     
55     /** Creates a new instance of AddMethodTest */
56     public AddSelectMethodTest(String JavaDoc name) {
57         super(name);
58     }
59     
60     public void setUp() {
61         System.out.println("######## "+getName()+" #######");
62     }
63
64     /** Use for execution inside IDE */
65     public static void main(java.lang.String JavaDoc[] args) {
66         // run only selected test case
67
junit.textui.TestRunner.run(new AddSelectMethodTest("testAddSelectMethod1InEB"));
68     }
69     
70     
71     public void testAddSelectMethod1InEB() 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_AddSelectMethodAction");
75         dialogTitle = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.action.Bundle", "LBL_AddSelectMethodAction");
76         methodName = "ejbSelectByTest1";
77         returnType = "int";
78         parameters = null;
79         ejbql = null;
80         //toSearchFile = beanName+"LocalHome.java";
81
isDDModified = true;
82         saveFile = true;
83         addMethod();
84     }
85
86     public void testAddSelectMethod2InEB() throws IOException JavaDoc{
87         beanName = "TestingEntity";
88         editorPopup = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.action.Bundle", "LBL_EJBActionGroup")
89                                +"|"+Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.action.Bundle", "LBL_AddSelectMethodAction");
90         dialogTitle = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.action.Bundle", "LBL_AddSelectMethodAction");
91         methodName = "ejbSelectByTest2";
92         returnType = "int";
93         parameters = new String JavaDoc[][] {{"java.lang.String", "a"}};
94         ejbql = null;
95         //toSearchFile = beanName+"LocalHome.java";
96
isDDModified = true;
97         saveFile = true;
98         addMethod();
99     }
100     
101     protected void addMethod() throws IOException JavaDoc {
102         EditorOperator editor = new EditorWindowOperator().getEditor(beanName+"Bean.java");
103         editor.select(11);
104
105         // invoke Add Business Method dialog
106
new ActionNoBlock(null,editorPopup).perform(editor);
107         NbDialogOperator dialog = new NbDialogOperator(dialogTitle);
108         new JTextFieldOperator(dialog).setText(methodName);
109         if (returnType != null) {
110             new JTextFieldOperator(dialog,1).setText(returnType);
111         }
112         
113         fillParameters(dialog);
114         
115         if (ejbql != null) {
116             new JTextAreaOperator(dialog).setText(ejbql);
117         }
118         dialog.ok();
119         
120         if (saveFile)
121             editor.save();
122         if (toSearchFile != null) {
123             waitForEditorText(editor, methodName);
124         }
125         
126         compareFiles();
127     }
128     
129 }
130
Popular Tags