1 19 20 package org.netbeans.test.java.gui.customizers; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import java.io.PrintStream ; 25 import java.io.PrintWriter ; 26 import junit.textui.TestRunner; 27 import org.netbeans.jellytools.EditorOperator; 28 import org.netbeans.jellytools.JellyTestCase; 29 import org.netbeans.jellytools.ProjectsTabOperator; 30 import org.netbeans.jellytools.actions.OpenAction; 31 import org.netbeans.jellytools.modules.java.MethodCustomizerOperator; 32 import org.netbeans.jellytools.nodes.Node; 33 import org.netbeans.jellytools.properties.Property; 34 import org.netbeans.jellytools.properties.PropertySheetOperator; 35 import org.netbeans.jemmy.JemmyProperties; 36 import org.netbeans.jemmy.TestOut; 37 import org.netbeans.jemmy.operators.JEditorPaneOperator; 38 import org.netbeans.junit.NbTestSuite; 39 import org.netbeans.test.java.gui.GuiUtilities; 40 41 42 46 public class MethodCustomizer extends JellyTestCase { 47 48 private static final String TEST_PROJECT_NAME = "default"; 50 51 private static final String TEST_PACKAGE_PATH = 53 "org.netbeans.test.java.gui.customizers"; 54 55 private static final String TEST_PACKAGE_NAME = TEST_PACKAGE_PATH+".test"; 57 58 private static final String TEST_CLASS_NAME = "MethodCustomizer"; 60 61 private static final String TEST_METHOD_NAME = "TestMethod"; 63 64 67 protected static PrintStream err; 68 69 72 protected static PrintStream log; 73 74 private String workDir = "/tmp"; 76 77 private static String projectDir; 79 80 84 public MethodCustomizer(String name) { 85 super(name); 86 } 87 88 92 public static NbTestSuite suite() { 93 NbTestSuite suite = new NbTestSuite(); 94 suite.addTest(new MethodCustomizer("testCustomizeMethod")); 95 return suite; 96 } 97 98 102 public static void main(java.lang.String [] args) { 103 TestRunner.run(suite()); 104 } 105 106 109 public void setUp() { 110 System.out.println("######## "+getName()+" #######"); 111 err = getLog(); 112 log = getRef(); 113 JemmyProperties.getProperties().setOutput(new TestOut(null, 114 new PrintWriter (err, true), new PrintWriter (err, false), null)); 115 try { 116 File wd = getWorkDir(); 117 workDir = wd.toString(); 118 } catch (IOException e) { } 119 } 120 121 124 public void testCustomizeMethod() { 125 Node pn = new ProjectsTabOperator().getProjectRootNode( 126 TEST_PROJECT_NAME); 127 pn.select(); 128 129 Node n = new Node(pn, org.netbeans.jellytools.Bundle.getString( 130 "org.netbeans.modules.java.j2seproject.Bundle", 131 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME+"|" 132 +TEST_CLASS_NAME); 133 134 n.select(); 135 new OpenAction().perform(); 136 137 EditorOperator editor = new EditorOperator(TEST_CLASS_NAME); 138 139 editor.insert("String "+TEST_METHOD_NAME+"(){ };\n", 14, 5); 141 142 GuiUtilities.waitForChildNode(TEST_PROJECT_NAME, "Source Packages|" 144 +TEST_PACKAGE_NAME+"|"+TEST_CLASS_NAME+"|"+TEST_CLASS_NAME+"|" 145 +org.netbeans.jellytools.Bundle.getString( 146 "org.netbeans.modules.java.ui.nodes.elements.Bundle", 147 "Methods"), TEST_METHOD_NAME); 148 149 Node n2 = new Node(pn, "Source Packages|"+TEST_PACKAGE_NAME+"|" 150 +TEST_CLASS_NAME+"|"+TEST_CLASS_NAME+"|" 151 +org.netbeans.jellytools.Bundle.getString( 152 "org.netbeans.modules.java.ui.nodes.elements.Bundle", "Methods") 153 +"|"+TEST_METHOD_NAME); 155 156 n2.select(); 157 n2.performPopupActionNoBlock(org.netbeans.jellytools.Bundle.getString( 158 "org.netbeans.core.Bundle", "CTL_PropertiesWindow")); 159 160 MethodCustomizerOperator cco = new MethodCustomizerOperator( 161 TEST_METHOD_NAME+" - "+org.netbeans.jellytools.Bundle.getString( 162 "org.netbeans.core.Bundle", "CTL_PropertiesWindow")); 163 164 PropertySheetOperator pso = new PropertySheetOperator(TEST_METHOD_NAME 165 +" - "+org.netbeans.jellytools.Bundle.getString( 166 "org.netbeans.core.Bundle", "CTL_PropertiesWindow")); 167 168 new Property(pso, "Modifiers").setValue("private"); 170 new Property(pso, "Return Type").setValue("void"); 171 new Property(pso, "Exceptions").setValue("Exception"); 172 173 cco.btClose().clickMouse(); 174 175 ref(editor.getText()); 177 compareReferenceFiles(); 178 179 EditorOperator.closeDiscardAll(); 180 } 181 182 } 183 | Popular Tags |