KickJava   Java API By Example, From Geeks To Geeks.

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


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 UseDatabaseTest extends AddMethodBase {
40     
41     private String JavaDoc name;
42     
43     /** Creates a new instance of AddMethodTest */
44     public UseDatabaseTest(String JavaDoc name) {
45         super(name);
46     }
47     
48     /** Use for execution inside IDE */
49     public static void main(java.lang.String JavaDoc[] args) {
50         // run only selected test case
51
junit.textui.TestRunner.run(new SendMessageTest("testUseDatabase1InSB"));
52     }
53
54     public void setUp() {
55         System.out.println("######## "+getName()+" #######");
56     }
57     
58     public void testUseDatabase1InSB() throws IOException JavaDoc{
59         beanName = "TestingSession";
60         editorPopup = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbcore.ui.logicalview.entres.Bundle", "LBL_EnterpriseActionGroup")
61                                +"|"+Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbcore.ui.logicalview.entres.Bundle", "LBL_UseDbAction");
62         name = "myTestingDatabase";
63         toSearchInEditor = "getMyTestingDatabase";
64         isDDModified = true;
65         saveFile = true;
66         addMethod();
67         Node resources = new Node(new ProjectsTabOperator().getProjectRootNode(EJBValidation.EJB_PROJECT_NAME),
68                  Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbjar.project.ui.Bundle", "LBL_Node_ResourceNode"));
69         new Node(resources,"derby_netPool.sun-resource");
70         new Node(resources,"jdbc_"+name+".sun-resource");
71     }
72
73     protected void addMethod() throws IOException JavaDoc {
74         EditorOperator editor = new EditorWindowOperator().getEditor(beanName+"Bean.java");
75         editor.select(11);
76
77         // invoke Add Business Method dialog
78
new ActionNoBlock(null,editorPopup).perform(editor);
79         NbDialogOperator dialog = new NbDialogOperator(Bundle.getStringTrimmed("org.netbeans.modules.j2ee.ejbcore.ui.logicalview.entres.Bundle", "LBL_ChooseDatabase"));
80         if (name != null) {
81             new JTextFieldOperator(dialog).setText(name);
82         }
83         new JComboBoxOperator(dialog).selectItem("/sample");
84         new JCheckBoxOperator(dialog).setSelected(true);
85         dialog.ok();
86         
87         if (saveFile)
88             editor.save();
89         
90         waitForEditorText(editor, toSearchInEditor);
91         
92         compareFiles();
93     }
94     
95 }
96
Popular Tags