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

package complete.cvs_profile;

import complete.GenericStub;
import complete.GenericStub.GenericNode;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.swing.JTabbedPane;
import org.netbeans.jellytools.NbDialogOperator;
import org.netbeans.jellytools.actions.Action;
import org.netbeans.jellytools.actions.CustomizeAction;
import org.netbeans.jellytools.actions.PropertiesAction;
import org.netbeans.jellytools.modules.vcscore.VCSCommandsOutputOperator;
import org.netbeans.jellytools.modules.vcsgeneric.VCSFilesystemCustomizerDialog;
import org.netbeans.jellytools.modules.vcsgeneric.actions.VCSGenericMountAction;
import org.netbeans.jellytools.modules.vcsgeneric.wizard.GenericVCSMountCVSProfileWizard;
import org.netbeans.jellytools.modules.vcsgeneric.wizard.GenericVCSMountWizard;
import org.netbeans.jellytools.modules.vcsgeneric.wizard.VCSWizardAdvanced;
import org.netbeans.jellytools.modules.vcsgeneric.wizard.VCSWizardProfile;
import org.netbeans.jemmy.operators.JCheckBoxOperator;
import org.netbeans.jemmy.operators.JTabbedPaneOperator;
import org.netbeans.junit.AssertionFailedErrorException;
import org.netbeans.modules.vcs.advanced.wizard.mount.MountWizardData;
import org.netbeans.modules.vcs.advanced.wizard.mount.MountWizardIterator;
import org.netbeans.jellytools.modules.vcsgeneric.cvs_profile.*;
import org.openide.filesystems.FileSystem;
import org.openide.util.Utilities;
import util.History;



public abstract class CVSStub extends GenericStub {
    
    public CVSStub(String testName) {
        super(testName);
        nRootPrefix = "CVS ";
    }
    
    static FileSystem sfs = null;
    
    protected FileSystem getFileSystem () {
        return sfs;
    }
    
    protected void setFileSystem (FileSystem fs) {
        sfs = fs;
    }
  
    protected void prepareServer (String dir) {
    }
    
    protected void mountVCSFileSystem () {
/*        new Action ("Versioning|Mount Version Control", null).performMenu (); // workaround for issue #31026
        new Action ("Tools", null).performMenu (); // workaround for issue #31026
        sleep (10000);
        new Action ("Versioning|Mount Version Control", null).performMenu (); // workaround for issue #31026
        new Action ("Tools", null).performMenu (); // workaround for issue #31026*/
        new VCSGenericMountAction().perform();
        GenericVCSMountWizard genericwizard = new GenericVCSMountWizard();
        genericwizard.verify();
        genericwizard.setWorkingDirectory("");
        genericwizard.txtWorkingDirectory().typeText (clientDirectory);

        String profile = "CVS";

        MountWizardIterator mwi = MountWizardIterator.singleton();
        MountWizardData mwd = mwi.getData();
        Method m;
        try {
            m = MountWizardData.class.getDeclaredMethod("getFileSystem", new Class[0]);
        } catch (NoSuchMethodException e) {
            throw new AssertionFailedErrorException (e);
        }
        Object o;
        try {
            m.setAccessible(true);
            o = m.invoke(mwd, new Object[0]);
        } catch (IllegalAccessException e) {
            throw new AssertionFailedErrorException (e);
        } catch (InvocationTargetException e) {
            throw new AssertionFailedErrorException (e);
        }
        FileSystem fs = (FileSystem) o;
        history = new History (fs, info);
        history.breakpoint();

        genericwizard.cboProfileComboBox().setVerification(false);
        genericwizard.selectProfileComboBox(profile);
        genericwizard.cboProfileComboBox().setVerification(true);
        history.waitCommand("AUTO_FILL_CONFIG", "");
        sleep (5000);

        GenericVCSMountCVSProfileWizard wizard = new GenericVCSMountCVSProfileWizard ();
        wizard.verify ();

        // stabilization
        wizard.setWorkingDirectory("");
        wizard.txtWorkingDirectory().typeText (clientDirectory);
        
        wizard.setCVSServerName(""); // workaround for issue #37380
        wizard.setUserName(""); // workaround for issue #37380
        wizard.selectCVSServerType("local");
        wizard.setRepositoryPath ("");
        wizard.txtRepositoryPath ().typeText (serverDirectory);
        wizard.useCommandLineCVSClient(); // workaround for issue #
        wizard.finish();
        
        closeAllProperties();
    }
        
    protected void prepareClient () {
        // advanced mode
        new CustomizeAction ().performPopup (root.cvsNode ());
        VCSFilesystemCustomizerDialog dia = new VCSFilesystemCustomizerDialog ();
        dia.checkAdvancedMode(true);
        dia.close ();
        dia.waitClosed ();

        // init
        root.cvsNode ().cVSInit ();
        history.getWaitCommand("Init", root.history ());

        // checkout
        root.cvsNode ().cVSCheckOut();
        CVSCheckoutFolderAdvDialog co = new CVSCheckoutFolderAdvDialog();
        co.setModuleS(hRoot);
        co.checkPruneEmptyFolders(false);
        co.oK();
        root.waitHistory("Check Out");

        // workaround - probably jelly issue - if not used, popup menu does not work in versioning frame
        // !!! error - commented because of issue #37837
        // VCSCommandsOutputOperator voo = new VCSCommandsOutputOperator ("Check Out");
        closeAllVCSOutputs();
    }
    
    protected void refresh (GenericNode node) {
        node.cvsNode ().cVSRefresh ();
        assertTrue("Refresh command failed", history.waitCommand("Refresh", node.history ()));
    }

    protected void refreshRecursively (GenericNode node) {
        node.cvsNode ().cVSRefreshRecursively();
        assertTrue("Refresh recursively command failed", history.waitCommand("Refresh Recursively", node.history ()));
    }

    protected void addDirectory (GenericNode node) {
        node.cvsNode ().cVSAdd();
        CVSAddFolderAdvDialog add = new CVSAddFolderAdvDialog ();
        add.oK ();
        add.waitClosed();
//        assertInformationDialog(null);
        assertTrue("Add folder command failed", history.waitCommand("Add", node.history ()));
        node.waitStatus (null);
    }
    protected void addFile (GenericNode node, String desc) {
        node.cvsNode ().cVSAdd();
        CVSAddFileAdvDialog add = new CVSAddFileAdvDialog ();
        if (desc != null) {
            add.txtFileDescription().setCaretPosition(0);
            add.txtFileDescription().typeText(desc);
        }
        add.oK ();
        add.waitClosed();
        assertTrue("Add file command failed", history.waitCommand("Add", node.history ()));
        node.waitStatus ("Locally Added", false);
    }

    protected void commitFile (GenericNode node, String branch, String desc) {
        node.cvsNode ().cVSCommit();
        CVSCommitFileAdvDialog com = new CVSCommitFileAdvDialog ();
        if (branch != null)
            com.setCommitToBranch(branch);
        if (desc != null) {
            com.txtEnterReason().setCaretPosition(0);
            com.txtEnterReason().typeText(desc);
        }
        com.oK ();
        com.waitClosed();
        assertTrue("Commit file command failed", history.waitCommand("Commit", node.history ()));
        node.waitStatus ("Up-to-date", false);
    }
    
    protected void addTagFile (GenericNode node, String name, boolean branch) {
        node.cvsNode().cVSBranchingAndTaggingAddTag();
        CVSAddTagFileAdvDialog add = new CVSAddTagFileAdvDialog ();
        add.checkBranchTag(branch);
        add.setTagName (name);
        add.oK ();
        add.waitClosed ();
        assertInformationDialog(null);
        assertTrue("Add tag file command failed", history.waitCommand("Add Tag", node.history ()));
    }
    
}
... 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.