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 ChangeNameOfLocaleFileInPropertiesWindow.java
 *
 * Created on 19. brezen 2002, 11:07
 *
 * Description :
 *
 * This is autometed test for netBenas34 version. Test has been
 * writed in Jelly2 ( see testtools.netbeans.org )
 *
 */

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

import java.io.File;
import org.netbeans.jellytools.Bundle;
import org.netbeans.jellytools.JellyTestCase;
import org.netbeans.jellytools.nodes.FilesystemNode;
import org.netbeans.junit.NbTestSuite;
import org.netbeans.properties.jelly2tests.operators.PropertiesEditorOperator;


/**
 *
 * @author  Petr Felenda - QA Engineer ( petr.felenda@sun.com )
 */
public class ChangeNameOfLocaleFileInPropertiesWindow extends JellyTestCase {
    
    /*
     * Definition of member variables and objects
     */
    private final String FILE_NAME = "testChangeNameOfLocaleFileInPropertiesWindow";
    private final String LANGUAGE_CODE = "cs";
    private final String COUNTRY_CODE = "CZ";
    private final String VARIANT = null;
    private final String LOCALE_NAME = "org.netbeans.properties.jelly2tests.suites.Uilities.getCzechLocaleName()";
    
    
    /*
     * 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) {
        
        NbTestSuite nbTestSuite = new NbTestSuite();
        int count = 1;
        if ( args.length != 0 )
            count = Integer.parseInt(args[0]);
        for ( int ii = 1; ii <= count; ii++ )
            nbTestSuite.addTest(new ChangeNameOfLocaleFileInPropertiesWindow());
        junit.textui.TestRunner.run(nbTestSuite);
    }
    
    
    /*
     * This static constructor have been using for starting this test from JUnit framework
     */
    public static NbTestSuite suite() {
        NbTestSuite suite = new NbTestSuite();
        suite.addTest(new ChangeNameOfLocaleFileInPropertiesWindow());
        return suite;
    }
    
    
    /**
     * Constructor - Creates new instance of this class
     */
    public ChangeNameOfLocaleFileInPropertiesWindow() {
        super("testChangeNameOfLocaleFileInPropertiesWindow");
    }
    
    
    /**
     *  This is body of test. Each step of testcase are described in testspec
     * on http://properties.netbeans.org/qa
     */
    public void testChangeNameOfLocaleFileInPropertiesWindow() throws Exception {
        
        // Print test description to the Output window
        System.out.println();
        System.out.println("===================================================================================");
        System.out.println("=   Test :  Change name of locale file in Properties Window                       =");
        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("===================================================================================");
        
        
        /*
         * 1st step of testcase
         * Click to locale file in Explorer. This should displays properties of
         * this tree node in Properties window. This means properties of this tree
         * node, but not properties in properties file! Do not mix it!
         * Use properties files group which containts at least two locales,
         * default and else the other one.
         */
        FilesystemNode filesystemNode = new FilesystemNode(
        System.getProperty( "xtest.workdir") +
        File.separator +
        "tmpdir");
        
        PropertiesEditorOperator propertiesEditorOperator = new PropertiesEditorOperator();
        
        try {
            
            propertiesEditorOperator.createNewPropertiesFile(filesystemNode, this.FILE_NAME);
            propertiesEditorOperator.openAddLocaleDialogFromExplorer(filesystemNode, this.FILE_NAME);
            propertiesEditorOperator.addLocaleDialogFill(this.LANGUAGE_CODE, this.COUNTRY_CODE,VARIANT, filesystemNode, this.FILE_NAME);
            propertiesEditorOperator.addLocaleDialogClickOkButtonNoBlock();
            propertiesEditorOperator.explorerSelectPath(this.FILE_NAME+"|Default",filesystemNode);
            
        /*
         * 2nd step of testcase
         * Try to rename default locale file in properties window.
         * ('Default' item in 'Explorer window' tree.)
         */
            //propertiesEditorOperator.propertiesWindowChangeProperty("Default","Name", "de_De");
            
            
        /*
         * 3th step of testcase
         * Confirm appeared 'Error' dialog.
         */
            //propertiesEditorOperator.errorDialogClickOkButton();
            //new org.netbeans.jemmy.EventTool().waitNoEvent(250);
            
            
        /*
         * 4th step of testcase
         * Select the other locale file in 'Explorer window'. This action displays
         * properties of this tree node in 'Properties window'.Change name of the
         * other locale file in Properties window
         */
            propertiesEditorOperator.explorerSelectPath(this.FILE_NAME+"|"+LOCALE_NAME, filesystemNode);
            propertiesEditorOperator.propertiesWindowChangeProperty(LOCALE_NAME, "Name", "de_De");
            new org.netbeans.jemmy.EventTool().waitNoEvent(250);
            
        /*
         * Result
         * There is changed name of locale file. Notes : Default locale is not
         * possible to rename. New name is compared to default name and updated
         * if this name has not begined with default properties file name.
         */
            propertiesEditorOperator.checkLocalesInExplorer(new String[] {org.netbeans.properties.jelly2tests.suites.Utilities.getDefaultLocaleName(),
            org.netbeans.properties.jelly2tests.suites.Utilities.getGermanLocaleName()},filesystemNode, this.FILE_NAME);
        } finally {
            
        /*
         * Clean up
         */
            propertiesEditorOperator.deletePropertiesFileFromExplorer(filesystemNode, this.FILE_NAME);
        }
    }
}
... 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.