|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun * Microsystems, Inc. All Rights Reserved. */ package gui.updatecenterwizard; import java.awt.Component; import javax.swing.JComponent; import junit.textui.TestRunner; import org.netbeans.jellytools.Bundle; import org.netbeans.jellytools.JellyTestCase; import org.netbeans.jellytools.NbDialogOperator; import org.netbeans.jellytools.WizardOperator; import org.netbeans.jellytools.actions.Action; import org.netbeans.jellytools.nodes.Node; import org.netbeans.jemmy.ComponentChooser; import org.netbeans.jemmy.EventTool; import org.netbeans.jemmy.JemmyException; import org.netbeans.jemmy.JemmyProperties; import org.netbeans.jemmy.operators.JButtonOperator; import org.netbeans.jemmy.operators.JCheckBoxOperator; import org.netbeans.jemmy.operators.JDialogOperator; import org.netbeans.jemmy.operators.JLabelOperator; import org.netbeans.jemmy.operators.JTableOperator; import org.netbeans.jemmy.operators.JTextFieldOperator; import org.netbeans.jemmy.operators.JTreeOperator; import org.netbeans.junit.NbTestSuite; /** * * @author lukas.hasik */ public class UpdateCenterWizardTests extends JellyTestCase { /** Creates a new instance of UpdateCenterWizardTests */ public UpdateCenterWizardTests(String name) { super(name); } public static NbTestSuite suite() { NbTestSuite suite = new NbTestSuite(); suite.addTest(new UpdateCenterWizardTests("testUnsuccesfullConnection")); suite.addTest(new UpdateCenterWizardTests("testSuccesfullConnection")); return suite; } /** Use for execution inside IDE */ public static void main(java.lang.String[] args) { // run whole suite //TestRunner.run(suite()); // run only selected test case junit.textui.TestRunner.run(new UpdateCenterWizardTests("testSuccesfullConnection")); } public void setUp() { System.out.println("######## "+getName()+" #######"); } public void tearDown() { } /* opens Update Center wizard from main menu Tools | Update Center */ private WizardOperator openUpdateCenterWizard() throws JemmyException { // "Tools" String toolsItem = Bundle.getStringTrimmed("org.netbeans.core.Bundle", "Menu/Tools"); // NOI18N WizardOperator updateCenterWizardOper = null; String updateCenterItem = Bundle.getStringTrimmed("org.netbeans.modules.autoupdate.Bundle", "CTL_Update"); new Action(toolsItem+"|"+updateCenterItem, null).perform(); // "Update Center Wizard" String updateCenterTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Wizard"); updateCenterWizardOper = new WizardOperator(updateCenterTitle); return updateCenterWizardOper; } /* opens Update Center wizard * set proxy to webcache:8080 !!! please change it correctly to your local settings, or comment the line marked with '// !!! proxy !!!' * connects to default update center */ public void testSuccesfullConnection() { WizardOperator ucwizard = null; try { ucwizard = openUpdateCenterWizard(); // set proxy // Proxy Configuration... String buttonProxyConfLabel = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "BNT_Proxy"); // !!! proxy !!! // NOI18N new JButtonOperator(ucwizard, buttonProxyConfLabel).pushNoBlock(); // !!! proxy !!! // Proxy Configuration String proxyConfDialogTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_ProxyDialog_Title"); // !!! proxy !!! // NOI18N NbDialogOperator proxyDialog = new NbDialogOperator(proxyConfDialogTitle);// !!! proxy !!! // Use Proxy check box new JCheckBoxOperator(proxyDialog).setSelected(true);// !!! proxy !!! // Proxy Host: text field new JTextFieldOperator(proxyDialog, 0).setText("webcache");// !!! proxy !!! // NOI18N // Proxy Port: text field new JTextFieldOperator(proxyDialog, 1).setText("8080");// !!! proxy !!! // NOI18N proxyDialog.ok();// !!! proxy !!! // "Next >" ucwizard.btNext().pushNoBlock(); // wait connecting dialog appears // "Connecting" String connectingTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Connecting_Title"); // wait at most 60 second until connecting dialog dismiss JemmyProperties.setCurrentTimeout("ComponentOperator.WaitStateTimeout", 60000); new NbDialogOperator(connectingTitle).waitClosed(); //check that you are on second pane/step String secondStep = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "LAB_221"); //label 'Available Updates and New Modules:' is only on second pane new JLabelOperator(ucwizard, secondStep); //can close ucwizard.close(); } catch (JemmyException e) { // close Update center dialog if(ucwizard != null) { ucwizard.close(); } throw e; } } /* opens Update Center wizard * set proxy to wrong values * connects to default update center * and the connect fails */ public void testUnsuccesfullConnection() { WizardOperator ucwizard = null; try { ucwizard = openUpdateCenterWizard(); // set proxy // Proxy Configuration... String buttonProxyConfLabel = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "BNT_Proxy"); // NOI18N new JButtonOperator(ucwizard, buttonProxyConfLabel).pushNoBlock(); // Proxy Configuration String proxyConfDialogTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_ProxyDialog_Title"); // NOI18N NbDialogOperator proxyDialog = new NbDialogOperator(proxyConfDialogTitle); // Use Proxy check box new JCheckBoxOperator(proxyDialog).setSelected(true); // Proxy Host: text field new JTextFieldOperator(proxyDialog, 0).setText("nonexisting.cache"); // NOI18N // Proxy Port: text field new JTextFieldOperator(proxyDialog, 1).setText("80809999999999999999"); // NOI18N proxyDialog.ok(); // "Next >" ucwizard.btNext().pushNoBlock(); // wait connecting dialog appears // "Connecting" String connectingTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Connecting_Title"); // wait at most 60 second until connecting dialog dismiss JemmyProperties.setCurrentTimeout("ComponentOperator.WaitStateTimeout", 60000); new NbDialogOperator(connectingTitle).waitClosed(); //find Error dialog String errorTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Error"); new NbDialogOperator(errorTitle).close(); ucwizard.close(); } catch (JemmyException e) { // close Update center dialog if(ucwizard != null) { ucwizard.close(); } throw e; } } public void testProxyDialogPossibilities() { } public void testAddNewAUType() { } public void testBadAUUrl() { } public void testChangePropagation() { } public void testSecondPanelButtons() { } public void testAcceptLicence() { } public void testSkipDownloadStep() { } public void testIncludeCheckBox() { } public void testSaveCopy() { } public void testSaveCopyWithWrongName() { } public void testUninstallAndInstallAUModule() { } /** Test Update Center * - open Update Center Wizard from main menu Tools|Update Center * - set proxy and go next * - wait until connection dialog dismiss * - in modules tree select "Development Update Center|Web|Applet" node * - click right arrow button and go next * - accept license dialog * - wait until download is finished and finish the wizard */ public void testUpdateCenter() { // "Tools" String toolsItem = Bundle.getStringTrimmed("org.netbeans.core.Bundle", "Menu/Tools"); // NOI18N WizardOperator updateCenterWizardOper = null; long oldWaitStateTime = JemmyProperties.getCurrentTimeout("ComponentOperator.WaitStateTimeout"); try { // "Update Center" String updateCenterItem = Bundle.getStringTrimmed("org.netbeans.modules.autoupdate.Bundle", "CTL_Update"); new Action(toolsItem+"|"+updateCenterItem, null).perform(); // "Update Center Wizard" String updateCenterTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Wizard"); updateCenterWizardOper = new WizardOperator(updateCenterTitle); // disable Forte for Java Update Center if any JTableOperator oper = new JTableOperator(updateCenterWizardOper); // check each row for(int i=0;i |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.