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 org.netbeans.test.java.gui.imt.WalkThrough;

import java.io.PrintWriter;
import junit.textui.TestRunner;
import org.netbeans.jellytools.Bundle;
import org.netbeans.jellytools.RepositoryTabOperator;
import org.netbeans.jellytools.nodes.JavaNode;
import org.netbeans.jemmy.EventTool;
import org.netbeans.junit.NbTest;
import org.netbeans.junit.NbTestSuite;
import org.netbeans.modules.java.imptool.ImpToolSettings;
import org.netbeans.test.java.XGUIRunner;
import org.netbeans.test.oo.gui.jelly.java.imt.Page1;
import org.netbeans.test.oo.gui.jelly.java.imt.Page2;
import org.netbeans.test.oo.gui.jelly.java.imt.Page3;
import org.openide.src.ClassElement;

/**
 * @author Jan Becicka
 *
 */

public class WalkThrough extends XGUIRunner {
    
    private static char sep = System.getProperty("file.separator").charAt(0);

    public static void main(java.lang.String[] args) {
        TestRunner.run(suite());
    }
    
    public WalkThrough() {
        super("");
    }
    
    public WalkThrough(java.lang.String testName) {
        super(testName);
    }
    
    public static NbTest suite() {
        return new NbTestSuite(WalkThrough.class);
    }
    
    public boolean go(Object o, PrintWriter log) throws Exception {
        
        //set properties 
        ClassElement.forName(packageName + "." + name).getSource().prepare().waitFinished();

        /*
         Options.show();
        Options opt = new Options();
        PropertiesWindow pw = opt.getPropertiesWindow("Editing"+opt.delim+"Java Sources"+opt.delim+"Import Management Tool Settings");
        
        pw.switchToPropertiesTab();
        pw.setSelectedItem("Guessing Strategy for Unresolved Identifiers", 1);
        
        pw.setText("List of Well-Known Packages", "java.lang.reflect");
        pw.setText("Maximum of Fully Qualified Names in Source", "2");
        
        pw.close();
        opt.close();
         */
        
        ImpToolSettings its = (ImpToolSettings) ImpToolSettings.findObject(ImpToolSettings.class, true);
        its.setResolveStrategy(ImpToolSettings.RESOLVE_WELLKNOWN);
        its.setResolvePlaces(new String[]{"java.lang.reflect"});
        its.setMaxFqn(2);

        //select the Test node in the Explorer
        String node = System.getProperty("work.dir").replace('\\', '/').replace('/', sep);

        node = node  + sep + "tests" + sep + "qa-functional" + sep + "testfs"
        + "|"
        + packageName.replace('.','|') + "|" + name;
        
        
        RepositoryTabOperator.invoke();
        JavaNode javaNode = new JavaNode(node);
        javaNode.select();
        
        javaNode.performPopupActionNoBlock(Bundle.getStringTrimmed("org.netbeans.core.Bundle", "Menu/Tools") + '|' + Bundle.getString("org.netbeans.modules.java.imptool.Bundle", "LAB_ImpToolAction"));
        
        //imt
        Page1 p1 = new Page1();
        p1.setPackageName("Vector", "java.util");
        p1.next();
        
        Page2 p2 = new Page2();
        //does not work on Linux!!!
        //assertEquals("There should be 21 identifiers in the list", p2.getSize(),21);
        p2.setAction("java.util.Vector",2);
        p2.setAction("java.awt.event.WindowAdapter",2);
        p2.setAction("java.awt.event.ActionListener",2);
        p2.setAction("java.lang.System",2);
        p2.setAction("java.lang.Runnable",2);
        p2.setAction("java.lang.reflect.Method",2);
        p2.setAction("javax.swing.JScrollPane",2);
        p2.setAction("javax.swing.JTabbedPane",2);
        p2.setAction("javax.swing.ButtonGroup",2);
        p2.setAction("javax.swing.JButton",2);
        p2.setAction("javax.swing.JFrame",2);
        p2.setAction("java.awt.BorderLayout",2);
        p2.setAction("java.awt.Scrollbar",2);

        p2.setAction("java.awt.Panel",2);

        p2.setAction("java.awt.Choice",2);
        p2.setAction("java.io.Serializable",2);
        
        p2.next(); 

        Page3 p3 = new Page3();
        p3.setAction("java.awt",1);
        p3.finish();
        new EventTool().waitNoEvent(1500);
        return true;
    }
    
    
    protected void setUp() {
        name = "WalkThrough";
        packageName = "org.netbeans.test.java.testsources";
    }
}
... 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.