1 19 20 package org.netbeans.test.java.gui.overridemethods; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import java.io.PrintStream ; 25 import java.io.PrintWriter ; 26 import org.netbeans.jellytools.Bundle; 27 import org.netbeans.jellytools.actions.ActionNoBlock; 28 import org.netbeans.junit.NbTestSuite; 29 import org.netbeans.jellytools.JellyTestCase; 30 import org.netbeans.jellytools.modules.java.OverrideMethodsOperator; 31 import org.netbeans.jellytools.ProjectsTabOperator; 32 import org.netbeans.jellytools.nodes.Node; 33 import org.netbeans.jemmy.JemmyProperties; 34 import org.netbeans.jemmy.TestOut; 35 import javax.swing.tree.TreeModel ; 36 import org.netbeans.jellytools.EditorOperator; 37 import org.netbeans.jellytools.actions.OpenAction; 38 import org.netbeans.test.java.Utilities; 39 import org.netbeans.test.java.gui.GuiUtilities; 40 41 45 public class OverrideMethodsDialog extends JellyTestCase { 46 47 private static final String TEST_PROJECT_NAME = "default"; 49 50 private static final String TEST_PACKAGE_PATH = 52 "org.netbeans.test.java.gui.overridemethods"; 53 54 private static final String TEST_PACKAGE_NAME = TEST_PACKAGE_PATH+".test"; 56 57 private static final String TEST_CLASS_NAME = "TestClass"; 59 60 63 protected static PrintStream err; 64 67 protected static PrintStream log; 68 69 private String workDir = "/tmp"; 71 72 private static String projectDir; 74 75 78 public OverrideMethodsDialog(String name) { 79 super(name); 80 } 81 82 86 public static NbTestSuite suite() { 87 NbTestSuite suite = new NbTestSuite(); 88 suite.addTest(new OverrideMethodsDialog("testOverrideMethods")); 89 return suite; 90 } 91 92 96 public static void main(String [] args) { 97 junit.textui.TestRunner.run(suite()); 98 } 99 100 101 public void setUp() { 102 System.out.println("######## "+getName()+" #######"); 103 err = getLog(); 104 log = getRef(); 105 JemmyProperties.getProperties().setOutput(new TestOut(null, 106 new PrintWriter (err, true), new PrintWriter (err, false), null)); 107 try { 108 File wd = getWorkDir(); 109 workDir = wd.toString(); 110 } catch (IOException e) { } 111 } 112 113 116 public void testOverrideMethods() { 117 Node pn = new ProjectsTabOperator().getProjectRootNode( 118 TEST_PROJECT_NAME); 119 pn.select(); 120 121 Node n = new Node(pn, Bundle.getString( 122 "org.netbeans.modules.java.j2seproject.Bundle", 123 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME+"|" 124 +TEST_CLASS_NAME); 125 126 n.select(); 127 new OpenAction().perform(); 128 129 Node parent = new Node(pn, Bundle.getString( 130 "org.netbeans.modules.java.j2seproject.Bundle", 131 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME); 132 133 GuiUtilities.waitForChildNode(TEST_PROJECT_NAME, 135 Bundle.getString( 136 "org.netbeans.modules.java.j2seproject.Bundle", 137 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME+"|" 138 +TEST_CLASS_NAME, TEST_CLASS_NAME); 139 Node n2 = new Node(pn, Bundle.getString( 140 "org.netbeans.modules.java.j2seproject.Bundle", 141 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME+"|" 142 +TEST_CLASS_NAME+"|"+TEST_CLASS_NAME); 143 n2.select(); 144 new ActionNoBlock("Source|Override Methods...", null).perform(n2); 145 146 Utilities.takeANap(1000); 147 148 final OverrideMethodsOperator omo = new OverrideMethodsOperator(); 150 TreeModel tm = omo.treeAvailableSuperclassAndInterfaceMethods(). 151 getModel(); 152 Object root = tm.getRoot(); 153 154 while (tm.getChildCount(root)<5) { 156 Utilities.takeANap(1000); 157 } 158 159 assertEquals(tm.getChild(root, 0).toString(), 161 "clone() : java.lang.Object"); 162 assertEquals(tm.getChild(root, 1).toString(), 163 "equals(Object) : boolean"); 164 assertEquals(tm.getChild(root, 2).toString(), 165 "finalize() : void"); 166 assertEquals(tm.getChild(root, 3).toString(), 167 "hashCode() : int"); 168 assertEquals(tm.getChild(root, 4).toString(), 169 "toString() : java.lang.String"); 170 171 omo.checkShowAbstractMethodsOnly(true); 172 assertEquals(tm.getChildCount(root), 0); 173 174 omo.checkShowAbstractMethodsOnly(false); 175 omo.checkShowSuperclassesAndInterfaces(true); 176 177 Utilities.takeANap(1000); 178 179 omo.treeAvailableSuperclassAndInterfaceMethods().selectRow(0); 181 omo.treeAvailableSuperclassAndInterfaceMethods().selectRow(1); 182 omo.treeAvailableSuperclassAndInterfaceMethods().selectRow(2); 183 omo.treeAvailableSuperclassAndInterfaceMethods().selectRow(3); 184 omo.treeAvailableSuperclassAndInterfaceMethods().selectRow(4); 185 186 int[] indexes = {1, 2, 3, 4, 5}; 187 188 omo.treeAvailableSuperclassAndInterfaceMethods(). 190 setSelectionRows(indexes); 191 192 omo.checkCopyJavadoc(true); 193 omo.checkGenerateSuperCalls(true); 194 195 omo.checkCopyJavadoc(false); 196 197 omo.ok(); 198 199 ref(new EditorOperator(TEST_CLASS_NAME).getText()); 200 201 compareReferenceFiles(); 202 } 203 204 } 205 | Popular Tags |