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

 /*
  * File CreatingPropertiesFileFromExplorer1.java
  *
  * Created on 16. September 2002
  *
  * 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 junit.textui.TestRunner;
import org.netbeans.jellytools.*;
import org.netbeans.jellytools.EditorOperator;
import org.netbeans.jellytools.nodes.FilesystemNode;
import org.netbeans.jellytools.nodes.PropertiesNode;
import org.netbeans.jellytools.nodes.PropertiesNode;
import org.netbeans.jemmy.operators.JTreeOperator;
import org.netbeans.junit.NbTestSuite;
import org.netbeans.properties.jelly2tests.operators.PropertiesEditorOperator;


/**
 *
 * @author  Petr Felenda - QA Engineer ( petr.felenda@sun.com )
 */
public class CreatingPropertiesFileFromExplorer1 extends JellyTestCase {
    
    /*
     * Definition of member variables and objects
     */
    final String FILE_NAME = "testFile_CreatingPropertiesFileFromExplorer1" ;
    final String SEPARATOR = "#";
    final String WORKDIR = System.getProperty( "xtest.workdir") + File.separator + "tmpdir";
    final String PACKAGE_PATH = "examples";
    
    
    /*
     * Main method for starting test from IDE.
     * There should 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 process
     */
    public static void main(String[] args) {
        
        NbTestSuite nbTestSuite = new NbTestSuite();
        nbTestSuite.addTest(new CreatingPropertiesFileFromExplorer1());
        TestRunner.run(nbTestSuite);
    }
    
    
    /**
     *  Constructor - creates a new instance of CreatingPropertiesFileFromExplorer1
     */
    public CreatingPropertiesFileFromExplorer1() {
        super("testCreatingPropertiesFileFromExplorer1");
    }
    
    /**
     * This method contain body of test
     * @return void
     */
    public void testCreatingPropertiesFileFromExplorer1() {
        
        // Print test description to the Output window
        System.out.println();
        System.out.println("================================================================================");
        System.out.println("=   Test :  Creating properties file from explorer 1                           =");
        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 WORKDIR directory
        System.out.println("WORKDIR ="+WORKDIR);
        FilesystemNode filesystemNode = new FilesystemNode( 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");
        
        /*
         * 2nd step of testcase
         * Type name to appeared wizard.
         */
        new org.netbeans.jellytools.NewObjectNameStepOperator().setName(this.FILE_NAME);
        
        /*
         * 3rd step of testcase
         * Confirm wizard. Press Finish button.
         */
        newWizard.finish();
        
        /*
         * Result
         * Should be created new file in explorer and opened in editor.
         */
        RepositoryTabOperator repository = new RepositoryTabOperator();
        String path = filesystemNode.getPath().concat( this.SEPARATOR).concat( this.FILE_NAME);
        System.out.println(">> Checking path to file in Explorer ");
        if ( null == repository.tree().findPath( path, this.SEPARATOR) )
            fail(">> File not found in Explorer Window tree");
        else
            System.out.println(">> Ok");
        
        System.out.println(">> Checking tab in editor");
        TopComponentOperator tco = new TopComponentOperator(this.FILE_NAME);
        System.out.println(">> Ok");
        
        /*
         * Cleanup
         */
        PropertiesNode propNode = new PropertiesNode(filesystemNode, this.FILE_NAME);
        propNode.delete();
        new NbDialogOperator(Bundle.getString("org.openide.explorer.Bundle", "MSG_ConfirmDeleteObjectTitle")).yes();
    }
    
    public static NbTestSuite suite() {
        NbTestSuite suite = new NbTestSuite();
        suite.addTest(new CreatingPropertiesFileFromExplorer1());
        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.