|
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-2002 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.test.gui.web.warpackager; import org.netbeans.jellytools.JellyTestCase; import org.netbeans.jellytools.Bundle; import org.netbeans.jellytools.nodes.FilesystemNode; import org.netbeans.jellytools.nodes.Node; import org.netbeans.web.test.nodes.WARNode; import org.netbeans.jellytools.OutputWindowOperator; import org.netbeans.jellytools.NbDialogOperator; import org.netbeans.jellytools.RuntimeTabOperator; import org.netbeans.jellytools.ExplorerOperator; import org.netbeans.jellytools.MainWindowOperator; import org.netbeans.jellytools.actions.ExplorerViewAction; import org.netbeans.jellytools.actions.CopyAction; import org.netbeans.jellytools.actions.CutAction; import org.netbeans.jellytools.actions.PasteAction; import org.netbeans.jellytools.actions.DeleteAction; import org.netbeans.jellytools.actions.RenameAction; import org.netbeans.jellytools.actions.PropertiesAction; import org.netbeans.jellytools.properties.TextFieldProperty; import org.netbeans.jellytools.properties.PropertySheetTabOperator; import org.netbeans.jellytools.properties.PropertySheetOperator; import org.netbeans.junit.NbTestSuite; import org.netbeans.jemmy.operators.JTreeOperator; import org.netbeans.jemmy.operators.JTextFieldOperator; import org.netbeans.jemmy.util.RegExComparator; import org.netbeans.jemmy.operators.Operator; import org.netbeans.jemmy.Waiter; import org.netbeans.jemmy.Waitable; import org.netbeans.jemmy.TimeoutExpiredException; import java.awt.event.KeyEvent; import org.netbeans.jellytools.EditorOperator; import org.netbeans.jellytools.EditorWindowOperator; import org.netbeans.jemmy.operators.JEditorPaneOperator; /* */ public class RenameWar extends JellyTestCase { private static String workDir = null; private static String webModule = null; private static String wmName = "wmdo"; private static String fSep = System.getProperty("file.separator"); private static String iSep = "|"; private static String classes = null; private static String from1 = null; private static String from2 = null; private static String from3 = null; private static String to1 = null; private static String to2 = null; private static String to3 = null; private static ExplorerOperator explorer = null; private static String renameTitle = null; private static String renameLabel = null; //constructor required by JUnit public RenameWar(java.lang.String testName) { super(testName); } //method allowing to execute test directly //from IDE for debugging public static void main(java.lang.String[] args) { junit.textui.TestRunner.run(suite()); } //method required by JUnit public static junit.framework.Test suite() { junit.framework.Test suite = new NbTestSuite(RenameWar.class); workDir = System.getProperty("warpackager.workdir").replace('/', fSep.charAt(0)); renameTitle = Bundle.getStringTrimmed("org.openide.actions.Bundle", "CTL_RenameTitle"); renameLabel = Bundle.getStringTrimmed("org.openide.actions.Bundle", "CTL_RenameLabel"); from1 = workDir + iSep + "from1"; from2 = workDir + iSep + "from2"; from3 = workDir + iSep + "from3"; to1 = workDir + iSep + "to1"; to2 = workDir + iSep + "to2"; to3 = workDir + iSep + "to3"; explorer = ExplorerOperator.invoke(); explorer.selectPageFilesystems(); return suite; } public void testRenameOkPopup() { WARNode node1 = null; try { node1 = new WARNode(from3 + "|war1"); } catch (Exception e) { fail("Please check that all mounts are done properly"); e.printStackTrace(); } try { node1.select(); (new RenameAction()).performPopup(node1); }catch(Exception e) { fail("Exception while try to rename WAR via popup: " + e); } NbDialogOperator dialog = new NbDialogOperator(renameTitle); JTextFieldOperator tf = new JTextFieldOperator(dialog); String name = tf.getText(); if(!name.equals("war1")) { fail("default text in rename dialog is wrong"); return; } tf.setText("newName1"); dialog.ok(); try { node1 = new WARNode(from3 + "|newName1"); } catch (Exception e) { fail("WAR file was not renamed."); e.printStackTrace(); } //PASS } public void testRenameCancelPopup() { WARNode node1 = null; try { node1 = new WARNode(from3 + "|war2"); } catch (Exception e) { fail("Please check that all mounts are done properly"); e.printStackTrace(); } try { node1.select(); (new RenameAction()).performPopup(node1); }catch(Exception e) { fail("Exception while try to rename WAR via popup: " + e); } NbDialogOperator dialog = new NbDialogOperator(renameTitle); JTextFieldOperator tf = new JTextFieldOperator(dialog); String name = tf.getText(); if(!name.equals("war2")) { fail("default text in rename dialog is wrong"); return; } tf.setText("newName2"); dialog.cancel(); try { node1 = new WARNode(from3 + "|war2"); } catch (Exception e) { fail("WAR file was renamed."); e.printStackTrace(); } //PASS } public void testRenameViaProps() { WARNode node1 = null; try { node1 = new WARNode(from3 + "|war3"); } catch (Exception e) { fail("Please check that all mounts are done properly"); e.printStackTrace(); } try { node1.select(); new PropertiesAction().perform(node1); String propertiesText = Bundle.getStringTrimmed("org.openide.actions.Bundle", "Properties"); String nameText = Bundle.getStringTrimmed("org.openide.loaders.Bundle", "PROP_name"); PropertySheetOperator pso = new PropertySheetOperator(propertiesText + " of war3"); PropertySheetTabOperator psto = new PropertySheetTabOperator(pso, propertiesText); TextFieldProperty tf = new TextFieldProperty(psto,nameText); if(!tf.getValue().equals("war3")) { fail("Default name in properties is wrong"); return; } tf.setValue("newName3"); }catch(Exception e) { fail("Exception while try to rename WAR via popup: " + e); } try { node1 = new WARNode(from3 + "|newName3"); } catch (Exception e) { fail("WAR file was not renamed."); e.printStackTrace(); } } /* public void testRenameByMouseClick() { } */ private void checkValid(String node) { try { WARNode war = new WARNode(node); }catch(Exception e) { fail("Valid war node (" + node + ")not found. " + e); e.printStackTrace(); } } private void deleteYes() { String deleteTitle = Bundle.getStringTrimmed("org.openide.explorer.Bundle", "MSG_ConfirmDeleteObjectTitle"); NbDialogOperator dialog = new NbDialogOperator(deleteTitle); dialog.yes(); } private void deleteNo() { String deleteTitle = Bundle.getStringTrimmed("org.openide.explorer.Bundle", "MSG_ConfirmDeleteObjectTitle"); NbDialogOperator dialog = new NbDialogOperator(deleteTitle); dialog.no(); } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 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.