|
What this is
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. */ /* * CreatingPropertiesFileFromMainWindow1.java * * Created on 16. September 2002 */ package org.netbeans.properties.jelly2tests.suites.creating_properties_file; import java.awt.Component; import java.awt.Container; import java.io.File; import junit.textui.TestRunner; import org.netbeans.jellytools.*; import org.netbeans.jellytools.nodes.FilesystemNode; import org.netbeans.jellytools.nodes.PropertiesNode; import org.netbeans.jemmy.EventTool; import org.netbeans.jemmy.QueueTool; 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 CreatingPropertiesFileFromMainWindow1 extends JellyTestCase { /* * Definition of member variables */ final String SEPARATOR = "#"; final String WORKDIR = System.getProperty( "xtest.workdir") + File.separator + "tmpdir"; final String PACKAGE_PATH = "examples"; final String DEFAULT_PROPERTIES_FILE_NAME = "properties"; final String EDITOR_TITLE_NAME = "Source Editor"; /* * 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 nbSuite = new NbTestSuite(); for ( int ii = 1; ii <= 2; ii++ ) nbSuite.addTest(new CreatingPropertiesFileFromMainWindow1()); TestRunner.run(nbSuite); } /** * Constructor - Creates a new instance of this class */ public CreatingPropertiesFileFromMainWindow1() { super("testCreatingPropertiesFileFromMainWindow1"); } /** * This method contains body of test * @return void */ public void testCreatingPropertiesFileFromMainWindow1() { /* * Print description of test to output window */ System.out.println(); System.out.println("================================================================================"); System.out.println("= Test : Creating properties file from main window 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("================================================================================"); System.out.println("workdir = "+ this.WORKDIR); FilesystemNode filesystemNode = new FilesystemNode(this.WORKDIR); filesystemNode.select(); /* * 1st step of testcase ( here is used toolbar's icon for opening wizard ) * There will be opened New Wizard from Main Window Toolbar ( icon 'New' from toolbar 'System' ) */ QueueTool.installQueue(); // work around for issue 32310 (30307) MainWindowOperator mainWindowOp = MainWindowOperator.getDefault(); mainWindowOp.getToolbarButton(mainWindowOp.getToolbar("System"),"New").push(); /* * 2nd step of testcase * Select from wizard Other|Properties File and click next button. */ WizardOperator wo = new WizardOperator("New"); JTreeOperator tree = new JTreeOperator(wo); tree.clickOnPath(tree.findPath("Other|Properties File","|")); wo.next(); /* * 3rd step of testcase * (here is nothing happen) * There is set default name and package. Do not change these values * ( package must be added because autotemed tests add jars and mount file- * systems witch are don't have deterministic order */ tree = new JTreeOperator(wo); tree.clickOnPath(tree.findPath( this.WORKDIR, this.SEPARATOR ) ); /* * 4th step of testcase * Confirm wizard */ wo.finish(); /* * Result * Should be added new properties file (with default name) to adequate place in * explorer and opened in editor. */ //NbFrameOperator fo = new NbFrameOperator(this.EDITOR_TITLE_NAME); PropertiesEditorOperator po = new PropertiesEditorOperator(); if ( ! po.existsFileInEditor(this.DEFAULT_PROPERTIES_FILE_NAME) ) fail("File "+ this.DEFAULT_PROPERTIES_FILE_NAME +" not found in Editor window"); /* if ( findMyComponent( fo.getComponents(),"["+this.DEFAULT_PROPERTIES_FILE_NAME) == null ) fail("File not found in Editor window"); else System.out.println(">> File has been in Editor Window (Ok)"); */ /* * Cleanup */ new PropertiesEditorOperator().deletePropertiesFileFromExplorer(filesystemNode, "properties"); } /* * Find component in container * This method is used for search component in containers * @param Container con - in this container is searched components * @param String findComponent - this is name of searched component */ private Component findMyComponent(Container con, String findComponent) { Component comp = null; for ( int ii = 0; ii < con.getComponentCount(); ii++ ) { String str = con.getComponent(ii).toString().toLowerCase(); int toIndex = str.indexOf('['); str = str.substring(0,toIndex); if ( str.indexOf("pane") > 0 || str.indexOf("view") > 0 || str.indexOf("renderer") > 0 || str.indexOf("container") > 0 || str.indexOf("component") > 0 ) { Container tmpC = (Container) con.getComponent(ii); if ( tmpC.getComponentCount() != 0 ) comp = findMyComponent( (Container) con.getComponent(ii), findComponent); } // if component is if ( comp != null ) return comp; if ( con.getComponent(ii).toString().toLowerCase().indexOf(findComponent.toLowerCase()) > 0 ) return con.getComponent(ii); } return null; } /* * Find comtainer in component * This method search container in array of components * @param Componentp[] comps - array of components * @param String findComponent - name of searched component */ private Component findMyComponent(Component[] comps, String findComponent ){ Component comp = null; for ( int ii = 0; ii < comps.length; ii++ ) { String str = comps[ii].toString().toLowerCase(); int toIndex = str.indexOf('['); str = str.substring(0,toIndex); if ( str.indexOf("pane") > 0 ) comp = findMyComponent( (Container) comps[ii] , findComponent); if ( comp != null ) break; } return comp; } public static NbTestSuite suite() { NbTestSuite suite = new NbTestSuite(); suite.addTest(new CreatingPropertiesFileFromMainWindow1()); return suite; } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
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.