1 19 20 package gui.updatecenterwizard; 21 22 import gui.updatecenterwizard.settings.CatalogDataValues; 23 import gui.updatecenterwizard.settings.TestbagsProperties; 24 import java.awt.Component ; 25 import java.io.File ; 26 import java.lang.Thread ; 27 import java.util.Properties ; 28 import javax.swing.JComponent ; 29 import javax.swing.JDialog ; 30 import org.netbeans.jellytools.Bundle; 31 import org.netbeans.jellytools.JellyTestCase; 32 import org.netbeans.jellytools.NbDialogOperator; 33 import org.netbeans.jellytools.OptionsOperator; 34 import org.netbeans.jellytools.WizardOperator; 35 import org.netbeans.jellytools.actions.Action; 36 import org.netbeans.jellytools.actions.ActionNoBlock; 37 import org.netbeans.jellytools.nodes.Node; 38 import org.netbeans.jellytools.properties.Property; 39 import org.netbeans.jellytools.properties.PropertySheetOperator; 40 import org.netbeans.jellytools.properties.StringProperty; 41 import org.netbeans.jemmy.ComponentChooser; 42 import org.netbeans.jemmy.ComponentSearcher; 43 import org.netbeans.jemmy.EventTool; 44 import org.netbeans.jemmy.JemmyException; 45 import org.netbeans.jemmy.JemmyProperties; 46 import org.netbeans.jemmy.operators.JButtonOperator; 47 import org.netbeans.jemmy.operators.JCheckBoxOperator; 48 import org.netbeans.jemmy.operators.JDialogOperator; 49 import org.netbeans.jemmy.operators.JLabelOperator; 50 import org.netbeans.jemmy.operators.JTableOperator; 51 import org.netbeans.jemmy.operators.JTextFieldOperator; 52 import org.netbeans.jemmy.operators.JTreeOperator; 53 import org.netbeans.jemmy.operators.Operator; 54 import org.netbeans.junit.NbTestSuite; 55 56 60 61 public class N_LocalServerUpdateCenterWizardTests extends UpdateCenterWizardTests { 62 63 CatalogDataValues dataValues = null; 64 TestbagsProperties tbp = new TestbagsProperties(); 65 66 67 public N_LocalServerUpdateCenterWizardTests(String name) { 68 super(name); 69 } 70 public void setUp() { 71 System.out.println("######## "+getName()+" #######"); 72 dataValues = readDataValues("N_local_settings.xml"); 73 } 74 75 76 public static NbTestSuite suite() { 77 NbTestSuite suite = new NbTestSuite(); 78 79 suite.addTest(new N_LocalServerUpdateCenterWizardTests("testCreateUpdateCenterType")); 80 suite.addTest(new N_LocalServerUpdateCenterWizardTests("testSuccessfulConnection")); 81 suite.addTest(new N_LocalServerUpdateCenterWizardTests("testUpdateCenter")); 82 suite.addTest(new N_LocalServerUpdateCenterWizardTests("testRestart")); 83 return suite; 84 } 85 86 87 88 public static void main(java.lang.String [] args) { 89 junit.textui.TestRunner.run(suite()); 92 } 93 94 100 public void testCreateUpdateCenterType(){ 101 if(tbp.readProperty(TestbagsProperties.LOCAL_SERVER_TESTBAG_RESTARTED_PROPERTY_NAME) == true){ 103 return; 104 } 105 OptionsOperator optionsOper = OptionsOperator.invoke(); 106 optionsOper.treeTable().tree().setComparator(new Operator.DefaultStringComparator(true, true)); 108 String systemSettings = Bundle.getString("org.netbeans.core.Bundle", "UI/Services/IDEConfiguration") + "|" + 110 Bundle.getString("org.netbeans.core.Bundle", "UI/Services/IDEConfiguration/System") + "|" + 111 Bundle.getString("org.netbeans.modules.updatecenters.resources.Bundle", "Services/AutoupdateType"); 112 113 Node n = new Node(optionsOper.treeTable().tree(), systemSettings); 114 n.select(); 115 116 new ActionNoBlock(null, "New" + "|" + 117 Bundle.getString("org.netbeans.modules.autoupdate.resources.Bundle", "Templates/Services/AutoupdateType/autoupdate_xml_type.settings") 118 ).perform(n); 119 120 121 String endTitle = Bundle.getString("org.netbeans.modules.autoupdate.resources.Bundle", "Templates/Services/AutoupdateType/autoupdate_xml_type.settings"); 123 String startTitle = Bundle.getString("org.openide.loaders.Bundle", "CTL_TemplateTitle2"); 124 startTitle = startTitle.substring(0, startTitle.length()-3); 125 String newWizardTitle = startTitle + endTitle; 126 WizardOperator newWizardOperator = null; 127 newWizardOperator = new WizardOperator(newWizardTitle); 128 129 JTextFieldOperator tfo = new JTextFieldOperator(newWizardOperator, 0); 130 tfo.setText(dataValues.getUcName()); 131 132 newWizardOperator.btFinish().push(); 133 134 135 String localUCType = systemSettings + "|" + dataValues.getUcName(); 136 n = new Node(optionsOper.treeTable().tree(), localUCType); 137 n.select(); 138 139 PropertySheetOperator pso = new PropertySheetOperator(optionsOper); 140 Property serverURLProperty = new Property(pso, Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "PROP_Url")); 141 serverURLProperty.setValue("file:/" + getDataDir() + File.separator + "catalog" + File.separator + dataValues.getUcFile()); 142 optionsOper.close(); 143 } 144 145 146 147 151 public void testSuccessfulConnection() { 152 if(tbp.readProperty(TestbagsProperties.LOCAL_SERVER_TESTBAG_RESTARTED_PROPERTY_NAME) == true){ 154 return; 155 } 156 157 WizardOperator ucwizard = null; 158 try { 159 ucwizard = openUpdateCenterWizard(); 160 161 setAllAUtypesSelected(false); 163 String myUC = dataValues.getUcName(); 164 setAUtypeSelected(myUC, true); 165 166 String buttonProxyConfLabel = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "BNT_Proxy"); new JButtonOperator(ucwizard, buttonProxyConfLabel).pushNoBlock(); String proxyConfDialogTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_ProxyDialog_Title"); NbDialogOperator proxyDialog = new NbDialogOperator(proxyConfDialogTitle); new JCheckBoxOperator(proxyDialog).setSelected(true); new JTextFieldOperator(proxyDialog, 0).setText(dataValues.getProxyHost()); new JTextFieldOperator(proxyDialog, 1).setText(dataValues.getProxyPort()); proxyDialog.ok(); ucwizard.btNext().pushNoBlock(); 182 String connectingTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Connecting_Title"); 185 JemmyProperties.setCurrentTimeout("ComponentOperator.WaitStateTimeout", 60000); 187 new NbDialogOperator(connectingTitle).waitClosed(); 188 String secondStep = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "LAB_221"); new JLabelOperator(ucwizard, secondStep); 191 ucwizard.close(); 193 194 } catch (JemmyException e) { 195 if(ucwizard != null) { 197 ucwizard.close(); 198 } 199 throw e; 200 } 201 202 } 203 204 213 public void testUpdateCenter() { 214 if(tbp.readProperty(TestbagsProperties.LOCAL_SERVER_TESTBAG_RESTARTED_PROPERTY_NAME) == true){ 216 return; 217 } 218 219 String toolsItem = Bundle.getStringTrimmed("org.netbeans.core.Bundle", "Menu/Tools"); WizardOperator updateCenterWizardOper = null; 222 long oldWaitStateTime = JemmyProperties.getCurrentTimeout("ComponentOperator.WaitStateTimeout"); 223 try { 224 String updateCenterItem = Bundle.getStringTrimmed("org.netbeans.modules.autoupdate.Bundle", "CTL_Update"); 226 new Action(toolsItem+"|"+updateCenterItem, null).perform(); 227 String updateCenterTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Wizard"); 229 updateCenterWizardOper = new WizardOperator(updateCenterTitle); 230 JTableOperator oper = new JTableOperator(updateCenterWizardOper); 232 for(int i=0;i<oper.getRowCount();i++) { 234 if(oper.getValueAt(i, 1).toString().indexOf("Forte")>-1 && ((Boolean )oper.getValueAt(i, 0)).booleanValue()) { oper.clickOnCell(i, 0); 237 } 238 if(oper.getValueAt(i, 1).toString().indexOf("Sun")>-1 && ((Boolean )oper.getValueAt(i, 0)).booleanValue()) { oper.clickOnCell(i, 0); 241 } 242 } 243 244 String buttonProxyConfLabel = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "BNT_Proxy"); new JButtonOperator(updateCenterWizardOper, buttonProxyConfLabel).pushNoBlock(); 248 String proxyConfDialogTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_ProxyDialog_Title"); NbDialogOperator proxyDialog = new NbDialogOperator(proxyConfDialogTitle); 251 new JCheckBoxOperator(proxyDialog).setSelected(true); 253 new JTextFieldOperator(proxyDialog, 0).setText("webcache"); new JTextFieldOperator(proxyDialog, 1).setText("8080"); proxyDialog.ok(); 258 259 updateCenterWizardOper.btNext().pushNoBlock(); 261 String connectingTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Connecting_Title"); 264 JemmyProperties.setCurrentTimeout("ComponentOperator.WaitStateTimeout", 60000); 266 new NbDialogOperator(connectingTitle).waitClosed(); 267 new EventTool().waitNoEvent(500); 269 JTreeOperator tree = new JTreeOperator(updateCenterWizardOper); 270 String devUCLabel = Bundle.getString("org.netbeans.modules.updatecenters.resources.Bundle", "Services/AutoupdateType/autoupdate_xml_type.settings"); 272 273 for(int i = 0; i<dataValues.getModules().size(); i++){ 275 new Node(tree, dataValues.getUcName() + "|" + dataValues.getModules().elementAt(i).toString()).select(); new JButtonOperator(updateCenterWizardOper, new ComponentChooser() { 278 283 final String addLabel = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "HINT_Add"); public boolean checkComponent(Component comp) { 285 String tooltip = ((JComponent )comp).getToolTipText(); 286 if(tooltip != null) { 287 return tooltip.equals(addLabel); 288 } else { 289 return false; 290 } 291 } 292 293 public String getDescription() { 294 return "JButton with tooltip equals "+addLabel; 295 } 296 }).push(); 297 } 298 updateCenterWizardOper.btNext().pushNoBlock(); 300 String licenceTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Licence_Title"); 303 String acceptLabel = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Licence_Accept"); 305 new JButtonOperator(new NbDialogOperator(licenceTitle), acceptLabel).push(); 306 JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 30000); String doneLabel = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "DownloadProgressPanel.jLabel1.doneText"); 310 new JLabelOperator(updateCenterWizardOper, doneLabel); 311 updateCenterWizardOper.next(); 312 JTableOperator resultsTable = new JTableOperator(updateCenterWizardOper); 314 for(int row=0; row < resultsTable.getRowCount(); row++){ 316 System.out.println(((Boolean )(resultsTable.getValueAt(row, 0))).booleanValue()); 318 if(((Boolean )(resultsTable.getValueAt(row, 0))).booleanValue()==false){ 319 new Thread (){ 320 public void run(){ 321 try{ 322 sleep(1000); 323 confirmAllModal(); 324 }catch(Exception e){ 325 e.printStackTrace(); 326 } 327 } 328 }.start(); 329 330 resultsTable.clickOnCell(row, 0); 331 } 332 } 333 } catch (JemmyException e) { 334 String errorTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Error"); 337 if(JDialogOperator.findJDialog(errorTitle, true, true) != null) { 338 new NbDialogOperator(errorTitle).close(); 339 } 340 if(updateCenterWizardOper != null) { 342 updateCenterWizardOper.close(); 343 } 344 throw e; 345 } finally { 346 JemmyProperties.setCurrentTimeout("ComponentOperator.WaitStateTimeout", oldWaitStateTime); 348 } 349 } 350 351 352 public void testRestart(){ 353 if(tbp.readProperty(TestbagsProperties.LOCAL_SERVER_TESTBAG_RESTARTED_PROPERTY_NAME) == true){ 355 return; 358 } 359 tbp.writeProperty(TestbagsProperties.LOCAL_SERVER_TESTBAG_RESTARTED_PROPERTY_NAME, true); 361 WizardOperator updateCenterWizardOper = null; 363 updateCenterWizardOper = openUpdateCenterWizard(); 364 System.out.println("pushing finish..."); 366 updateCenterWizardOper.btFinish().push(); 367 } 369 370 371 public boolean isRestarted(){ 372 return (tbp.readProperty(TestbagsProperties.LOCAL_SERVER_TESTBAG_RESTARTED_PROPERTY_NAME) == true); 373 } 374 public void setRestarted(boolean value){ 375 tbp.writeProperty(TestbagsProperties.LOCAL_SERVER_TESTBAG_RESTARTED_PROPERTY_NAME, value); 376 } 377 378 379 423 424 } 425 | Popular Tags |