KickJava   Java API By Example, From Geeks To Geeks.

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


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.*;
25 import org.netbeans.jellytools.actions.ActionNoBlock;
26 import org.netbeans.jellytools.actions.OpenAction;
27 import org.netbeans.jellytools.nodes.Node;
28 import org.netbeans.jemmy.JemmyException;
29 import org.netbeans.jemmy.Waitable;
30 import org.netbeans.jemmy.Waiter;
31 import org.netbeans.jemmy.operators.*;
32 import org.netbeans.jemmy.util.PNGEncoder;
33 import org.netbeans.test.j2ee.*;
34
35 /**
36  *
37  * @author lm97939
38  */

39 public class AddCMPFieldTest extends AddMethodBase {
40     
41     protected String JavaDoc methodName;
42     protected String JavaDoc returnType;
43     private String JavaDoc description;
44     private Boolean JavaDoc localGetter;
45     private Boolean JavaDoc localSetter;
46     private Boolean JavaDoc remoteGetter;
47     private Boolean JavaDoc remoteSetter;
48     
49     /** Creates a new instance of AddMethodTest */
50     public AddCMPFieldTest(String JavaDoc name) {
51         super(name);
52     }
53     
54     /** Use for execution inside IDE */
55     public static void main(java.lang.String JavaDoc[] args) {
56         // run only selected test case
57
junit.textui.TestRunner.run(new AddCMPFieldTest("testAddCMPField1InEB"));
58     }
59     
60     public void setUp() {
61         System.out.println("######## "+getName()+" #######");
62     }
63     
64     public void testAddCMPField1InEB() throws IOException JavaDoc{
65         beanName = "TestingEntity";
66         editorPopup = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.action.Bundle", "LBL_EJBActionGroup")
67                                +"|"+Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.action.Bundle", "LBL_AddCmpFieldAction");
68         methodName = "cmpTestField1x";
69         description = null;
70         returnType = "String";
71         isDDModified = true;
72         saveFile = true;
73         addMethod();
74     }
75
76     public void testAddCMPField2InEB() throws IOException JavaDoc{
77         beanName = "TestingEntity";
78         editorPopup = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.action.Bundle", "LBL_EJBActionGroup")
79                                +"|"+Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbcore.ui.logicalview.ejb.action.Bundle", "LBL_AddCmpFieldAction");
80         methodName = "cmpTestField2x";
81         description = "Test Field";
82         returnType = "int";
83         localGetter = Boolean.TRUE;
84         localSetter = Boolean.FALSE;
85         remoteGetter = Boolean.TRUE;
86         remoteSetter = Boolean.TRUE;
87         isDDModified = true;
88         saveFile = true;
89         addMethod();
90     }
91     
92     protected void addMethod() throws IOException JavaDoc {
93         EditorOperator editor = new EditorWindowOperator().getEditor(beanName+"Bean.java");
94         editor.select(11);
95
96         // invoke Add Business Method dialog
97
new ActionNoBlock(null,editorPopup).perform(editor);
98         AddCMPFieldDialog dialog = new AddCMPFieldDialog();
99         dialog.setName(methodName);
100         if (description != null) {
101             dialog.setDescription(description);
102         }
103         if (returnType != null) {
104             dialog.setType(returnType);
105         }
106         
107         
108         if (localGetter != null)
109             dialog.checkLocalGetter(localGetter.booleanValue());
110         if (localSetter != null)
111             dialog.checkLocalSetter(localSetter.booleanValue());
112         if (remoteGetter != null)
113             dialog.checkRemoteGetter(remoteGetter.booleanValue());
114         if (remoteSetter != null)
115             dialog.checkRemoteSetter(remoteSetter.booleanValue());
116         dialog.ok();
117         
118         if (saveFile)
119             editor.save();
120         
121         waitForEditorText(editor, methodName);
122         
123         compareFiles();
124     }
125     
126 }
127
Popular Tags