KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gui > updatecenterwizard > R_RemoteServerUpdateCenterWizardTests


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 gui.updatecenterwizard;
21
22 import gui.updatecenterwizard.settings.CatalogDataValues;
23 import org.netbeans.jellytools.Bundle;
24 import org.netbeans.jellytools.NbDialogOperator;
25 import org.netbeans.jellytools.WizardOperator;
26 import org.netbeans.jemmy.JemmyException;
27 import org.netbeans.jemmy.JemmyProperties;
28 import org.netbeans.jemmy.operators.JButtonOperator;
29 import org.netbeans.jemmy.operators.JCheckBoxOperator;
30 import org.netbeans.jemmy.operators.JLabelOperator;
31 import org.netbeans.jemmy.operators.JTextFieldOperator;
32 import org.netbeans.junit.NbTestSuite;
33  
34 /**
35  *
36  * @author Jaromir.Uhrik@Sun.Com
37  */

38
39 public class R_RemoteServerUpdateCenterWizardTests extends UpdateCenterWizardTests {
40     
41     CatalogDataValues dataValues = null;
42     /** Creates a new instance of RemoteServerUpdateCenterWizardTests */
43     public R_RemoteServerUpdateCenterWizardTests(String JavaDoc name) {
44         super(name);
45     }
46     public void setUp() {
47         System.out.println("######## "+getName()+" #######");
48         dataValues = readDataValues("R_remote_settings.xml");
49     }
50     
51     public static NbTestSuite suite() {
52         NbTestSuite suite = new NbTestSuite();
53         suite.addTest(new N_RemoteServerUpdateCenterWizardTests("testUnsuccessfulConnection"));
54         suite.addTest(new N_RemoteServerUpdateCenterWizardTests("testSuccessfulConnection"));
55         return suite;
56     }
57     
58        /* opens Update Center wizard
59         * set proxy to wrong values
60         * connects to default update center
61         * and the connect fails
62         */

63     public void testUnsuccessfulConnection() {
64         
65         
66         WizardOperator ucwizard = null;
67         
68         try {
69             ucwizard = openUpdateCenterWizard();
70             
71             //only Development Update Center will be selected
72
setAllAUtypesSelected(false);
73             String JavaDoc devUC = Bundle.getString("org.netbeans.modules.updatecenters.resources.Bundle","Services/AutoupdateType/autoupdate_xml_type.settings");
74             setAUtypeSelected(devUC, true);
75             
76             // set proxy
77
// Proxy Configuration...
78
String JavaDoc buttonProxyConfLabel = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "BNT_Proxy"); // NOI18N
79
new JButtonOperator(ucwizard, buttonProxyConfLabel).pushNoBlock();
80             // Proxy Configuration
81
String JavaDoc proxyConfDialogTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_ProxyDialog_Title"); // NOI18N
82
NbDialogOperator proxyDialog = new NbDialogOperator(proxyConfDialogTitle);
83             // Use Proxy check box
84
new JCheckBoxOperator(proxyDialog).setSelected(true);
85             // Proxy Host: text field
86
new JTextFieldOperator(proxyDialog, 0).setText("nonexisting.cache"); // NOI18N
87
// Proxy Port: text field
88
new JTextFieldOperator(proxyDialog, 1).setText("80809999999999999999"); // NOI18N
89
proxyDialog.ok();
90             // "Next >"
91
ucwizard.btNext().pushNoBlock();
92             // wait connecting dialog appears
93
// "Connecting"
94
String JavaDoc connectingTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Connecting_Title");
95             // wait at most 60 second until connecting dialog dismiss
96
JemmyProperties.setCurrentTimeout("ComponentOperator.WaitStateTimeout", 60000);
97             new NbDialogOperator(connectingTitle).waitClosed();
98             //find Error dialog
99
String JavaDoc errorTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Error");
100             new NbDialogOperator(errorTitle).close();
101             ucwizard.close();
102             
103         } catch (JemmyException e) {
104             // close Update center dialog
105
if(ucwizard != null) {
106                 ucwizard.close();
107             }
108             throw e;
109         }
110         
111     }
112      /* opens Update Center wizard
113      * set proxy to webcache:8080 !!! please change it correctly to your local settings, or comment the line marked with '// !!! proxy !!!'
114      * connects to default update center
115      */

116     public void testSuccessfulConnection() {
117         
118         WizardOperator ucwizard = null;
119         try {
120             ucwizard = openUpdateCenterWizard();
121             
122             //only local UC created by tests will be selected
123
setAllAUtypesSelected(false);
124             String JavaDoc myUC = dataValues.getUcName();
125             setAUtypeSelected(myUC, true);
126             
127             // set proxy
128
// Proxy Configuration...
129
String JavaDoc buttonProxyConfLabel = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "BNT_Proxy"); // !!! proxy !!! // NOI18N
130
new JButtonOperator(ucwizard, buttonProxyConfLabel).pushNoBlock(); // !!! proxy !!!
131
// Proxy Configuration
132
String JavaDoc proxyConfDialogTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_ProxyDialog_Title"); // !!! proxy !!! // NOI18N
133
NbDialogOperator proxyDialog = new NbDialogOperator(proxyConfDialogTitle);// !!! proxy !!!
134
// Use Proxy check box
135
new JCheckBoxOperator(proxyDialog).setSelected(true);// !!! proxy !!!
136
// Proxy Host: text field
137
new JTextFieldOperator(proxyDialog, 0).setText(dataValues.getProxyHost());// !!! proxy !!! // NOI18N
138
// Proxy Port: text field
139
new JTextFieldOperator(proxyDialog, 1).setText(dataValues.getProxyPort());// !!! proxy !!! // NOI18N
140
proxyDialog.ok();// !!! proxy !!!
141
// "Next >"
142
ucwizard.btNext().pushNoBlock();
143             // wait connecting dialog appears
144
// "Connecting"
145
String JavaDoc connectingTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Connecting_Title");
146             // wait at most 60 second until connecting dialog dismiss
147
JemmyProperties.setCurrentTimeout("ComponentOperator.WaitStateTimeout", 60000);
148             new NbDialogOperator(connectingTitle).waitClosed();
149             //check that you are on second pane/step
150
String JavaDoc secondStep = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "LAB_221"); //label 'Available Updates and New Modules:' is only on second pane
151
new JLabelOperator(ucwizard, secondStep);
152             //can close
153
ucwizard.close();
154             
155         } catch (JemmyException e) {
156             // close Update center dialog
157
if(ucwizard != null) {
158                 ucwizard.close();
159             }
160             throw e;
161         }
162         
163     }
164     /** Use for execution inside IDE */
165     public static void main(java.lang.String JavaDoc[] args) {
166         // run whole suite
167
//TestRunner.run(suite());
168
junit.textui.TestRunner.run(suite());
169     }
170     
171     
172     
173 }
174
Popular Tags