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 org.netbeans.jellytools.modules.xml.actions;

import junit.textui.TestRunner;
import org.netbeans.jellytools.NbDialogOperator;
import org.netbeans.jellytools.actions.Action;
import org.netbeans.jellytools.modules.css.actions.CheckCSSAction;
import org.netbeans.jellytools.modules.css.actions.CopyHTMLStyleAction;
import org.netbeans.jellytools.modules.css.actions.CopyXMLStyleAction;
import org.netbeans.jellytools.modules.xml.catalog.nodes.XMLEntityCatalogsNode;
import org.netbeans.jellytools.nodes.Node;
import org.netbeans.jemmy.EventDispatcher;
import org.netbeans.tests.xml.JXTest;

/** Checks XSL Transformation action. */

public class ActionsTest extends JXTest {
    private static final int CLASS = 0;
    private static final int TPATH = 1;
    private static final int ATTRS = 2;
    
    /** Creates new XMLNodeTest */
    public ActionsTest(String testName) {
        super(testName);
    }
    
    // TESTS ///////////////////////////////////////////////////////////////////
    
    public void test() {
        //documentActionTest(new CheckDTDAction(), "PA",  "states");
        //documentActionTest(new CheckXMLAction(),    "PAS",  "XMLDocument");
        ////documentActionTest(new EditScenariosAction(), "PASc",  "stylesheet"); //!!! #26559
        //documentActionTest(new GenerateCSSAction(), "PAc",  "states");
        //documentActionTest(new GenerateDOMTreeScannerAction(), "PAc",  "states");
        //documentActionTest(new GenerateDTDAction(), "PAc",  "XMLDocument");
        //documentActionTest(new GenerateDocumentationAction(), "PAc",  "states");
        //documentActionTest(new NewAttributeAction(), "Pc",  "XMLDocument" + DELIM + "root");
        //documentActionTest(new NewCDATAction(), "Pc",  "XMLDocument" + DELIM + "root");
        //documentActionTest(new NewCharRefAction(), "Pc",  "XMLDocument" + DELIM + "root");
        //documentActionTest(new NewCommentAction(),  "Pc",   "XMLDocument");
        //documentActionTest(new NewDoctypeAction(),  "Pc",   "XMLDocument");
        //documentActionTest(new NewElementAction(),  "Pc",   "XMLDocument");
        //documentActionTest(new NewEntityReferenceAction(),  "Pc",   "XMLwithDTD" + DELIM + "root");
        //documentActionTest(new NewPIAction(),       "Pc",   "XMLDocument");
        //documentActionTest(new NewTextAction(),  "Pc",   "XMLDocument" + DELIM + "root");
        //documentActionTest(new NormalizeElementAction(),  "P",   "XMLDocument" + DELIM + "root");
        //documentActionTest(new ReloadDocumentAction(), "PA",  "XMLDocument");
        //documentActionTest(new SAXDocumentHandlerWizardAction(), "PAc",  "states");
        //documentActionTest(new TransformAction(),   "PASc", "XMLDocument");
        //documentActionTest(new ValidateXMLAction(), "PA",  "XMLDocument");
        
        //documentActionTest(new CheckCSSAction(), "PA",  "CascadeStyleSheet");
        //documentActionTest(new CopyXMLStyleAction(), "PA",  "CascadeStyleSheet");
        //documentActionTest(new CopyHTMLStyleAction(), "PA",  "CascadeStyleSheet");
        
        //catalogActionTest(new MountCatalogAction(), "PAc",  "");

        //!!! should be a stand-alone tests:
        //!!! a) needs mounted NB Catalog; b) unmount test have to mount unmounted catalog
        
        //catalogActionTest(new RefreshCatalogAction(), "PA",  "NetBeans Catalog");
        //catalogActionTest(new UnmountCatalogAction(), "PA",  "NetBeans Catalog"); 
    }
    
    // LIB /////////////////////////////////////////////////////////////////////
    
    /** @see actionTest(Action, String, Node) */
    private boolean catalogActionTest(Action action, String attrs, String treePath) {
        return actionTest(action, attrs, XMLEntityCatalogsNode.getInstance().getCatalog(treePath));
    }
    
    /** @see actionTest(Action, String, Node) */
    private boolean documentActionTest(Action action, String attrs, String treePath) {
        return actionTest(action, attrs, findDataNode(treePath));
    }
    
    /** Tests org.netbeans.jellytools.actions.Action's subclases.
     * @param action tested action
     * @param attrs can consist from
     * 
  • P - test performPopup() *
  • A - test performAPI() *
  • S - test performShortcut() *
  • c - close dialog after each perform method * @param treePath relative path to 'data' folder delimited by DELIM * @return true if test passes esle false */ private boolean actionTest(Action action, String attrs, Node node) { boolean pass = true; log(""); try { boolean close = (attrs.indexOf('c') != -1); // if (attrs.indexOf('S') != -1) { // log(" "); // action.performShortcut(node); // if (close) cancelDialog(); // log(" "); // } if (attrs.indexOf('P') != -1) { log(" "); action.performPopup(node); if (close) cancelDialog(); else sleepTest(1000); log(" "); } if (attrs.indexOf('A') != -1) { log(" "); action.performAPI(node); if (close) cancelDialog(); else sleepTest(1000); log(" "); } } catch (Exception ex) { pass = false; log("Failed:", ex); } finally { log("<\\test>"); } return pass; } /** Waits for 3 secs and close the first dialog. */ private void cancelDialog() { try { EventDispatcher.waitQueueEmpty(); } catch (Exception e) { /* do nothing */ } sleepTest(1000); new NbDialogOperator("").cancel(); } // MAIN //////////////////////////////////////////////////////////////////// public static void main(String[] args) throws Exception { System.setProperty("xmltest.dbgTimeouts", "true"); logIntoConsole(true); TestRunner.run(ActionsTest.class); } }
  • ... 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.