KickJava   Java API By Example, From Geeks To Geeks.

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


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.test.j2ee.*;
33 import org.netbeans.test.j2ee.lib.Utils;
34
35 /**
36  *
37  * @author lm97939
38  */

39 public class AddOperationTest extends AddMethodTest {
40     
41     
42     /** Creates a new instance of AddMethodTest */
43     public AddOperationTest(String JavaDoc name) {
44         super(name);
45     }
46     
47     /** Use for execution inside IDE */
48     public static void main(java.lang.String JavaDoc[] args) {
49         // run only selected test case
50
junit.textui.TestRunner.run(new AddMethodTest("testAddOperation1"));
51     }
52     
53     public void setUp() {
54         System.out.println("######## "+getName()+" #######");
55     }
56
57     public void testAddOperation1() throws IOException JavaDoc{
58         beanName = "SampleWebService";
59         editorPopup = /*Bundle.getStringTrimmed("org.netbeans.modules.websvc.core.webservices.action.Bundle", "LBL_WebServiceActionGroup")
60                                +"|"+*/
Bundle.getStringTrimmed("org.netbeans.modules.websvc.core.webservices.action.Bundle", "LBL_OperationAction");
61         dialogTitle = Bundle.getStringTrimmed("org.netbeans.modules.websvc.core.webservices.action.Bundle", "LBL_OperationAction");
62         methodName = "operation1";
63         returnType = "String";
64         parameters = null;
65         exceptions = null;
66         isDDModified = false;
67         saveFile = true;
68         addMethod();
69     }
70
71     public void testAddOperation2() throws IOException JavaDoc{
72         beanName = "SampleWebService";
73         editorPopup = /*Bundle.getStringTrimmed("org.netbeans.modules.websvc.core.webservices.action.Bundle", "LBL_WebServiceActionGroup")
74                                +"|"+*/
Bundle.getStringTrimmed("org.netbeans.modules.websvc.core.webservices.action.Bundle", "LBL_OperationAction");
75         dialogTitle = Bundle.getStringTrimmed("org.netbeans.modules.websvc.core.webservices.action.Bundle", "LBL_OperationAction");
76         methodName = "operation2";
77         returnType = "String";
78         parameters = new String JavaDoc[][] {{"java.lang.String", "a"}, {"int", "b"}};
79         exceptions = new String JavaDoc[] { "java.lang.Exception" };
80         isDDModified = false;
81         saveFile = true;
82         addMethod();
83     }
84      
85     
86     protected void addMethod() throws IOException JavaDoc {
87         Node openFile = new Node(new ProjectsTabOperator().getProjectRootNode(WSValidation.WEB_SAMPLE_PROJECT_NAME),
88                                  "Web Services|"+beanName);
89         new OpenAction().performAPI(openFile);
90         
91         EditorOperator editor = new EditorWindowOperator().getEditor(beanName+"Impl.java");
92         //editor.select(12);
93
//editor.requestFocus();
94

95         // invoke Add Business Method dialog
96
new ActionNoBlock(null,editorPopup).perform(openFile);
97         NbDialogOperator dialog = new NbDialogOperator(dialogTitle);
98         
99         new JTextFieldOperator(dialog).setText(methodName);
100         if (returnType != null) {
101             new JTextFieldOperator(dialog,1).setText(returnType);
102         }
103         fillParameters(dialog);
104         fillExceptions(dialog);
105         
106         dialog.ok();
107         if (saveFile) {
108             editor.save();
109         }
110         
111         waitForEditorText(editor, methodName);
112
113         new org.netbeans.jemmy.EventTool().waitNoEvent(2000);
114         Utils utils = new Utils(this);
115         String JavaDoc beanNames[] = { beanName+"Impl.java",
116                                beanName+"SEI.java",
117                                beanName+"-config.xml",
118         };
119         utils.assertFiles(new File JavaDoc(WSValidation.WEB_SAMPLE_PROJECT_PATH + File.separator + "src" + File.separator + "java" + File.separator + "sample"), beanNames, getName()+"_");
120         String JavaDoc ddNames[] = { "web.xml",
121                              "sun-web.xml",
122                              "webservices.xml"
123         };
124         utils.assertFiles(new File JavaDoc(WSValidation.WEB_SAMPLE_PROJECT_PATH + File.separator + "web" + File.separator + "WEB-INF"), ddNames, isDDModified?getName()+"_":"");
125
126         editor.closeDiscard();
127     }
128     
129   
130     
131 }
132
Popular Tags