1 19 20 package org.netbeans.test.java.gui.copypaste; 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.NbDialogOperator; 30 import org.netbeans.jellytools.ProjectsTabOperator; 31 import org.netbeans.jellytools.actions.CopyAction; 32 import org.netbeans.jellytools.actions.CutAction; 33 import org.netbeans.jellytools.actions.OpenAction; 34 import org.netbeans.jellytools.actions.PasteAction; 35 import org.netbeans.jellytools.modules.java.SimpleCopyAction; 36 import org.netbeans.jellytools.modules.java.SimpleMoveAction; 37 import org.netbeans.jellytools.nodes.Node; 38 import org.netbeans.jemmy.JemmyProperties; 39 import org.netbeans.jemmy.TestOut; 40 import org.netbeans.jemmy.operators.JEditorPaneOperator; 41 import org.netbeans.junit.NbTestSuite; 42 import org.netbeans.test.java.Utilities; 43 import org.netbeans.test.java.gui.GuiUtilities; 44 45 46 47 51 public class ClassNodeTest extends JellyTestCase { 52 53 private static final String TEST_PROJECT_NAME = "default"; 55 56 private static final String TEST_PACKAGE_PATH = 58 "org.netbeans.test.java.gui.copypaste"; 59 60 private static final String TEST_PACKAGE_NAME = TEST_PACKAGE_PATH+".test"; 62 63 private static final String TEST_PACKAGE_NAME_2 = 65 TEST_PACKAGE_PATH+".test2"; 66 67 private static final String TEST_PACKAGE_NAME_3 = 69 TEST_PACKAGE_PATH+".test3"; 70 71 private static final String TEST_CLASS_NAME = "TestClass"; 73 74 private static final String TEST_IFACE_NAME = "TestInterface"; 76 77 80 protected static PrintStream err; 81 82 85 protected static PrintStream log; 86 87 private String workDir = "/tmp"; 89 90 private static String projectDir; 92 93 94 98 public ClassNodeTest(String name) { 99 super(name); 100 } 101 102 106 public static NbTestSuite suite() { 107 NbTestSuite suite = new NbTestSuite(); 108 suite.addTest(new ClassNodeTest("testCopyPaste")); 110 suite.addTest(new ClassNodeTest("testCutPaste")); 111 suite.addTest(new ClassNodeTest("testCopyPasteInterface")); 112 suite.addTest(new ClassNodeTest("testCutPasteInterface")); 113 return suite; 114 } 115 116 120 public static void main(java.lang.String [] args) { 121 TestRunner.run(suite()); 122 } 123 124 127 public void setUp() { 128 System.out.println("######## "+getName()+" #######"); 129 err = getLog(); 130 log = getRef(); 131 JemmyProperties.getProperties().setOutput(new TestOut(null, 132 new PrintWriter (err, true), new PrintWriter (err, false), null)); 133 try { 134 File wd = getWorkDir(); 135 workDir = wd.toString(); 136 } catch (IOException e) { } 137 } 138 139 142 public void testCopyPaste() { 143 Node pn = new ProjectsTabOperator().getProjectRootNode( 144 TEST_PROJECT_NAME); 145 pn.select(); 146 147 GuiUtilities.waitForChildNode(TEST_PROJECT_NAME, 148 org.netbeans.jellytools.Bundle.getString( 149 "org.netbeans.modules.java.j2seproject.Bundle", 150 "NAME_src.dir"), TEST_PACKAGE_NAME_2); 151 152 GuiUtilities.waitForChildNode(TEST_PROJECT_NAME, 153 org.netbeans.jellytools.Bundle.getString( 154 "org.netbeans.modules.java.j2seproject.Bundle", 155 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME, 156 TEST_CLASS_NAME); 157 158 Node n = new Node(pn, org.netbeans.jellytools.Bundle.getString( 160 "org.netbeans.modules.java.j2seproject.Bundle", 161 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME+"|" 162 +TEST_CLASS_NAME); 163 166 new CopyAction().perform(n); 167 168 Node n2 = new Node(pn, org.netbeans.jellytools.Bundle.getString( 170 "org.netbeans.modules.java.j2seproject.Bundle", 171 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME_2); 172 173 n2.select(); 174 new SimpleCopyAction().perform(); 175 176 Utilities.takeANap(1000); 177 178 GuiUtilities.waitForChildNode(TEST_PROJECT_NAME, 180 org.netbeans.jellytools.Bundle.getString( 181 "org.netbeans.modules.java.j2seproject.Bundle", 182 "NAME_src.dir")+"|" 183 +TEST_PACKAGE_NAME_2, TEST_CLASS_NAME); 184 185 Node node = new Node(pn, org.netbeans.jellytools.Bundle.getString( 186 "org.netbeans.modules.java.j2seproject.Bundle", 187 "NAME_src.dir")+"|" 188 +TEST_PACKAGE_NAME_2+"|"+TEST_CLASS_NAME); 189 new OpenAction().perform(); 190 191 Node n3 = new Node(pn, org.netbeans.jellytools.Bundle.getString( 193 "org.netbeans.modules.java.j2seproject.Bundle", 194 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME_2+"|" 195 +TEST_CLASS_NAME); 196 n3.select(); 197 new OpenAction().perform(); 198 199 JEditorPaneOperator txtOper = new EditorOperator(TEST_CLASS_NAME).txtEditorPane(); 201 202 ref(txtOper.getText()); 204 compareReferenceFiles(); 205 } 206 207 208 211 public void testCutPaste() { 212 Node pn = new ProjectsTabOperator().getProjectRootNode(TEST_PROJECT_NAME); 213 pn.select(); 214 215 GuiUtilities.waitForChildNode(TEST_PROJECT_NAME, 216 org.netbeans.jellytools.Bundle.getString( 217 "org.netbeans.modules.java.j2seproject.Bundle", 218 "NAME_src.dir"), TEST_PACKAGE_NAME_2); 219 220 Node n = new Node(pn, org.netbeans.jellytools.Bundle.getString( 221 "org.netbeans.modules.java.j2seproject.Bundle", 222 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME+"|" 223 +TEST_CLASS_NAME); 224 225 n.select(); 227 new CutAction().perform(); 228 229 Node n2 = new Node(pn, org.netbeans.jellytools.Bundle.getString( 231 "org.netbeans.modules.java.j2seproject.Bundle", 232 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME_3); 233 n2.select(); 234 new SimpleMoveAction().perform(); 235 236 Utilities.takeANap(1000); 237 238 240 248 GuiUtilities.waitForChildNode(TEST_PROJECT_NAME, 250 org.netbeans.jellytools.Bundle.getString( 251 "org.netbeans.modules.java.j2seproject.Bundle", 252 "NAME_src.dir")+"|" 253 +TEST_PACKAGE_NAME_3, TEST_CLASS_NAME); 254 255 Node n3 = new Node(pn, org.netbeans.jellytools.Bundle.getString( 256 "org.netbeans.modules.java.j2seproject.Bundle", 257 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME_3+"|" 258 +TEST_CLASS_NAME); 259 260 new EditorOperator(TEST_CLASS_NAME).close(true); 262 263 Node n4 = new Node(pn, org.netbeans.jellytools.Bundle.getString( 265 "org.netbeans.modules.java.j2seproject.Bundle", 266 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME_3+"|" 267 +TEST_CLASS_NAME); 268 n4.select(); 269 new OpenAction().perform(); 270 271 JEditorPaneOperator txtOper = new EditorOperator(TEST_CLASS_NAME).txtEditorPane(); 273 274 ref(txtOper.getText()); 276 compareReferenceFiles(); 277 278 Node n5 = new Node(pn, org.netbeans.jellytools.Bundle.getString( 280 "org.netbeans.modules.java.j2seproject.Bundle", 281 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME); 282 String [] children = n5.getChildren(); 283 assertEquals(children.length, 1); 284 } 285 286 289 public void testCopyPasteInterface() { 290 Node pn = new ProjectsTabOperator().getProjectRootNode( 291 TEST_PROJECT_NAME); 292 pn.select(); 293 294 Node n = new Node(pn, org.netbeans.jellytools.Bundle.getString( 296 "org.netbeans.modules.java.j2seproject.Bundle", 297 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME+"|" 298 +TEST_IFACE_NAME); 299 301 new CopyAction().perform(n); 303 304 Node n2 = new Node(pn, org.netbeans.jellytools.Bundle.getString( 306 "org.netbeans.modules.java.j2seproject.Bundle", 307 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME_2); 308 309 n2.select(); 310 new SimpleCopyAction().perform(); 311 312 Utilities.takeANap(1000); 313 314 GuiUtilities.waitForChildNode(TEST_PROJECT_NAME, 316 org.netbeans.jellytools.Bundle.getString( 317 "org.netbeans.modules.java.j2seproject.Bundle", 318 "NAME_src.dir")+"|" 319 +TEST_PACKAGE_NAME_2, TEST_IFACE_NAME); 320 321 Node n3 = new Node(pn, org.netbeans.jellytools.Bundle.getString( 323 "org.netbeans.modules.java.j2seproject.Bundle", 324 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME_2+"|" 325 +TEST_IFACE_NAME); 326 n3.select(); 327 new OpenAction().perform(); 328 329 JEditorPaneOperator txtOper = new EditorOperator(TEST_IFACE_NAME).txtEditorPane(); 331 332 ref(txtOper.getText()); 334 compareReferenceFiles(); 335 } 336 337 340 public void testCutPasteInterface() { 341 Node pn = new ProjectsTabOperator().getProjectRootNode(TEST_PROJECT_NAME); 342 pn.select(); 343 344 Node n = new Node(pn, org.netbeans.jellytools.Bundle.getString( 346 "org.netbeans.modules.java.j2seproject.Bundle", 347 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME+"|" 348 +TEST_IFACE_NAME); 349 n.select(); 350 351 new CutAction().perform(); 352 353 Node n2 = new Node(pn, org.netbeans.jellytools.Bundle.getString( 355 "org.netbeans.modules.java.j2seproject.Bundle", 356 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME_3); 357 358 n2.select(); 359 new SimpleMoveAction().perform(); 360 361 Utilities.takeANap(1000); 362 363 371 GuiUtilities.waitForChildNode(TEST_PROJECT_NAME, 373 org.netbeans.jellytools.Bundle.getString( 374 "org.netbeans.modules.java.j2seproject.Bundle", 375 "NAME_src.dir")+"|" 376 +TEST_PACKAGE_NAME_3, TEST_IFACE_NAME); 377 378 Node n3 = new Node(pn, org.netbeans.jellytools.Bundle.getString( 380 "org.netbeans.modules.java.j2seproject.Bundle", 381 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME_3+"|" 382 +TEST_IFACE_NAME); 383 n3.select(); 384 new OpenAction().perform(); 385 386 ref(new EditorOperator(TEST_IFACE_NAME).getText()); 388 compareReferenceFiles(); 389 390 Node n5 = new Node(pn, org.netbeans.jellytools.Bundle.getString( 392 "org.netbeans.modules.java.j2seproject.Bundle", 393 "NAME_src.dir")+"|"+TEST_PACKAGE_NAME); 394 String [] children = n5.getChildren(); 395 assertEquals(children.length, 0); 396 } 397 398 } 399 | Popular Tags |