alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

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-2004 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package validation;

import java.awt.Component;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.IOException;
import javax.swing.JComponent;

import junit.textui.TestRunner;
import org.netbeans.jellytools.Bundle;
import org.netbeans.jellytools.EditorOperator;
import org.netbeans.jellytools.FilesTabOperator;
import org.netbeans.jellytools.HelpOperator;
import org.netbeans.jellytools.JellyTestCase;
import org.netbeans.jellytools.MainWindowOperator;
import org.netbeans.jellytools.NbDialogOperator;
import org.netbeans.jellytools.NewFileNameLocationStepOperator;
import org.netbeans.jellytools.NewFileWizardOperator;
import org.netbeans.jellytools.NewProjectNameLocationStepOperator;
import org.netbeans.jellytools.NewProjectWizardOperator;
import org.netbeans.jellytools.OptionsOperator;
import org.netbeans.jellytools.OutputTabOperator;
import org.netbeans.jellytools.ProjectsTabOperator;
import org.netbeans.jellytools.RuntimeTabOperator;
import org.netbeans.jellytools.TopComponentOperator;
import org.netbeans.jellytools.WizardOperator;
import org.netbeans.jellytools.actions.Action;
import org.netbeans.jellytools.actions.ActionNoBlock;
import org.netbeans.jellytools.actions.CompileAction;
import org.netbeans.jellytools.actions.CopyAction;
import org.netbeans.jellytools.actions.CutAction;
import org.netbeans.jellytools.actions.DeleteAction;
import org.netbeans.jellytools.actions.NewFileAction;
import org.netbeans.jellytools.actions.OpenAction;
import org.netbeans.jellytools.actions.PasteAction;
import org.netbeans.jellytools.actions.ViewAction;
import org.netbeans.jellytools.modules.vcscore.VCSOutputOperator;
import org.netbeans.jellytools.modules.vcscore.VersioningManagerOperator;
import org.netbeans.jellytools.modules.vcsgeneric.actions.CVSUpdateAction;
import org.netbeans.jellytools.modules.vcsgeneric.wizard.VCSProfileOperator;
import org.netbeans.jellytools.modules.vcsgeneric.wizard.VCSProfileStepOperator;
import org.netbeans.jellytools.nodes.JavaNode;
import org.netbeans.jellytools.nodes.Node;
import org.netbeans.jellytools.nodes.SourcePackagesNode;
import org.netbeans.jellytools.properties.Property;
import org.netbeans.jellytools.properties.PropertySheetOperator;

import org.netbeans.jemmy.ComponentChooser;
import org.netbeans.jemmy.EventTool;
import org.netbeans.jemmy.JemmyException;
import org.netbeans.jemmy.JemmyProperties;
import org.netbeans.jemmy.TestOut;
import org.netbeans.jemmy.TimeoutExpiredException;
import org.netbeans.jemmy.Waitable;
import org.netbeans.jemmy.Waiter;
import org.netbeans.jemmy.operators.JButtonOperator;
import org.netbeans.jemmy.operators.JCheckBoxOperator;
import org.netbeans.jemmy.operators.JComboBoxOperator;
import org.netbeans.jemmy.operators.JDialogOperator;
import org.netbeans.jemmy.operators.JLabelOperator;
import org.netbeans.jemmy.operators.JListOperator;
import org.netbeans.jemmy.operators.JTableOperator;
import org.netbeans.jemmy.operators.JTextFieldOperator;
import org.netbeans.jemmy.operators.JTreeOperator;
import org.netbeans.jemmy.operators.Operator;
import org.netbeans.jemmy.operators.WindowOperator;
import org.netbeans.jemmy.util.PNGEncoder;

import org.netbeans.junit.NbTestSuite;

/**
 * Overall validation suite for IDE.
 *
 * @author Jiri.Skrivanek@sun.com
 */
public class IDEValidation extends JellyTestCase {
    
    /** Need to be defined because of JUnit */
    public IDEValidation(String name) {
        super(name);
    }

    public static NbTestSuite suite() {
        NbTestSuite suite = new NbTestSuite();
        suite.addTest(new IDEValidation("testMainMenu"));
        suite.addTest(new IDEValidation("testHelp"));
        suite.addTest(new IDEValidation("testOptions"));
        suite.addTest(new IDEValidation("testNewProject"));
        // sample project must exist before testShortcuts
        suite.addTest(new IDEValidation("testShortcuts"));
        suite.addTest(new IDEValidation("testNewFile"));
        suite.addTest(new IDEValidation("testCVS"));
        suite.addTest(new IDEValidation("testProjectsView"));
        suite.addTest(new IDEValidation("testFilesView"));
        suite.addTest(new IDEValidation("testEditor"));
        suite.addTest(new IDEValidation("testBuildAndRun"));
        suite.addTest(new IDEValidation("testDebugging"));
        suite.addTest(new IDEValidation("testXML"));
        suite.addTest(new IDEValidation("testUpdateCenter"));
        suite.addTest(new IDEValidation("testDb"));
        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 IDEValidation("testMainMenu"));
    }
    
    public void setUp() {
        System.out.println("########  "+getName()+"  #######");
        // Close help window if any - it should not stay open between test cases.
        // Otherwise it can break next tests.
        closeHelpWindow();
    }
    
    public void tearDown() {
    }
    
    // name of class created from template and used in tests
    private static final String JAVA_CLASS_NAME = "Main"; // NOI18N
    // name of sample frame created and used in tests
    private static final String SAMPLE_FRAME_NAME = "SampleFrame"; // NOI18N
    // name of sample project
    private static final String SAMPLE_PROJECT_NAME = "SampleProject"; // NOI18N
    // name of first sample package
    private static final String SAMPLE1_PACKAGE_NAME = "sample1"; //NOI18N
    // name of second sample package
    private static final String SAMPLE2_PACKAGE_NAME = "sample2"; //NOI18N
    // name of sample class
    private static final String SAMPLE1_CLASS_NAME = "SampleClass1"; // NOI18N
    // name of sample file
    private static final String SAMPLE1_FILE_NAME = SAMPLE1_CLASS_NAME+".java"; // NOI18N

    /** Test creation of java project. 
     * - open New Project wizard from main menu (File|New Project)
     * - select Java Application project from Standard category
     * - in the next panel type project name and project location in
     * - finish the wizard
     * - wait until scanning of java files is finished
     */
    public void testNewProject() {
        NewProjectWizardOperator npwo = NewProjectWizardOperator.invoke();
        // "Standard"
        String standardLabel = Bundle.getString("org.netbeans.modules.java.j2seproject.ui.wizards.Bundle", "Templates/Project/Standard");
        npwo.selectCategory(standardLabel);
        // "Java Application"
        String javaApplicationLabel = Bundle.getString("org.netbeans.modules.java.j2seproject.ui.wizards.Bundle", "Templates/Project/Standard/emptyJ2SE.xml");
        npwo.selectProject(javaApplicationLabel);
        npwo.next();
        NewProjectNameLocationStepOperator npnlso = new NewProjectNameLocationStepOperator();
        npnlso.txtProjectName().setText(SAMPLE_PROJECT_NAME);
        npnlso.txtProjectLocation().setText(System.getProperty("netbeans.user")); // NOI18N
        npnlso.finish();
        // "Scanning Project Classpaths"
        String titleScanning = Bundle.getString("org.netbeans.modules.javacore.Bundle", "TXT_ApplyingPathsTitle");
        NbDialogOperator scanningDialogOper = new NbDialogOperator(titleScanning);
        // scanning can last for a long time => wait max. 3 minutes
        scanningDialogOper.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 180000);
        scanningDialogOper.waitClosed();
        // wait project appear in projects view
        new ProjectsTabOperator().getProjectRootNode(SAMPLE_PROJECT_NAME);
    }
    
    /** Test new file wizard. 
     * - open New File wizard from main menu (File|New File)
     * - select sample project as target
     * - select Java Classes|Java Package file type
     * - in the next panel type package name in
     * - finish the wizard
     * - open New File wizard from context menu on created package node (New|File)
     * - select Java Classes|Java Main Class file type
     * - in the next panel type class name in
     * - finish the wizard
     * - check class is open in editor and close all opened documents
     */
    public void testNewFile() {
        // create a new package
        
        // "Java Classes"
        String javaClassesLabel = Bundle.getString("org.netbeans.modules.java.Bundle", "Templates/Classes");
        // "Java Package"
        String packageLabel = Bundle.getString("org.netbeans.modules.java.Bundle", "Templates/Classes/Package");
        NewFileWizardOperator.create(SAMPLE_PROJECT_NAME, javaClassesLabel, packageLabel, null, SAMPLE1_PACKAGE_NAME);
        // wait package node is created
        Node sample1Node = new Node(new SourcePackagesNode(SAMPLE_PROJECT_NAME), SAMPLE1_PACKAGE_NAME);
        
        // create a new class
        
        // "Java Main Class"
        String mainClassLabel = Bundle.getString("org.netbeans.modules.java.Bundle", "Templates/Classes/Main.java"); // NOI18N
        NewFileWizardOperator.invoke(sample1Node, javaClassesLabel, mainClassLabel);
        NewFileNameLocationStepOperator nameStepOper = new NewFileNameLocationStepOperator();
        nameStepOper.setObjectName(SAMPLE1_CLASS_NAME);
        nameStepOper.finish();
        // check class is opened in Editor and then close all documents
        new EditorOperator(SAMPLE1_FILE_NAME).closeAllDocuments();
    }
    
    /** Test Projects view 
     * - expand java elements hierarchy of sample class (SampleClass1.java|class SampleClass1|Methods|main) 
     * and select main method node.
     * - copy sample class and paste it to the same package
     * - verify creation of SampleClass1_1.java node
     * - cut SampleClass1_1.java
     * - paste it to another package
     * - cancel refactoring dialog
     * - delete SampleClass1_1.java node
     */
    public void testProjectsView() {
        ProjectsTabOperator projectsTabOper = ProjectsTabOperator.invoke();
        // needed for slower machines
        JemmyProperties.setCurrentTimeout("JTreeOperator.WaitNextNodeTimeout", 30000); // NOI18N
        // "class"
        String classLabel = Bundle.getStringTrimmed("org.openide.src.nodes.Bundle", "SHORT_classElementFormat");
        // "Methods"
        String methodsLabel = Bundle.getString("org.openide.src.nodes.Bundle", "Methods");
        SourcePackagesNode sourcePackagesNode = new SourcePackagesNode(SAMPLE_PROJECT_NAME);
        Node sample1Node = new Node(sourcePackagesNode, SAMPLE1_PACKAGE_NAME);
        Node sampleClass1Node = new Node(sample1Node, SAMPLE1_FILE_NAME);
        // expand class members
        new Node(sampleClass1Node, classLabel+SAMPLE1_CLASS_NAME+"|"+methodsLabel+"|main").select(); // NOI18N
        // test pop-up menu actions
        // "Copy"
        CopyAction copyAction = new CopyAction();
        copyAction.perform(sampleClass1Node);
        // "Paste"
        PasteAction pasteAction = new PasteAction();
        pasteAction.perform(sample1Node);
        Node sampleClass1_1Node = new Node(sample1Node, "_1"); // NOI18N
        sampleClass1_1Node.select();
        // "Cut"
        CutAction cutAction = new CutAction();
        cutAction.perform(sampleClass1_1Node);
        // package created by default when the sample project was created
        Node sampleProjectPackage = new Node(sourcePackagesNode, SAMPLE_PROJECT_NAME.toLowerCase());
        new ActionNoBlock(null, pasteAction.getPopupPath()).perform(sampleProjectPackage);
        // cancel refactoring
        // "Refactor Code for Moved Class(es)"
        String refactorTitle = Bundle.getString("org.netbeans.modules.refactoring.ui.Bundle", "LBL_RefactorClassAfterMove");
        new NbDialogOperator(refactorTitle).cancel();
        // "Delete"
        sampleClass1_1Node = new Node(sampleProjectPackage, "_1"); // NOI18N
        DeleteAction deleteAction = new DeleteAction();
        deleteAction.perform(sampleClass1_1Node);
        // "Confirm Object Deletion"
        String confirmTitle = Bundle.getString("org.openide.explorer.Bundle", "MSG_ConfirmDeleteObjectTitle"); // NOI18N
        new NbDialogOperator(confirmTitle).yes();
    }

    /** Test Files view 
     * - expand java elements hierarchy of sample class (SampleClass1.java|class SampleClass1|Methods|main) 
     * and select main method node.
     */
    public void testFilesView() {
        FilesTabOperator filesTabOper = FilesTabOperator.invoke();
        // needed for slower machines
        JemmyProperties.setCurrentTimeout("JTreeOperator.WaitNextNodeTimeout", 30000); // NOI18N
        // "class"
        String classLabel = Bundle.getStringTrimmed("org.openide.src.nodes.Bundle", "SHORT_classElementFormat");
        // "Methods"
        String methodsLabel = Bundle.getString("org.openide.src.nodes.Bundle", "Methods");
        Node sourcePackagesNode = new Node(filesTabOper.getProjectNode(SAMPLE_PROJECT_NAME), "src"); // NOI18N
        Node sample1Node = new Node(sourcePackagesNode, SAMPLE1_PACKAGE_NAME); // NOI18N
        Node sampleClass1Node = new Node(sample1Node, SAMPLE1_FILE_NAME);
        // expand class members
        new Node(sampleClass1Node, classLabel+SAMPLE1_CLASS_NAME+"|"+methodsLabel+"|main").select(); // NOI18N
        // It is possible to test also pop-up menu actions as in testProjectsView, but
        // it is redundant IMO
    }

    
    /** Test of DB module.
     * It only tests whether the Databases node is present in Runtime view, 
     * Add Driver action is enabled on Drivers node and Connect action is available
     * on default JDBC-ODBC Bridge node.
     * - find Databases|Drivers node in Runtime tab
     * - open and close Add Driver dialog from context menu on Drivers node
     * - open and close Connect Using dialog on JDBC-ODBC Bridge node
     */
    public void testDb() {
        // "Databases"
        String databasesLabel = Bundle.getString("org.netbeans.modules.db.resources.Bundle", "NDN_Databases");
        // "Drivers"
        String driversLabel = Bundle.getString("org.netbeans.modules.db.resources.Bundle", "NDN_Drivers");
        Node driversNode = new Node(RuntimeTabOperator.invoke().getRootNode(), databasesLabel+"|"+driversLabel);
        // "Add Driver ..."
        String addDriverItem = Bundle.getString("org.netbeans.modules.db.resources.Bundle", "AddNewDriver");
        // open a dialog to add a new JDBC driver
        new ActionNoBlock(null, addDriverItem).perform(driversNode);
        String addDriverTitle = Bundle.getString("org.netbeans.modules.db.resources.Bundle", "AddDriverDialogTitle");
        new NbDialogOperator(addDriverTitle).cancel();
        
        // node JDBC-ODBC Bridge should be present always
        Node jdbcOdbcNode = new Node(driversNode, "JDBC-ODBC Bridge"); // NOI18N
        // "Connect Using ..."
        String connectUsingItem = Bundle.getString("org.netbeans.modules.db.resources.Bundle", "ConnectUsing");
        // open a dialog to create a new connection
        new ActionNoBlock(null, connectUsingItem).perform(jdbcOdbcNode);
        String newDatabaseConnectionTitle = Bundle.getString("org.netbeans.modules.db.resources.Bundle", "NewConnectionDialogTitle");
        new NbDialogOperator(newDatabaseConnectionTitle).cancel();
    }
    
    /** Test Help 
     * - open Help window from main menu (Help|Help Contents)
     */
    public void testHelp() {
        // increasing time because opening of help window can last longer on slower machines
        JemmyProperties.setCurrentTimeout("JMenuOperator.PushMenuTimeout", 60000);
        // open "Help|Contents"
        HelpOperator helpOper = HelpOperator.invoke();
        // check help window opened
        // title is "Help - All"
        helpOper.close();
    }
    
    /** Test Main Menu 
     * - open and close About dialog (main menu item Help|About)
     * - open and close Javadoc Index Search top component (main menu item View|Javadoc Index Search)
     */
    public void testMainMenu() {
        // open About dialog
        String helpItem = Bundle.getStringTrimmed("org.netbeans.core.Bundle", "Menu/Help"); 
        String aboutItem = Bundle.getStringTrimmed("org.netbeans.core.actions.Bundle", "About");
        new ActionNoBlock(helpItem+"|"+aboutItem, null).perform();
        String aboutTitle = Bundle.getString("org.netbeans.core.Bundle", "CTL_About_Title");
        new NbDialogOperator(aboutTitle).close();
        // open Window|Javadoc Index Search
        String viewItem = Bundle.getStringTrimmed("org.netbeans.core.Bundle", "Menu/Tools"); // NOI18N
        String javadocItem = Bundle.getStringTrimmed("org.netbeans.modules.javadoc.search.Bundle", "CTL_SEARCH_MenuItem");
        new Action(viewItem+"|"+javadocItem, null).perform();
        // "Javadoc Index Search"
        String javadocTitle = Bundle.getString("org.netbeans.modules.javadoc.search.Bundle", "CTL_SEARCH_WindowTitle");
        new TopComponentOperator(javadocTitle).close();
    }
    
    /** Test global shortcuts. 
     * - open and close new file wizard (CTRL+N)
     * - open and close Javadoc Index Search top component (Shift+F1)
     * - open and close new breakpoint dialog (Ctrl+Shift+F8)
     */
    public void testShortcuts() {
        // "Javadoc Index Search"
        String javadocTitle = Bundle.getString("org.netbeans.modules.javadoc.search.Bundle", 
                                               "CTL_SEARCH_WindowTitle");
        // test global shortcuts
        // open new wizard (Ctrl+N)
        Node node = new SourcePackagesNode(SAMPLE_PROJECT_NAME);
        // push Escape key to ensure there is no thing blocking shortcut execution
        MainWindowOperator.getDefault().pushKey(KeyEvent.VK_ESCAPE);
        NewFileAction newFileAction = new NewFileAction();
        try {
            newFileAction.performShortcut(node);
            new NewFileWizardOperator().close();
        } catch (TimeoutExpiredException e) {
            // need to be realiable test => repeat action once more to be sure it is problem in IDE
            // this time use events instead of Robot
            node.select();
            MainWindowOperator.getDefault().pushKey(KeyEvent.VK_N, KeyEvent.CTRL_MASK);
            new NewFileWizardOperator().close();
        }
        // open Javadoc Index Search (Shift+F1)
        Action searchAction = new Action(null, null, new Action.Shortcut(KeyEvent.VK_F1, KeyEvent.SHIFT_MASK));
        try {
            searchAction.perform(MainWindowOperator.getDefault());
            new TopComponentOperator(javadocTitle).close();
        } catch (TimeoutExpiredException e) {
            // need to be realiable test => repeat action once more to be sure it is problem in IDE
            // this time use events instead of Robot
            MainWindowOperator.getDefault().pushKey(KeyEvent.VK_F1, KeyEvent.SHIFT_MASK);
            new TopComponentOperator(javadocTitle).close();
        }
        // open new breakpoint dialog (Ctrl+Shift+F8)
        String newBreakpointTitle = Bundle.getString("org.netbeans.modules.debugger.ui.actions.Bundle", "CTL_Breakpoint_Title");
        ActionNoBlock breakpointAction = new ActionNoBlock(null, null, new Action.Shortcut(KeyEvent.VK_F8, KeyEvent.SHIFT_MASK|KeyEvent.CTRL_MASK));
        try {
            breakpointAction.perform(MainWindowOperator.getDefault());
            new NbDialogOperator(newBreakpointTitle).close();
        } catch (TimeoutExpiredException e) {
            // need to be realiable test => repeat action once more to be sure it is problem in IDE
            // this time use events instead of Robot
            MainWindowOperator.getDefault().pushKey(KeyEvent.VK_F8, KeyEvent.SHIFT_MASK|KeyEvent.CTRL_MASK);
            new NbDialogOperator(newBreakpointTitle).close();
        }
    }
    
    /** Test Source Editor
     * - opens sample class in Editor (context menu Open on the node)
     * - type abbreviation 'sout' at line 23 and then 'Hello'
     * - verify it is written 'System.out.println("Hello");'
     * - select the text and call copy from editor's context menu
     * - insert dummy text at line 24 , select it and paste the text in the clipboard
     * - select second 'Hello' and delete it by context menu
     * - insert 'Good bye' instead
     * - select fourth line, cut it and paste it at line 3
     */
    public void testEditor() {
        // open sample file in Editor
        SourcePackagesNode sourcePackagesNode = new SourcePackagesNode(SAMPLE_PROJECT_NAME);
        Node sample1Node = new Node(sourcePackagesNode, SAMPLE1_PACKAGE_NAME);
        JavaNode sampleClass1Node = new JavaNode(sample1Node, SAMPLE1_FILE_NAME);
        sampleClass1Node.open();
        // find open file in editor
        EditorOperator eo = new EditorOperator(SAMPLE1_FILE_NAME);
        eo.insert("\n", 23, 1); // NOI18N
        // Need to disable verification because shortcut "sout" is replaced
        // by "System.out.println("");" and "sout" is not found in Editor
        eo.setCaretPositionToLine(23);
        eo.txtEditorPane().setVerification(false);
        eo.txtEditorPane().typeText("sout "); // NOI18N
        eo.txtEditorPane().setVerification(true);
        eo.insert("Hello"); // NOI18N
        //eo.insert("System.out.println(\"Hello\");\n", 24, 1); // NOI18N
        final String textToCopy = "System.out.println(\"Hello\");"; // NOI18N
        eo.select(textToCopy);
        int oldDispatchingModel = JemmyProperties.getCurrentDispatchingModel();
        // "Copy"
        CopyAction copyAction = new CopyAction();
        try {
            copyAction.perform(eo);
        } catch (TimeoutExpiredException e) {
            // if not succed try it second time in Robot mode
            JemmyProperties.setCurrentDispatchingModel(JemmyProperties.ROBOT_MODEL_MASK);
            copyAction.perform(eo);
        } finally {
            // set previous dispatching model
            JemmyProperties.setCurrentDispatchingModel(oldDispatchingModel);
        }
        // wait until clipboard contains text to copy
        try {
            new Waiter(new Waitable() {
                public Object actionProduced(Object obj) {
                    try {
                        String text = Toolkit.getDefaultToolkit().getSystemClipboard().
                                        getContents(null).getTransferData(DataFlavor.stringFlavor).toString();
                        return textToCopy.equals(text) ? Boolean.TRUE:null;
                    } catch (UnsupportedFlavorException e) {
                        // The following exception can be thrown when clipboard is empty.
                        // java.awt.datatransfer.UnsupportedFlavorException: Unicode String
                        // at org.openide.util.datatransfer.ExTransferable$Empty.getTransferData(ExTransferable.java:461)
                        // Ignore this exception.
                        return null;
                    } catch (IOException ioe) {
                        throw new JemmyException("Failed getting clipboard content.", ioe);
                    }
                }
                public String getDescription() {
                    return("Clipboard contains "+textToCopy); // NOI18N
                }
            }).waitAction(null);
        } catch (Exception ie) {
            throw new JemmyException("Interrupted.", ie);
        }
        eo.insert("int xxxx;\n", 24, 1); // NOI18N
        eo.select("int xxxx;"); // NOI18N
        PasteAction pasteAction = new PasteAction();
        try {
            pasteAction.perform(eo);
        } catch (TimeoutExpiredException e) {
            // if not succed try it second time in Robot mode
            JemmyProperties.setCurrentDispatchingModel(JemmyProperties.ROBOT_MODEL_MASK);
            pasteAction.perform(eo);
        } finally {
            // set previous dispatching model
            JemmyProperties.setCurrentDispatchingModel(oldDispatchingModel);
        }
        eo.select("Hello", 1); // NOI18N
        // "Delete"
        DeleteAction deleteAction = new DeleteAction();
        deleteAction.performShortcut(eo);
        // wait Hello is deleted
        eo.txtEditorPane().waitText("System.out.println(\"\");"); // NOI18N
        eo.insert("Good bye"); // NOI18N
        // test cut action
        eo.select(4);
        // "Cut"
        CutAction cutAction = new CutAction();
        try {
            cutAction.perform(eo);
        } catch (TimeoutExpiredException e) {
            // if not succed try it second time in Robot mode
            JemmyProperties.setCurrentDispatchingModel(JemmyProperties.ROBOT_MODEL_MASK);
            cutAction.perform(eo);
        } finally {
            // set previous dispatching model
            JemmyProperties.setCurrentDispatchingModel(oldDispatchingModel);
        }
        // need to wait a little until editor content is refreshed after cut action
        new EventTool().waitNoEvent(500);
        // select from column 1 to 2 at line 3 
        eo.select(3, 1, 2);
        try {
            pasteAction.perform(eo);
        } catch (TimeoutExpiredException e) {
            // if not succed try it second time in Robot mode
            JemmyProperties.setCurrentDispatchingModel(JemmyProperties.ROBOT_MODEL_MASK);
            pasteAction.perform(eo);
        } finally {
            // set previous dispatching model
            JemmyProperties.setCurrentDispatchingModel(oldDispatchingModel);
        }
    }
    
    /** Test build and run.
     * - select sample class node and call "Build|Compile "SampleClass1.java"" main menu item
     * - wait until compilation finishes (track status bar)
     * - select sample class node and call "Run|Run Other|Run "SampleClass1.java"" main menu item
     * - wait until run finishes
     * - from context menu set sample project as main project
     * - call "Build|Build Main Project" main menu item
     * - wait until build finishes
     * - call "Run|Run Main Project" main menu item
     * - wait until run finishes
     */
    public void testBuildAndRun() {
        SourcePackagesNode sourcePackagesNode = new SourcePackagesNode(SAMPLE_PROJECT_NAME);
        Node sample1Node = new Node(sourcePackagesNode, SAMPLE1_PACKAGE_NAME);
        JavaNode sampleClass1Node = new JavaNode(sample1Node, SAMPLE1_FILE_NAME);
        // increase timeout to 60 seconds
        MainWindowOperator.getDefault().getTimeouts().setTimeout("Waiter.WaitingTime", 60000);
        // start to track Main Window status bar
        MainWindowOperator.StatusTextTracer stt = MainWindowOperator.getDefault().getStatusTextTracer();
        stt.start();
        // call Build|Compile main menu item
        new CompileAction().perform(sampleClass1Node);
        /* We cannot get this bundle - ti is probably loaded by a different classLoader
        // "Finished building SampleProject (run)"
        String finishedLabel = Bundle.getString("org.apache.tools.ant.module.bridge.impl.Bundle", 
                                                "FMT_finished_target_status",
                                                new String[] {SAMPLE_PROJECT_NAME});
         */
        // wait message "Building SampleProject (compile-single)..."
        stt.waitText("compile-single", true); // NOI18N
        // wait message "Finished building SampleProject (compile-single)"
        stt.waitText("compile-single", true); // NOI18N
        
        // "Run" 
        String runItem = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.Bundle", "Menu/RunProject");
        // "Run Other"
        String runOtherItem = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.Bundle", "Menu/RunProject/RunOther");
        // "Run File"
        String runFileItem = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.actions.Bundle", 
                                                     "LBL_RunSingleAction_Name",
                                                     new Object[] {new Integer(1), SAMPLE1_FILE_NAME});
        // call "Run|Run Other|Run "SampleClass1.java""
        new Action(runItem+"|"+runOtherItem+"|"+runFileItem, null).perform(sampleClass1Node);
        // wait message "Building SampleProject (run-single)..."
        stt.waitText("run-single", true); // NOI18N
        // wait message "Finished building SampleProject (run-single)"
        stt.waitText("run-single", true); // NOI18N
        // check Hello and Good bye was printed out to the output window
        OutputTabOperator outputOper = new OutputTabOperator("run-single"); //NOI18N
        outputOper.waitText("Hello"); //NOI18N
        outputOper.waitText("Good bye"); //NOI18N
        
        // "Set as Main Project"
        String setAsMainProjectItem = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.actions.Bundle", "LBL_SetAsMainProjectAction_Name");
        new Action(null, setAsMainProjectItem).perform(new ProjectsTabOperator().getProjectRootNode(SAMPLE_PROJECT_NAME));
        // "Build"
        String buildItem = Bundle.getStringTrimmed("org.netbeans.core.Bundle", "Menu/Build");
        // "Build Main Project"
        String buildMainProjectItem = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.actions.Bundle", "LBL_BuildMainProjectAction_Name");
        // call "Build|Build Main Project" main menu item
        new Action(buildItem+"|"+buildMainProjectItem, null).perform();
        // wait message "Building SampleProject (jar)..."
        stt.waitText("jar", true); // NOI18N
        // wait message "Finished building SampleProject (jar)"
        stt.waitText("jar", true); // NOI18N
        
        // Run Main Project
        String runMainProjectItem = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.actions.Bundle", "LBL_RunMainProjectAction_Name");
        // call "Run|Run Main Project" main menu item
        new Action(runItem+"|"+runMainProjectItem, null).perform();
        // wait message "Building SampleProject (run)..."
        stt.waitText("run", true); // NOI18N
        // wait message "Finished building SampleProject (run)"
        stt.waitText("run", true); // NOI18N

        stt.stop();
    }
    
    /** Test Debugging
     * - find sample class in editor
     * - select text 'System.out.println("Hello");' and push Shift+F8 to toggle breakpoint
     * - select text 'System.out.println("Good bye");' and call 'Toggle Breakpoint" context menu item
     * - run debugger from main menu ("Run "SampleClass1.java" in  Debugger")
     * - wait until first breakpoint is reached and call Continue from main menu
     * - wait until second breakpoint is reached and check 'Hello' is printed to output
     * - finish debugger by main menu action (Finish Debugger Session)
     * - delete sample class
     */
    public void testDebugging() throws Throwable {
        // "Run" 
        String runItem = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.Bundle", "Menu/RunProject");
        try {
            // find sample file in Editor
            EditorOperator eo = new EditorOperator(SAMPLE1_FILE_NAME);

            // if file not contains brpText from previous test cases, insert it
            String brpText = "System.out.println(\"Hello\");"; // NOI18N
            if(!eo.contains(brpText)) {
                eo.insert(brpText+"\n", 23, 1);
            }
            eo.select(brpText);
            
            // toggle breakpoint via Shift+F8
            eo.pushKey(KeyEvent.VK_F8, KeyEvent.CTRL_MASK);

            // wait breakpoint established
            new Waiter(new Waitable() {
                public Object actionProduced(Object editorOper) {
                    return ((EditorOperator)editorOper).getAnnotations(23).length == 1 ? Boolean.TRUE : null;
                }
                public String getDescription() {
                    return("Wait breakpoint established on line 23"); // NOI18N
                }
            }).waitAction(eo);
            
            // if file not contains second brpText from previous test cases, insert it
            brpText = "System.out.println(\"Good bye\");"; // NOI18N
            if(!eo.contains(brpText)) {
                eo.insert(brpText+"\n", 24, 1);
            }
            eo.select(brpText);
            // toggle breakpoint via pop-up menu
            // "Toggle Breakpoint"
            String toggleBrakpointItem = Bundle.getStringTrimmed("org.netbeans.modules.debugger.ui.actions.Bundle", "CTL_Toggle_breakpoint");
            // clickForPopup(0, 0) used in the past sometimes caused that menu
            // was opened outside editor area because editor roll up after 
            // text was selected
            new Action(null, toggleBrakpointItem).perform(eo.txtEditorPane());
            // wait second breakpoint established
            new Waiter(new Waitable() {
                public Object actionProduced(Object editorOper) {
                    return ((EditorOperator)editorOper).getAnnotations(24).length == 1 ? Boolean.TRUE : null;
                }
                public String getDescription() {
                    return("Wait breakpoint established on line 24"); // NOI18N
                }
            }).waitAction(eo);
            // start to track Main Window status bar
            MainWindowOperator.StatusTextTracer stt = MainWindowOperator.getDefault().getStatusTextTracer();
            stt.start();
            // start debugging
            // "Run Other"
            String runOtherItem = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.Bundle", "Menu/RunProject/RunOther");
            // "Debug "SampleClass1.java""
            String debugItem = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.actions.Bundle", 
                                                       "LBL_DebugSingleAction_Name", 
                                                       new Object[] {new Integer(1), SAMPLE1_FILE_NAME});
            new Action(runItem+"|"+runOtherItem+"|"+debugItem, null).perform();
            // check the first breakpoint reached
            // wait status text "Thread main stopped at SampleClass1.java:23"
            // increase timeout to 60 seconds
            MainWindowOperator.getDefault().getTimeouts().setTimeout("Waiter.WaitingTime", 60000);
            stt.waitText("23"); // NOI18N
            // continue debugging
            // "Continue"
            String continueItem = Bundle.getStringTrimmed("org.netbeans.modules.debugger.ui.actions.Bundle", "CTL_Continue_action_name");
            new Action(runItem+"|"+continueItem, null).perform();
            // check the second breakpoint reached
            // wait status text "Thread main stopped at SampleClass1.java:24"
            stt.waitText("24"); // NOI18N
            stt.stop();
            // check "Hello" was printed out in Output
            OutputTabOperator oto = new OutputTabOperator("debug-single"); // NOI18N
            // wait until text Hello is not written in to the Output
            oto.waitText("Hello"); // NOI18N
        } catch (Throwable th) {
            try {
                // capture screen before cleanup in finally clause is completed
                PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
            } catch (Exception e1) {
                // ignore it
            }
            throw th;
        } finally {
            // finish debugging
            // "Finish Debugger Session"
            String finishItem = Bundle.getStringTrimmed("org.netbeans.modules.debugger.ui.actions.Bundle", "CTL_KillAction_name");
            new Action(runItem+"|"+finishItem, null).perform();
            // check status line
            // "Debugger finished"
            String finishedLabel = Bundle.getString("org.netbeans.modules.debugger.jpda.ui.Bundle", "CTL_Debugger_finished");;
            MainWindowOperator.getDefault().waitStatusText(finishedLabel);
            // delete sample class
            SourcePackagesNode sourcePackagesNode = new SourcePackagesNode(SAMPLE_PROJECT_NAME);
            Node sample1Node = new Node(sourcePackagesNode, SAMPLE1_PACKAGE_NAME);
            JavaNode sampleClass1Node = new JavaNode(sample1Node, SAMPLE1_FILE_NAME);
            sampleClass1Node.delete();
            String confirmTitle = Bundle.getString("org.openide.explorer.Bundle", "MSG_ConfirmDeleteObjectTitle"); // NOI18N
            // "Confirm Object Deletion"
            new NbDialogOperator(confirmTitle).yes();
        }
    }

     /** Test Options  
      * - open Options window from main menu Tools|Options
      * - select IDE Configuration|System|System Settings node
      * - set Web Browser to "Swing HTML Browser"
      * - set Proxy Host to webcache
      * - set Proxy Port to 8080
      * - set Use Proxy to true
      * - close Options window
      */
    public void testOptions() {
        OptionsOperator optionsOper = OptionsOperator.invoke();
        // set exact comparator because in Japanese there is conflict with Filesystem settings
        optionsOper.treeTable().tree().setComparator(new Operator.DefaultStringComparator(true, true));
        // "IDE Configuration|System|System Settings"
        String systemSettings = Bundle.getString("org.netbeans.core.Bundle", "UI/Services/IDEConfiguration") + "|" +
                                Bundle.getString("org.netbeans.core.Bundle", "UI/Services/IDEConfiguration/System") + "|" +
                                Bundle.getString("org.netbeans.core.Bundle", "Services/org-netbeans-core-IDESettings.settings");
        optionsOper.selectOption(systemSettings);
        PropertySheetOperator pso = new PropertySheetOperator(optionsOper);
        // "Web Browser"
        String webBrowserLabel = Bundle.getString("org.netbeans.core.Bundle", "PROP_WWW_BROWSER");
        // "Swing HTML Browser"
        String swingBrowserLabel = Bundle.getString("org.netbeans.core.ui.Bundle", "Services/Browsers/SwingBrowser.ser");
        new Property(pso, webBrowserLabel).setValue(swingBrowserLabel);
        // "Proxy Host"
        String proxyHostLabel = Bundle.getString("org.netbeans.core.Bundle", "PROP_PROXY_HOST");
        new Property(pso, proxyHostLabel).setValue("webcache"); // NOI18N
        // "Proxy Port"
        String proxyPortLabel = Bundle.getString("org.netbeans.core.Bundle", "PROP_PROXY_PORT");
        new Property(pso, proxyPortLabel).setValue("8080"); // NOI18N
        // "Use Proxy"
        String useProxyLabel = Bundle.getString("org.netbeans.core.Bundle", "PROP_USE_PROXY");
        new Property(pso, useProxyLabel).setValue("true"); // NOI18N
        optionsOper.close();
    }
    
    /** 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-1 && ((Boolean)oper.getValueAt(i, 0)).booleanValue()) { // NOI18N
                    oper.clickOnCell(i, 0);
                }
                // if Update Center matches "Sun ONE Studio" and it is enabled/checked then click to uncheck
                if(oper.getValueAt(i, 1).toString().indexOf("Sun")>-1 && ((Boolean)oper.getValueAt(i, 0)).booleanValue()) { // NOI18N
                    oper.clickOnCell(i, 0);
                }
            }

            // set proxy
            // Proxy Configuration...
            String buttonProxyConfLabel = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "BNT_Proxy"); // NOI18N
            new JButtonOperator(updateCenterWizardOper, 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("webcache"); // NOI18N
            // Proxy Port: text field 
            new JTextFieldOperator(proxyDialog, 1).setText("8080"); // NOI18N
            proxyDialog.ok();
            
            // "Next >"
            updateCenterWizardOper.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();
            // wait JTree generated on next page
            new EventTool().waitNoEvent(500);
            // select Web|Applet module
            JTreeOperator tree = new JTreeOperator(updateCenterWizardOper);
            // "Development Update Center
            String devUCLabel = Bundle.getString("org.netbeans.modules.updatecenters.resources.Bundle", "Services/AutoupdateType/autoupdate_xml_type.settings");
            new Node(tree, devUCLabel+"|Web|Applet").select(); // NOI18N
            // add to right panel (push button with tooltip "Add")
            new JButtonOperator(updateCenterWizardOper, new ComponentChooser() {
                final String addLabel = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "HINT_Add"); // NOI18N
                public boolean checkComponent(Component comp) {
                    String tooltip = ((JComponent)comp).getToolTipText();
                    if(tooltip != null) {
                        return tooltip.equals(addLabel);
                    } else {
                        return false;
                    }
                }
                
                public String getDescription() {
                    return "JButton with tooltip equals "+addLabel;
                }
            }).push();
            // push "Next" button
            updateCenterWizardOper.btNext().pushNoBlock();
            // accept license agreement
            // "License Agreement"
            String licenceTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Licence_Title");
            // "Accept"
            String acceptLabel = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Licence_Accept");
            new JButtonOperator(new NbDialogOperator(licenceTitle), acceptLabel).push();
            // wait 30 s until download is done
            JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 30000); // NOI18N
            // "Done."
            String doneLabel = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "DownloadProgressPanel.jLabel1.doneText");
            new JLabelOperator(updateCenterWizardOper, doneLabel);
            updateCenterWizardOper.next();
            // accept certificate if requested
            if(!updateCenterWizardOper.btFinish().isEnabled()) {
                // "View Certificate..."
                String viewCertificateLable = Bundle.getStringTrimmed("org.netbeans.modules.autoupdate.Bundle", "BTN_View");
                new JButtonOperator(updateCenterWizardOper, viewCertificateLable).pushNoBlock();
                // click on "Accept" button in dialog
                String acceptCertificateLabel = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Certificate_Accept");
                // "Module Certificate"
                String certificateTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Certificate_Title");
                new JButtonOperator(new JDialogOperator(certificateTitle), acceptCertificateLabel).push();
            }
            // "Finish"
            updateCenterWizardOper.btFinish().push();
        } catch (JemmyException e) {
            // close possible error dialog
            // "Error"
            String errorTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Error");
            if(JDialogOperator.findJDialog(errorTitle, true, true) != null) {
                new NbDialogOperator(errorTitle).close();
            }
            // close Update center dialog
            if(updateCenterWizardOper != null) {
                updateCenterWizardOper.close();
            }
            throw e;
        } finally {
            // restore default timeout
            JemmyProperties.setCurrentTimeout("ComponentOperator.WaitStateTimeout", oldWaitStateTime);
        }
    }
    
    /** Test CVS
     * Cannot use real CVS repository. Only check commands are available in
     * like-CVS local repository.
     * - from main menu invoke "Versioning|CVS|Global CVS Check Out"
     * - in dialog about advanced mode check "do not show" check box and push command button to continue
     * - wait for CVS Checkout dialog and close it
     * - open versioning manager dialog from main menu Versioning|Versioning Manager
     * - click Add button
     * - type working directory in the wizard
     * - select CVS profile
     * - type the same directory in the repository text field
     * - click Next button
     * - click Finish button
     * - wait directory appears in the list in versioning manager
     * - close versioning manager
     * - open file from CVS workdir and on editor's tab call CVS|Update
     * - check Update tab is open in VCS Output
     * - call CVS|Update from popup on a package
     * - check Update tab is open in VCS Output
     */
    public void testCVS() {
        // from main menu invoke "Versioning|CVS|Global CVS Check Out", wait for dialog and close it
        // "Versioning"
        String versioningItem = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.actions.Bundle", "Menu/Versioning"); // NOI18N
        // "CVS"
        String cvsItem = Bundle.getStringTrimmed("org.netbeans.modules.vcs.profiles.cvsprofiles.config.Bundle", "CVS"); // NOI18N
        // "Global CVS Check Out..."
        String globalCheckoutItem = Bundle.getStringTrimmed("org.netbeans.modules.vcs.profiles.cvsprofiles.config.BundleGlobal", "CVS_GLOBAL_CHECKOUT"); // NOI18N
        new ActionNoBlock(versioningItem+"|"+cvsItem+"|"+globalCheckoutItem, null).perform();
        
        // handle dialog about advanced command mode
        // "Enabling Advanced CVS Command Options"
        String advancedTitle = Bundle.getString("org.netbeans.modules.vcscore.actions.Bundle", "CommandMenu.firstTimer.title");
        NbDialogOperator advancedDialogOper = new NbDialogOperator(advancedTitle);
        // "Do Not Show This Dialog Box Again"
        String checkBoxLabel = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.actions.Bundle", "CommandMenu.firstTimerBox");
        new JCheckBoxOperator(advancedDialogOper, checkBoxLabel).setSelected(true);
        new JButtonOperator(advancedDialogOper, globalCheckoutItem).pushNoBlock();
        
        // "CVS Checkout"
        String checkoutTitle = Bundle.getStringTrimmed("org.netbeans.modules.vcs.profiles.cvsprofiles.config.BundleGlobal", "COMMAND_CHECKOUT_Label"); // NOI18N
        new NbDialogOperator(checkoutTitle).close();

        // Add local CVS working directory
        VersioningManagerOperator vmo = VersioningManagerOperator.invoke();
        vmo.add();
        VCSProfileStepOperator profileStepOper = new VCSProfileStepOperator();
        VCSProfileOperator profileOper = profileStepOper.getProfileOperator();
        String workdir = System.getProperty("netbeans.user")+File.separator+SAMPLE_PROJECT_NAME+File.separator+"src"; // NOI18N
        profileOper.setWorkingDirectory(workdir);
        profileOper.setProfile(profileOper.CVS_UNIX);
        // need to wait because values are initialized later
        new EventTool().waitNoEvent(1000);
        // Perform Checkout check box should be checked
        profileOper.cbNextStep().waitSelected(true);
        
        profileOper.setCVSRepository(workdir);
        profileStepOper.next();
        profileStepOper.finish();
        // wait directory is added and close the manager
        vmo.selectDirectory(workdir);
        vmo.close();

        // open sample class
        Node sample1Node = new Node(new SourcePackagesNode(SAMPLE_PROJECT_NAME), SAMPLE1_PACKAGE_NAME);
        Node sampleClass1Node = new Node(sample1Node, SAMPLE1_FILE_NAME);
        new OpenAction().perform(sampleClass1Node);
        // try Update command from editor's pop-up menu
        EditorOperator eo = new EditorOperator(SAMPLE1_FILE_NAME);
        CVSUpdateAction cvsUpdateAction = new CVSUpdateAction();
        eo.pushMenuOnTab(cvsUpdateAction.getPopupPath());
        // "Update"
        String updateItem = Bundle.getStringTrimmed("org.netbeans.modules.vcs.profiles.cvsprofiles.config.Bundle", "CVS_UPDATE"); // NOI18N
        // "Update - SampleClass1.java"
        String updateTitle = Bundle.getString("org.netbeans.modules.vcs.profiles.cvsprofiles.visualizers.update.Bundle", 
                                              "CvsUpdateVisualizer.title_one",
                                              new Object[] {updateItem, SAMPLE1_FILE_NAME});
        VCSOutputOperator vcsOutputOper = new VCSOutputOperator();
        // wait until Update tab is opened
        vcsOutputOper.selectTab(updateTitle);
        
	/*
        // try Update pop-up menu command on sample1 package
        cvsUpdateAction.perform(sample1Node);
        // "Update - sample1"
        String updateTitleSampleFolder = Bundle.getString("org.netbeans.modules.vcs.profiles.cvsprofiles.visualizers.update.Bundle",
                                                    "CvsUpdateVisualizer.title_one",
                                                    new Object[] {updateItem, SAMPLE1_PACKAGE_NAME});
        // wait until Update tab is opened
        vcsOutputOper.selectTab(updateTitleSampleFolder);
	*/
        // close VCS Output
        vcsOutputOper.close();
    }
    
    /** Test XML
     * It checks XML Entity Catalogs node is present in the Runtime tab,
     * creates an XML document from template, checks XML, validates XML,
     * generates DTD, checks DTD and generates DOM Tree Scanner.
     */
    public void testXML() {
        // check XML Entity Catalogs
        
        // "XML Entity Catalogs"
        String catalogsLabel = Bundle.getString("org.netbeans.modules.xml.catalog.Bundle", "TEXT_catalog_root");
        // "Depl.Desc.Catalog"
        String deplDescLabel = Bundle.getString("org.netbeans.modules.web.dd.Bundle", "LBL_DDCatalog");
        String publicID = "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN";
        Node catalogNode = new Node(RuntimeTabOperator.invoke().getRootNode(), 
                                    catalogsLabel+"|"+
                                    deplDescLabel+"|"+
                                    publicID);
        // view and close it
        new ViewAction().perform(catalogNode);
        new EditorOperator(publicID).close();
        
        // create an XML file

        Node sample1Node = new Node(new SourcePackagesNode(SAMPLE_PROJECT_NAME), SAMPLE1_PACKAGE_NAME);
        // create xml package
        // "Java Classes"
        String javaClassesLabel = Bundle.getString("org.netbeans.modules.java.Bundle", "Templates/Classes");
        // "Java Package"
        String packageLabel = Bundle.getString("org.netbeans.modules.java.Bundle", "Templates/Classes/Package");
        NewFileWizardOperator.create(SAMPLE_PROJECT_NAME, javaClassesLabel, packageLabel, null, "xml"); // NOI18N
        Node xmlNode = new Node(new SourcePackagesNode(SAMPLE_PROJECT_NAME), "xml"); //NOI18N
        // "XML"
        String xmlCategory = Bundle.getString("org.netbeans.api.xml.resources.Bundle", "Templates/XML");
        // "XML Document"
        String xmlDocument = Bundle.getString("org.netbeans.modules.xml.core.resources.Bundle", "Templates/XML/XMLWizard.xml");
        NewFileWizardOperator.invoke(xmlNode, xmlCategory, xmlDocument);
        NewFileNameLocationStepOperator nameStepOper = new NewFileNameLocationStepOperator();
        nameStepOper.setObjectName("XMLDocument");  // NOI18N
        nameStepOper.next();
        nameStepOper.finish();
        // wait node is present
        Node xmlDocumentNode = new Node(xmlNode, "XMLDocument.xml"); // NOI18N
        // wait xml document is open in editor
        new EditorOperator("XMLDocument.xml").close();  // NOI18N

        // "Check XML"
        
        String checkXMLItem = Bundle.getStringTrimmed("org.netbeans.modules.xml.tools.actions.Bundle", "NAME_Check_XML");
        // invoke context action to check xml
        new Action(null, checkXMLItem).perform(xmlDocumentNode);
        // "XML check"
        String xmlCheckTitle = Bundle.getString("org.netbeans.modules.xml.core.actions.Bundle", "TITLE_XML_check_window");
        // find and close an output with the result of xml check
        new OutputTabOperator(xmlCheckTitle).close();
        
        // "Validate XML"
        
        String validateItem = Bundle.getStringTrimmed("org.netbeans.modules.xml.tools.actions.Bundle", "NAME_Validate_XML");
        // invoke context action to validate xml
        new Action(null, validateItem).perform(xmlDocumentNode);
        // find and close an output with the result of xml validation
        new OutputTabOperator(xmlCheckTitle).close();
        
        // "Generate DTD..."
        
        String generateDTDItem = Bundle.getStringTrimmed("org.netbeans.modules.xml.tools.generator.Bundle", "PROP_GenerateDTD");
        new ActionNoBlock(null, generateDTDItem).perform(xmlDocumentNode);
        // "Select File Name"
        String selectTitle = Bundle.getString("org.netbeans.modules.xml.tools.generator.Bundle", "PROP_fileNameTitle");
        NbDialogOperator selectDialog = new NbDialogOperator(selectTitle);
        // name has to be set because of issue http://www.netbeans.org/issues/show_bug.cgi?id=46049
        new JTextFieldOperator(selectDialog).setText("DTD");
        String selectLabel = Bundle.getString("org.netbeans.modules.xml.tools.generator.Bundle", "BK0002");
        new JButtonOperator(selectDialog, selectLabel).push();
        // wait DTD is open in editor
        new EditorOperator("DTD.dtd").close();  // NOI18N
        Node dtdNode = new Node(xmlNode, "DTD.dtd"); // NOI18N
        
        // "Check DTD"
        
        String checkDTDItem = Bundle.getStringTrimmed("org.netbeans.modules.xml.tools.actions.Bundle", "NAME_Validate_DTD");
        new Action(null, checkDTDItem).perform(dtdNode);
        // find and close an output with the result of dtd check
        new OutputTabOperator(xmlCheckTitle).close();
        
        // "Generate DOM Tree Scanner"
        
        String generateScannerItem = Bundle.getStringTrimmed("org.netbeans.modules.xml.tools.generator.Bundle", "PROP_GenerateDOMScanner");
        new ActionNoBlock(null, generateScannerItem).perform(dtdNode);
        selectDialog = new NbDialogOperator(selectTitle);
        new JButtonOperator(selectDialog, selectLabel).push();
        // wait Scanner is open in editor
        new EditorOperator("DTDScanner.java").close();  // NOI18N
        Node scannerNode = new Node(xmlNode, "DTDScanner.java"); // NOI18N
        
        // clean up
        
        // delete xml folder and its contents
        DeleteAction deleteAction = new DeleteAction();
        deleteAction.perform(xmlNode);
        // "Confirm Object Deletion"
        String confirmTitle = Bundle.getString("org.openide.explorer.Bundle", "MSG_ConfirmDeleteObjectTitle"); // NOI18N
        new NbDialogOperator(confirmTitle).yes();
        xmlNode.waitNotPresent();
    }

    /** Closes help window if any. It should not stay open between test cases.
     *  Otherwise it can break next tests.
     */
    private static void closeHelpWindow() {
        Window helpWindow = WindowOperator.findWindow(new ComponentChooser() {
            public boolean checkComponent(Component comp) {
                WindowOperator winOper = new WindowOperator((Window)comp);
                winOper.setOutput(TestOut.getNullOutput());
                return  null != winOper.findSubComponent(new ComponentChooser() {
                    public boolean checkComponent(Component comp) {
                        return comp.getClass().getName().startsWith("javax.help.JHelp"); //NOI18N
                    }
                    public String getDescription() {
                        return("any javax.help");  //NOI18N
                    }
                });
            }
            public String getDescription() {
                return "containing any javax.help.JHelp component";  //NOI18N
            }
        });
        if(helpWindow != null) {
            new WindowOperator(helpWindow).close();
        }
    }
}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

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.