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

package complete.common;

import org.netbeans.jellytools.*;
import org.netbeans.jellytools.nodes.Node;
import org.netbeans.jellytools.actions.*;
import org.netbeans.jellytools.modules.vcscore.VCSCommandsOutputOperator;
import org.netbeans.jellytools.modules.vcsgeneric.VCSCommandOperator;
import org.netbeans.jellytools.modules.vcsgeneric.wizard.*;
import org.netbeans.jellytools.properties.*;
import org.netbeans.jemmy.operators.*;

/** XTest / JUnit test class performing check of Command editor.
 * @author Jiri Kovalsky
 * @version 1.0
 */
public class Commands extends org.netbeans.jellytools.JellyTestCase {
    
    public static String MOUNT_MENU = "Versioning|Mount Version Control|Generic VCS";
    
    /** Constructor required by JUnit.
     * @param testName Method name to be used as testcase.
     */
    public Commands(String testName) {
        super(testName);
    }
    
    /** Method used for explicit test suite definition.
     * @return Commands test suite.
     */
    public static junit.framework.Test suite() {
        junit.framework.TestSuite suite = new org.netbeans.junit.NbTestSuite();
        suite.addTest(new Commands("testCommandEditor"));
        suite.addTest(new Commands("testPopupSubmenu"));
        suite.addTest(new Commands("testPopupDevider"));
        suite.addTest(new Commands("testPopupAction"));
        suite.addTest(new Commands("testCustomizeMenu"));
        suite.addTest(new Commands("testSetupCommand"));
        suite.addTest(new Commands("testInvokeCommand"));
        suite.addTest(new Commands("testConfirmationMessages"));
        return suite;
    }
    
    /** Use for internal test execution inside IDE.
     * @param args Command line arguments.
     */
    public static void main(java.lang.String[] args) {
        junit.textui.TestRunner.run(suite());
    }
    
    /** Method called before each testcase to redirect system output.
     */
    protected void setUp() {
        org.netbeans.jemmy.JemmyProperties.setCurrentOutput(org.netbeans.jemmy.TestOut.getNullOutput());
    }
    
    /** Method will create a file and capture the screen together with saving the exception.
     */
    private void captureScreen(Exception exc) throws Exception {
        java.io.File dumpFile = new java.io.File("dump.png");
        try {
            dumpFile = new java.io.File(getWorkDirPath() + "/dump.png");
            java.io.File excFile = new java.io.File(getWorkDirPath() + "/exception.txt");
            dumpFile.getParentFile().mkdirs();
            dumpFile.createNewFile();
            java.io.PrintWriter writer = new java.io.PrintWriter(new java.io.FileWriter(excFile));
            exc.printStackTrace(writer);
            writer.flush();
            writer.close();
        } catch(java.io.IOException e) {}
        org.netbeans.jemmy.util.PNGEncoder.captureScreen(dumpFile.getAbsolutePath());
    }
    
    /** Checks that command editor can be invoked and contains all of its components.
     * @throws Exception any unexpected exception thrown during test.
     */
    public void testCommandEditor() throws Exception {
        try {
            System.out.print(".. Testing command editor ..");
            new ActionNoBlock(MOUNT_MENU, null).perform();
            VCSWizardProfile wizardProfile = new VCSWizardProfile();
//            wizardProfile.checkOnlyCompatibleProfiles(false);
            wizardProfile.setProfile(VCSWizardProfile.EMPTY_UNIX);
            wizardProfile.next();
            VCSWizardAdvanced wizardAdvanced = new VCSWizardAdvanced();
            wizardAdvanced.editCommands();
            CommandEditor commandEditor = new CommandEditor();
            commandEditor.verify();
            Node node = new Node(commandEditor.treeCommands(), "Empty");
            node.select();
            String[] commands = new String[] {"Refresh", "Refresh Recursively", "(separator)", "Check in", "Check out",
            "Lock", "Unlock", "Add", "Remove"};
            int count = commands.length;
            for (int i=0; i
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

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.