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.
 */

/*
 * CreatingPropertiesFileFromExplorer2.java
 *
 * Created on 19. brezen 2002, 11:07
 *
 * This is autometed test for netBeans version 34. Test has been
 * writed in Jelly2 ( see http://testtools.netbeans.org )
 */

package org.netbeans.properties.jelly2tests.suites.creating_properties_file;

import java.io.File;
import javax.swing.tree.TreePath;
import junit.textui.TestRunner;
import org.netbeans.jellytools.*;
import org.netbeans.jellytools.nodes.FilesystemNode;
import org.netbeans.jellytools.nodes.JavaNode;
import org.netbeans.jellytools.nodes.PropertiesNode;
import org.netbeans.jemmy.operators.JPopupMenuOperator;
import org.netbeans.jemmy.operators.JTreeOperator;
import org.netbeans.junit.NbTestSuite;
import org.netbeans.properties.jelly2tests.operators.PropertiesEditorOperator;


/**
 *
 * @author  Petr Felenda - QA Engineer
 */
public class CreatingPropertiesFileFromExplorer2 extends JellyTestCase {
    
    /*
     * Definition of member variables and objects
     */
    final String FILE_NAME = "testFile_CreatingPropertiesFileFromExplorer2" ;
    final String WORKDIR = System.getProperty( "xtest.workdir") + File.separator + "tmpdir";
    final String SEPARATOR = "#";
    
    
    /*
     * Main method for starting test from IDE.
     * There must be mounted necessary jars in Filesystems ( in Explorer Window )
     * - jemmy.jar
     * - jelly2-nb.jar
     *  both jars have been downloaded from http://jellytools.netbeans.org
     *  @param String[] args - arguments are not processed
     */
    public static void main(String[] args) {
        //System.setProperty( "xtest.workdir","");
        NbTestSuite nbTestSuite = new NbTestSuite();
        nbTestSuite.addTest(new CreatingPropertiesFileFromExplorer2());
        TestRunner.run(nbTestSuite);
    }
    
    
    /**
     * Constructor - Creates a new instance of CreatingPropertiesFileFromExplorer2
     */
    public CreatingPropertiesFileFromExplorer2() {
        super("testCreatingPropertiesFileFromExplorer2");
    }
    
    
    /**
     * This method contain body of test
     * @return void
     */
    public void testCreatingPropertiesFileFromExplorer2() {
        
        // Print test description to the Output window
        System.out.println();
        System.out.println("================================================================================");
        System.out.println("=   Test :  Creating properties file from Explorer 2                           =");
        System.out.println("=   See testspec of properties module on web :                                 =");
        System.out.println("=   http://properties.netbeans.org/qa/testspecs/nb34/PropertiesTestSpec.html   =");
        System.out.println("================================================================================");
        
        //create a node for the sampledir directory
        FilesystemNode filesystemNode = new FilesystemNode(this.WORKDIR);
        
        
        /*
         * 1st step of testcase
         * In explorer create new properties file. Right click on any directory and
         * select in appeared context menu New|Other|Properties File.
         */
        NewWizardOperator newWizard = NewWizardOperator.invoke(filesystemNode, "Other|Properties File");
        
        //type class name
        new NewObjectNameStepOperator().setName(this.FILE_NAME);
        
        
        //push finish
        newWizard.finish();
        
        // Check new file in explorer show explorer
        //ExplorerOperator explorer = ExplorerOperator.invoke();
        //select "Repository" page and get an operator from there
        RepositoryTabOperator explorer = RepositoryTabOperator.invoke();
        String path = filesystemNode.getPath().concat( this.SEPARATOR).concat( this.FILE_NAME);
        
        System.out.println(">> Checking path to file in Explorer ");
        if ( null == explorer.tree().findPath( path, this.SEPARATOR) )
            fail();
        else
            System.out.println(">> Ok");
        
        //find editor window
        System.out.println(">> Checking tab in editor");
        TopComponentOperator tco = new TopComponentOperator(this.FILE_NAME);
        //EditorOperator editorWindow = new EditorOperator( this.FILE_NAME);
        
        /*
         * 2nd step of testcase
         * In explorer create new properties file. Right click on any directory and select
         * in appeared context menu New|Other|Properties File
         */
        NewWizardOperator.invoke(filesystemNode, "Other|Properties File");
        
        
        /*
         * 3th step of testcase
         * Type name to appeared wizard.(as same name as previous case)
         */
        new NewObjectNameStepOperator().setName(this.FILE_NAME);
        // the package should be renamed from previous case
        
        
        /*
         * 4th step of testcase - Result
         * Try confirm wizard. 'Finish' button should be disabled.
         */
        if ( new NewObjectNameStepOperator().btFinish().isEnabled() == true )
            fail("Button finish is enabled and should be disabled.Because file with this name exist.");
        else
            System.out.println(">> Button is disabled. (Ok)");
        
        
        /*
         * 5th step of testcase
         * Cancel wizard. Click to 'Cancel' button.
         */
        new NewObjectNameStepOperator().btCancel().push();
        System.out.println("OK");
        
        
        /*
         * Cleanup
         */
        new PropertiesEditorOperator().deletePropertiesFileFromExplorer(filesystemNode, this.FILE_NAME);
    }
    
    public static NbTestSuite suite() {
        NbTestSuite suite = new NbTestSuite();
        suite.addTest(new CreatingPropertiesFileFromExplorer2());
        return suite;
    }
    
    
    
}
... 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.