|
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. */ package org.netbeans.test.java.gui.customizers; import junit.textui.TestRunner; import org.netbeans.jellytools.Bundle; import org.netbeans.jellytools.ExplorerOperator; import org.netbeans.jellytools.JellyTestCase; import org.netbeans.jellytools.RepositoryTabOperator; import org.netbeans.jellytools.modules.java.MethodCustomizerOperator; import org.netbeans.jellytools.modules.java.MethodParameterOperator; import org.netbeans.jellytools.modules.java.NewIdentifierOperator; import org.netbeans.jellytools.nodes.JavaNode; import org.netbeans.jellytools.nodes.Node; import org.netbeans.junit.NbTestSuite; import org.netbeans.test.java.Utilities; public class MethodCustomizer extends JellyTestCase { private static final String NAME_TEST_FILE = "TestFile"; private static final String NAME_TEST_METHOD = "TestMethod"; private static final String NAME_DATA_DIR = "org/netbeans/test/java/gui/customizers/data/"; /** Need to be defined because of JUnit */ public MethodCustomizer(String name) { super(name); } public static NbTestSuite suite() { NbTestSuite suite = new NbTestSuite(); suite.addTest(new MethodCustomizer("testAddMethod")); suite.addTest(new MethodCustomizer("testCustomizeMethod")); return suite; } /** Use for execution inside IDE */ public static void main(java.lang.String[] args) { // run whole suite TestRunner.run(suite()); // run only selected test case //junit.textui.TestRunner.run(new BeansTemplates("testJavaBean")); } /** setUp method */ public void setUp() { System.out.println("######## "+getName()+" #######"); RepositoryTabOperator.invoke(); } /** tearDown method */ public void tearDown() { } private void customizeMethod() { //add method ExplorerOperator explorerOperator = new ExplorerOperator(); explorerOperator.selectPageFilesystems(); Node repositoryRootNode = explorerOperator.repositoryTab().getRootNode(); JavaNode testFile = new JavaNode(repositoryRootNode, Utilities.getSampleDir().getDisplayName()+"|"+NAME_TEST_METHOD + "|class " + NAME_TEST_METHOD + "|Methods|method"); testFile.select(); testFile.performPopupActionNoBlock(Bundle.getString("org.openide.actions.Bundle", "Customize")); //customize it final MethodCustomizerOperator methodCustomizer = new MethodCustomizerOperator(Bundle.getString("org.netbeans.core.Bundle", "CTL_Customizer_dialog_title")); methodCustomizer.typeName("method2"); methodCustomizer.selectReturnType("int"); methodCustomizer.selectAccess("private"); methodCustomizer.checkFinal(true); methodCustomizer.checkAbstract(true); Thread thread = new Thread( new java.lang.Runnable() { public void run() { methodCustomizer.add(); } }); thread.start(); MethodParameterOperator param = new MethodParameterOperator(); param.typeName("param2"); param.selectType("int"); param.oK(); thread = new Thread( new java.lang.Runnable() { public void run() { methodCustomizer.add2(); } }); thread.start(); NewIdentifierOperator identifier = new NewIdentifierOperator(); identifier.setNewName("java.beans.PropertyVetoException"); identifier.oK(); methodCustomizer.closeByButton(); } public void testCustomizeMethod() { //create test file Utilities.copyToSampleDir(NAME_DATA_DIR + NAME_TEST_METHOD + ".java"); customizeMethod(); ref(Utilities.getAsString(NAME_TEST_METHOD + ".java")); Utilities.saveAll(); Utilities.delete(NAME_TEST_METHOD + ".java"); compareReferenceFiles(); } public void testAddMethod() { //create test file Utilities.copyToSampleDir(NAME_DATA_DIR + NAME_TEST_FILE + ".java"); addMethod(); ref(Utilities.getAsString(NAME_TEST_FILE + ".java")); Utilities.saveAll(); Utilities.delete(NAME_TEST_FILE + ".java"); compareReferenceFiles(); } private void addMethod() { //add class ExplorerOperator explorerOperator = new ExplorerOperator(); explorerOperator.selectPageFilesystems(); Node repositoryRootNode = explorerOperator.repositoryTab().getRootNode(); JavaNode testFile = new JavaNode(repositoryRootNode, Utilities.getSampleDir().getDisplayName()+"|" + NAME_TEST_FILE + "|" + "class " + NAME_TEST_FILE); testFile.select(); testFile.performPopupActionNoBlock(Bundle.getString("org.openide.src.nodes.Bundle", "LAB_Add") + '|' + Bundle.getString("org.openide.src.nodes.Bundle", "MENU_CREATE_METHOD")); //customize it final MethodCustomizerOperator methodCustomizer = new MethodCustomizerOperator(Bundle.getString("org.openide.src.nodes.Bundle", "TIT_NewMethod")); methodCustomizer.typeName("method"); methodCustomizer.selectReturnType("String"); methodCustomizer.selectAccess("public"); methodCustomizer.checkAbstract(true); methodCustomizer.checkFinal(true); Thread thread = new Thread( new java.lang.Runnable() { public void run() { methodCustomizer.add(); } }); thread.start(); MethodParameterOperator param = new MethodParameterOperator(); param.typeName("param1"); param.selectType("int"); param.checkFinal(true); param.oK(); thread = new Thread( new java.lang.Runnable() { public void run() { methodCustomizer.add2(); } }); thread.start(); NewIdentifierOperator identifier = new NewIdentifierOperator(); identifier.setNewName("java.io.IOException"); identifier.oK(); methodCustomizer.oK(); } } |
... 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.