1 21 22 package gui.debuggercore; 23 24 import java.io.File ; 25 import junit.textui.TestRunner; 26 import org.netbeans.jellytools.EditorOperator; 27 import org.netbeans.jellytools.JellyTestCase; 28 import org.netbeans.jellytools.NbDialogOperator; 29 import org.netbeans.jellytools.TopComponentOperator; 30 import org.netbeans.jellytools.actions.DebugProjectAction; 31 import org.netbeans.jellytools.actions.OpenAction; 32 import org.netbeans.jellytools.modules.debugger.actions.ContinueAction; 33 import org.netbeans.jellytools.modules.debugger.actions.NewBreakpointAction; 34 import org.netbeans.jellytools.nodes.Node; 35 import org.netbeans.jellytools.nodes.SourcePackagesNode; 36 import org.netbeans.jemmy.EventTool; 37 import org.netbeans.jemmy.JemmyProperties; 38 import org.netbeans.jemmy.operators.JComboBoxOperator; 39 import org.netbeans.jemmy.operators.JEditorPaneOperator; 40 import org.netbeans.jemmy.operators.JTableOperator; 41 import org.netbeans.jemmy.operators.JTextFieldOperator; 42 import org.netbeans.jemmy.operators.JPopupMenuOperator; 43 import org.netbeans.jemmy.util.PNGEncoder; 44 import org.netbeans.junit.NbTestSuite; 45 46 47 48 52 public class Breakpoints extends JellyTestCase { 53 54 56 60 public Breakpoints(String name) { 61 super(name); 62 } 63 64 68 public static void main(String [] args) { 69 TestRunner.run(suite()); 70 } 71 72 76 public static NbTestSuite suite() { 77 NbTestSuite suite = new NbTestSuite(); 78 suite.addTest(new Breakpoints("testLineBreakpointCreation")); 79 suite.addTest(new Breakpoints("testLineBreakpointFunctionality")); 80 suite.addTest(new Breakpoints("testLineBreakpointFunctionalityAfterContinue")); 81 suite.addTest(new Breakpoints("testLineBreakpointFunctionalityInStaticMethod")); 82 suite.addTest(new Breakpoints("testLineBreakpointFunctionalityInInitializer")); 83 suite.addTest(new Breakpoints("testLineBreakpointFunctionalityInConstructor")); 84 suite.addTest(new Breakpoints("testLineBreakpointFunctionalityInInnerClass")); 85 suite.addTest(new Breakpoints("testLineBreakpointFunctionalityInSecondaryClass")); 86 suite.addTest(new Breakpoints("testConditionalLineBreakpointFunctionality")); 87 suite.addTest(new Breakpoints("testMethodBreakpointPrefilledConstructor")); 88 suite.addTest(new Breakpoints("testMethodBreakpointPrefilledMethod")); 90 suite.addTest(new Breakpoints("testMethodBreakpointCreation")); 91 suite.addTest(new Breakpoints("testMethodBreakpointFunctionalityInPrimaryClass")); 92 suite.addTest(new Breakpoints("testMethodBreakpointFunctionalityInSecondClass")); 93 suite.addTest(new Breakpoints("testMethodBreakpointFunctionalityOnAllMethods")); 94 suite.addTest(new Breakpoints("testClassBreakpointPrefilledInClass")); 95 suite.addTest(new Breakpoints("testClassBreakpointPrefilledInInitializer")); 96 suite.addTest(new Breakpoints("testClassBreakpointPrefilledInConstructor")); 97 suite.addTest(new Breakpoints("testClassBreakpointPrefilledInMethod")); 98 suite.addTest(new Breakpoints("testClassBreakpointPrefilledInSecondClass")); 99 suite.addTest(new Breakpoints("testClassBreakpointCreation")); 100 suite.addTest(new Breakpoints("testClassBreakpointFunctionalityOnPrimaryClass")); 101 suite.addTest(new Breakpoints("testClassBreakpointFunctionalityOnSecondClass")); 102 suite.addTest(new Breakpoints("testClassBreakpointFunctionalityWithFilter")); 103 suite.addTest(new Breakpoints("testFieldBreakpointPrefilledValues")); 104 suite.addTest(new Breakpoints("testFieldBreakpointCreation")); 105 suite.addTest(new Breakpoints("testFieldBreakpointFunctionalityAccess")); 106 suite.addTest(new Breakpoints("testFieldBreakpointFunctionalityModification")); 107 suite.addTest(new Breakpoints("testThreadBreakpointCreation")); 108 suite.addTest(new Breakpoints("testThreadBreakpointFunctionality")); 109 suite.addTest(new Breakpoints("testExceptionBreakpointCreation")); 110 suite.addTest(new Breakpoints("testExceptionBreakpointFunctionality")); 111 return suite; 112 } 113 114 117 public void setUp() { 118 System.out.println("######## " + getName() + " ####### "); 119 } 120 121 124 public void tearDown() { 125 JemmyProperties.getCurrentOutput().printTrace("\nteardown\n"); 126 Utilities.endAllSessions(); 127 Utilities.deleteAllBreakpoints(); 128 } 129 130 133 public void testLineBreakpointCreation() throws Throwable { 134 try { 135 Node beanNode = new Node(new SourcePackagesNode(Utilities.testProjectName), "examples.advanced|MemoryView.java"); new OpenAction().performAPI(beanNode); 138 EditorOperator eo = new EditorOperator("MemoryView.java"); 139 Utilities.toggleBreakpoint(eo, 73); 141 Utilities.showDebuggerView(Utilities.breakpointsViewTitle); 142 JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.breakpointsViewTitle)); 143 assertEquals("Line MemoryView.java:73", jTableOperator.getValueAt(0, 0).toString()); 144 eo = new EditorOperator("MemoryView.java"); 145 Utilities.toggleBreakpoint(eo, 73, false); 146 new EventTool().waitNoEvent(1000); 147 jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.breakpointsViewTitle)); 148 assertEquals(0, jTableOperator.getRowCount()); 149 } catch (Throwable th) { 150 try { 151 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 153 } catch (Exception e1) { 154 } 156 throw th; 157 } 158 } 159 160 163 public void testLineBreakpointFunctionality() throws Throwable { 164 try { 165 EditorOperator eo = new EditorOperator("MemoryView.java"); 166 Utilities.toggleBreakpoint(eo, 73); 168 Utilities.startDebugger(); 169 Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:73", 0); 170 } catch (Throwable th) { 171 try { 172 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 174 } catch (Exception e1) { 175 } 177 throw th; 178 } 179 } 180 181 184 public void testLineBreakpointFunctionalityAfterContinue() throws Throwable { 185 try { 186 EditorOperator eo = new EditorOperator("MemoryView.java"); 187 Utilities.toggleBreakpoint(eo, 52); 189 Utilities.startDebugger(); 190 Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:52", 0); 191 eo = new EditorOperator("MemoryView.java"); 192 Utilities.toggleBreakpoint(eo, 74); 193 new ContinueAction().perform(); 194 Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:74", 0); 195 } catch (Throwable th) { 196 try { 197 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 199 } catch (Exception e1) { 200 } 202 throw th; 203 } 204 } 205 206 209 public void testLineBreakpointFunctionalityInStaticMethod() throws Throwable { 210 try { 211 EditorOperator eo = new EditorOperator("MemoryView.java"); 212 Utilities.toggleBreakpoint(eo, 114); 214 Utilities.startDebugger(); 215 Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:114", 0); 216 } catch (Throwable th) { 217 try { 218 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 220 } catch (Exception e1) { 221 } 223 throw th; 224 } 225 } 226 227 230 public void testLineBreakpointFunctionalityInInitializer() throws Throwable { 231 try { 232 EditorOperator eo = new EditorOperator("MemoryView.java"); 233 Utilities.toggleBreakpoint(eo, 45); 235 Utilities.startDebugger(); 236 Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:45", 0); 237 } catch (Throwable th) { 238 try { 239 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 241 } catch (Exception e1) { 242 } 244 throw th; 245 } 246 } 247 248 251 public void testLineBreakpointFunctionalityInConstructor() throws Throwable { 252 try { 253 EditorOperator eo = new EditorOperator("MemoryView.java"); 254 Utilities.toggleBreakpoint(eo, 54); 256 Utilities.startDebugger(); 257 Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:54", 0); 258 } catch (Throwable th) { 259 try { 260 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 262 } catch (Exception e1) { 263 } 265 throw th; 266 } 267 } 268 269 272 public void testLineBreakpointFunctionalityInInnerClass() throws Throwable { 273 try { 274 EditorOperator eo = new EditorOperator("MemoryView.java"); 275 Utilities.toggleBreakpoint(eo, 123); 277 Utilities.startDebugger(); 278 Utilities.waitDebuggerConsole("Thread Thread-0 stopped at MemoryView.java:123", 0); 279 } catch (Throwable th) { 280 try { 281 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 283 } catch (Exception e1) { 284 } 286 throw th; 287 } 288 } 289 290 293 public void testLineBreakpointFunctionalityInSecondaryClass() throws Throwable { 294 try { 295 EditorOperator eo = new EditorOperator("MemoryView.java"); 296 Utilities.toggleBreakpoint(eo, 154); 298 Utilities.startDebugger(); 299 Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:154", 0); 300 } catch (Throwable th) { 301 try { 302 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 304 } catch (Exception e1) { 305 } 307 throw th; 308 } 309 } 310 311 314 public void testConditionalLineBreakpointFunctionality() throws Throwable { 315 try { 316 EditorOperator eo = new EditorOperator("MemoryView.java"); 317 Utilities.toggleBreakpoint(eo, 63); 319 Utilities.toggleBreakpoint(eo, 64); 320 321 Utilities.showDebuggerView(Utilities.breakpointsViewTitle); 322 JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.breakpointsViewTitle)); 323 assertEquals("Line MemoryView.java:64", jTableOperator.getValueAt(1, 0).toString()); 324 new JPopupMenuOperator(jTableOperator.callPopupOnCell(1, 0)).pushMenuNoBlock("Customize"); 325 NbDialogOperator dialog = new NbDialogOperator(Utilities.customizeBreakpointTitle); 326 new JEditorPaneOperator(dialog, 0).setText("i > 0"); 327 dialog.ok(); 328 Utilities.startDebugger(); 329 int lines = Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:63", 0); 330 new ContinueAction().perform(); 331 lines = Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:63", lines+1); 332 new ContinueAction().perform(); 333 Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:64", lines+1); 334 } catch (Throwable th) { 335 try { 336 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 338 } catch (Exception e1) { 339 } 341 throw th; 342 } 343 } 344 345 348 public void testMethodBreakpointPrefilledConstructor() throws Throwable { 349 try { 350 NbDialogOperator dialog = Utilities.newBreakpoint(53); 351 new JComboBoxOperator(dialog, 0).selectItem("Method"); 352 assertEquals("Package Name was not set to correct value.", "examples.advanced", new JTextFieldOperator(dialog, 1).getText()); 353 assertEquals("Class Name was not set to correct value.", "MemoryView", new JTextFieldOperator(dialog, 2).getText()); 354 assertEquals("Method Name was not set to correct value.", "<init>", new JTextFieldOperator(dialog, 3).getText()); 355 dialog.cancel(); 356 } catch (Throwable th) { 357 try { 358 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 360 } catch (Exception e1) { 361 } 363 throw th; 364 } 365 } 366 367 370 public void testMethodBreakpointPrefilledMethod() throws Throwable { 371 try { 372 NbDialogOperator dialog = Utilities.newBreakpoint(92); 373 new JComboBoxOperator(dialog, 0).selectItem("Method"); 374 assertEquals("Package Name was not set to correct value.", "examples.advanced", new JTextFieldOperator(dialog, 1).getText()); 375 assertEquals("Class Name was not set to correct value.", "MemoryView", new JTextFieldOperator(dialog, 2).getText()); 376 assertEquals("Method Name was not set to correct value.", "updateStatus", new JTextFieldOperator(dialog, 3).getText()); 377 dialog.cancel(); 378 } catch (Throwable th) { 379 try { 380 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 382 } catch (Exception e1) { 383 } 385 throw th; 386 } 387 } 388 389 392 public void testMethodBreakpointCreation() throws Throwable { 393 try { 394 NbDialogOperator dialog = Utilities.newBreakpoint(92); 395 new JComboBoxOperator(dialog, 0).selectItem("Method"); 396 dialog.ok(); 397 Utilities.showDebuggerView(Utilities.breakpointsViewTitle); 398 JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.breakpointsViewTitle)); 399 assertEquals("Method MemoryView.updateStatus", jTableOperator.getValueAt(0, 0).toString()); 400 } catch (Throwable th) { 401 try { 402 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 404 } catch (Exception e1) { 405 } 407 throw th; 408 } 409 } 410 411 414 public void testMethodBreakpointFunctionalityInPrimaryClass() throws Throwable { 415 try { 416 NbDialogOperator dialog = Utilities.newBreakpoint(92); 417 new JComboBoxOperator(dialog, 0).selectItem("Method"); 418 dialog.ok(); 419 Utilities.startDebugger(); 420 Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:92", 0); 421 } catch (Throwable th) { 422 try { 423 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 425 } catch (Exception e1) { 426 } 428 throw th; 429 } 430 } 431 432 435 public void testMethodBreakpointFunctionalityInSecondClass() throws Throwable { 436 try { 437 NbDialogOperator dialog = Utilities.newBreakpoint(154); 438 new JComboBoxOperator(dialog, 0).selectItem("Method"); 439 dialog.ok(); 440 Utilities.startDebugger(); 441 Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:154", 0); 442 } catch (Throwable th) { 443 try { 444 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 446 } catch (Exception e1) { 447 } 449 throw th; 450 } 451 } 452 453 456 public void testMethodBreakpointFunctionalityOnAllMethods() throws Throwable { 457 try { 458 NbDialogOperator dialog = Utilities.newBreakpoint(37); 459 new JComboBoxOperator(dialog, 0).selectItem("Method"); 460 dialog.ok(); 461 Utilities.startDebugger(); 462 int lines = Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:39", 0); 463 new ContinueAction().perform(); 464 lines = Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:114", lines+1); 465 new ContinueAction().perform(); 466 lines = Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:50", lines+1); 467 new ContinueAction().perform(); 468 lines = Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:51", lines+1); 469 new ContinueAction().perform(); 470 lines = Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:121", lines+1); 471 new ContinueAction().perform(); 472 lines = Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:79", lines+1); 473 new ContinueAction().perform(); 474 Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:92", lines+1); 475 } catch (Throwable th) { 476 try { 477 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 479 } catch (Exception e1) { 480 } 482 throw th; 483 } 484 } 485 486 489 public void testClassBreakpointPrefilledInClass() throws Throwable { 490 try { 491 NbDialogOperator dialog = Utilities.newBreakpoint(27); 492 if (!new JComboBoxOperator(dialog, 0).getSelectedItem().equals("Class")) 493 new JComboBoxOperator(dialog, 0).selectItem("Class"); 494 assertEquals("Package Name was not set to correct value.", "", new JTextFieldOperator(dialog, 0).getText()); 495 assertEquals("Class Name was not set to correct value.", "", new JTextFieldOperator(dialog, 1).getText()); 496 dialog.cancel(); 497 } catch (Throwable th) { 498 try { 499 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 501 } catch (Exception e1) { 502 } 504 throw th; 505 } 506 } 507 508 511 public void testClassBreakpointPrefilledInInitializer() throws Throwable { 512 try { 513 NbDialogOperator dialog = Utilities.newBreakpoint(38); 514 if (!new JComboBoxOperator(dialog, 0).getSelectedItem().equals("Class")) 515 new JComboBoxOperator(dialog, 0).selectItem("Class"); 516 assertEquals("Package Name was not set to correct value.", "examples.advanced", new JTextFieldOperator(dialog, 0).getText()); 517 assertEquals("Class Name was not set to correct value.", "MemoryView", new JTextFieldOperator(dialog, 1).getText()); 518 dialog.cancel(); 519 } catch (Throwable th) { 520 try { 521 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 523 } catch (Exception e1) { 524 } 526 throw th; 527 } 528 } 529 530 533 public void testClassBreakpointPrefilledInConstructor() throws Throwable { 534 try { 535 NbDialogOperator dialog = Utilities.newBreakpoint(45); 536 if (!new JComboBoxOperator(dialog, 0).getSelectedItem().equals("Class")) 537 new JComboBoxOperator(dialog, 0).selectItem("Class"); 538 assertEquals("Package Name was not set to correct value.", "examples.advanced", new JTextFieldOperator(dialog, 0).getText()); 539 assertEquals("Class Name was not set to correct value.", "MemoryView", new JTextFieldOperator(dialog, 1).getText()); 540 dialog.cancel(); 541 } catch (Throwable th) { 542 try { 543 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 545 } catch (Exception e1) { 546 } 548 throw th; 549 } 550 } 551 552 555 public void testClassBreakpointPrefilledInMethod() throws Throwable { 556 try { 557 NbDialogOperator dialog = Utilities.newBreakpoint(80); 558 if (!new JComboBoxOperator(dialog, 0).getSelectedItem().equals("Class")) 559 new JComboBoxOperator(dialog, 0).selectItem("Class"); 560 assertEquals("Package Name was not set to correct value.", "examples.advanced", new JTextFieldOperator(dialog, 0).getText()); 561 assertEquals("Class Name was not set to correct value.", "MemoryView", new JTextFieldOperator(dialog, 1).getText()); 562 dialog.cancel(); 563 } catch (Throwable th) { 564 try { 565 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 567 } catch (Exception e1) { 568 } 570 throw th; 571 } 572 } 573 574 577 public void testClassBreakpointPrefilledInSecondClass() throws Throwable { 578 try { 579 NbDialogOperator dialog = Utilities.newBreakpoint(154); 580 if (!new JComboBoxOperator(dialog, 0).getSelectedItem().equals("Class")) 581 new JComboBoxOperator(dialog, 0).selectItem("Class"); 582 assertEquals("Package Name was not set to correct value.", "examples.advanced", new JTextFieldOperator(dialog, 0).getText()); 583 assertEquals("Class Name was not set to correct value.", "Helper", new JTextFieldOperator(dialog, 1).getText()); 584 dialog.cancel(); 585 } catch (Throwable th) { 586 try { 587 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 589 } catch (Exception e1) { 590 } 592 throw th; 593 } 594 } 595 596 599 public void testClassBreakpointCreation() throws Throwable { 600 try { 601 NbDialogOperator dialog = Utilities.newBreakpoint(73); 602 new JComboBoxOperator(dialog, 0).selectItem("Class"); 603 dialog.ok(); 604 Utilities.showDebuggerView(Utilities.breakpointsViewTitle); 605 JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.breakpointsViewTitle)); 606 assertEquals("Class breakpoint was not created.", "Class MemoryView prepare / unload", jTableOperator.getValueAt(0, 0).toString()); 607 } catch (Throwable th) { 608 try { 609 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 611 } catch (Exception e1) { 612 } 614 throw th; 615 } 616 } 617 618 621 public void testClassBreakpointFunctionalityOnPrimaryClass() throws Throwable { 622 try { 623 NbDialogOperator dialog = Utilities.newBreakpoint(73); 624 new JComboBoxOperator(dialog, 0).selectItem("Class"); 625 dialog.ok(); 626 new EventTool().waitNoEvent(500); 627 Utilities.startDebugger(); 628 int lines = Utilities.waitDebuggerConsole("Thread main stopped.", 0); 629 new ContinueAction().perform(); 630 Utilities.waitDebuggerConsole(Utilities.runningStatusBarText, lines+1); 631 } catch (Throwable th) { 632 try { 633 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 635 } catch (Exception e1) { 636 } 638 throw th; 639 } 640 } 641 642 645 public void testClassBreakpointFunctionalityOnSecondClass() throws Throwable { 646 try { 647 NbDialogOperator dialog = Utilities.newBreakpoint(154); 648 new JComboBoxOperator(dialog, 0).selectItem("Class"); 649 dialog.ok(); 650 Utilities.startDebugger(); 651 int lines = Utilities.waitDebuggerConsole("Thread main stopped.", 0); 652 new ContinueAction().perform(); 653 Utilities.waitDebuggerConsole(Utilities.runningStatusBarText, lines+1); 654 } catch (Throwable th) { 655 try { 656 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 658 } catch (Exception e1) { 659 } 661 throw th; 662 } 663 } 664 665 668 public void testClassBreakpointFunctionalityWithFilter() throws Throwable { 669 try { 670 NbDialogOperator dialog = Utilities.newBreakpoint(73); 671 new JComboBoxOperator(dialog, 0).selectItem("Class"); 672 new JTextFieldOperator(dialog, 1).setText("*"); 673 dialog.ok(); 674 675 new DebugProjectAction().perform(); 676 Utilities.getDebugToolbar().waitComponentVisible(true); 677 int lines = Utilities.waitDebuggerConsole("Thread main stopped.", 0); 679 new EventTool().waitNoEvent(500); 680 new ContinueAction().perform(); 681 lines = Utilities.waitDebuggerConsole("Thread main stopped.", lines+1); 683 new ContinueAction().perform(); 684 lines = Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:121.", lines+1); 686 new ContinueAction().perform(); 687 Utilities.waitDebuggerConsole(Utilities.runningStatusBarText, lines+1); 688 } catch (Throwable th) { 689 try { 690 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 692 } catch (Exception e1) { 693 } 695 throw th; 696 } 697 } 698 699 702 public void testFieldBreakpointPrefilledValues() throws Throwable { 703 try { 704 NbDialogOperator dialog = Utilities.newBreakpoint(36, 36); 705 new JComboBoxOperator(dialog, 0).selectItem("Field"); 706 assertEquals("Package Name was not set to correct value.", "examples.advanced", new JTextFieldOperator(dialog, 1).getText()); 707 assertEquals("Class Name was not set to correct value.", "MemoryView", new JTextFieldOperator(dialog, 2).getText()); 708 assertEquals("Field Name was not set to correct value.", "msgMemory", new JTextFieldOperator(dialog, 3).getText()); 709 dialog.cancel(); 710 } catch (Throwable th) { 711 try { 712 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 714 } catch (Exception e1) { 715 } 717 throw th; 718 } 719 } 720 721 724 public void testFieldBreakpointCreation() throws Throwable { 725 try { 726 NbDialogOperator dialog = Utilities.newBreakpoint(36, 36); 727 new JComboBoxOperator(dialog, 0).selectItem("Field"); 728 new JComboBoxOperator(dialog, 1).selectItem("Field Access"); 729 dialog.ok(); 730 Utilities.showDebuggerView(Utilities.breakpointsViewTitle); 731 JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.breakpointsViewTitle)); 732 assertEquals("Field breakpoint was not created.", "Field MemoryView.msgMemory access", jTableOperator.getValueAt(0, 0).toString()); 733 } catch (Throwable th) { 734 try { 735 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 737 } catch (Exception e1) { 738 } 740 throw th; 741 } 742 } 743 744 747 public void testFieldBreakpointFunctionalityAccess() throws Throwable { 748 try { 749 NbDialogOperator dialog = Utilities.newBreakpoint(36, 36); 750 new JComboBoxOperator(dialog, 0).selectItem("Field"); 751 new JComboBoxOperator(dialog, 1).selectItem("Field Access"); 752 dialog.ok(); 753 Utilities.startDebugger(); 754 Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:104.", 0); 755 } catch (Throwable th) { 756 try { 757 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 759 } catch (Exception e1) { 760 } 762 throw th; 763 } 764 } 765 766 769 public void testFieldBreakpointFunctionalityModification() throws Throwable { 770 try { 771 NbDialogOperator dialog = Utilities.newBreakpoint(36, 36); 772 new JComboBoxOperator(dialog, 0).selectItem("Field"); 773 new JComboBoxOperator(dialog, 1).selectItem("Field Modification"); 774 dialog.ok(); 775 Utilities.startDebugger(); 776 Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:45", 0); 777 } catch (Throwable th) { 778 try { 779 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 781 } catch (Exception e1) { 782 } 784 throw th; 785 } 786 } 787 788 791 public void testThreadBreakpointCreation() throws Throwable { 792 try { 793 new NewBreakpointAction().perform(); 794 NbDialogOperator dialog = new NbDialogOperator(Utilities.newBreakpointTitle); 795 new JComboBoxOperator(dialog, 0).selectItem("Thread"); 796 dialog.ok(); 797 Utilities.showDebuggerView(Utilities.breakpointsViewTitle); 798 JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.breakpointsViewTitle)); 799 assertEquals("Thread breakpoint was not created.", "Thread started", jTableOperator.getValueAt(0, 0).toString()); 800 } catch (Throwable th) { 801 try { 802 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 804 } catch (Exception e1) { 805 } 807 throw th; 808 } 809 } 810 811 814 public void testThreadBreakpointFunctionality() throws Throwable { 815 try { 816 new NewBreakpointAction().perform(); 817 NbDialogOperator dialog = new NbDialogOperator(Utilities.newBreakpointTitle); 818 new JComboBoxOperator(dialog, 0).selectItem("Thread"); 819 dialog.ok(); 820 821 Utilities.startDebugger(); 822 int lines = Utilities.waitDebuggerConsole("Thread breakpoint hit by thread ", 0); 823 new ContinueAction().perform(); 824 lines = Utilities.waitDebuggerConsole("Thread breakpoint hit by thread ", lines+1); 825 new ContinueAction().perform(); 826 Utilities.waitDebuggerConsole(Utilities.runningStatusBarText, lines+1); 827 } catch (Throwable th) { 828 try { 829 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 831 } catch (Exception e1) { 832 } 834 throw th; 835 } 836 } 837 838 841 public void testExceptionBreakpointCreation() throws Throwable { 842 try { 843 new NewBreakpointAction().perform(); 844 NbDialogOperator dialog = new NbDialogOperator(Utilities.newBreakpointTitle); 845 new JComboBoxOperator(dialog, 0).selectItem("Exception"); 846 847 new JTextFieldOperator(dialog, 2).setText("java.lang"); 848 new JComboBoxOperator(dialog, 2).typeText("NullPointerException"); 849 new JComboBoxOperator(dialog, 1).selectItem("Caught or Uncaught"); 850 dialog.ok(); 851 Utilities.showDebuggerView(Utilities.breakpointsViewTitle); 852 JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.breakpointsViewTitle)); 853 assertEquals("Thread breakpoint was not created.", "Exception NullPointerException", jTableOperator.getValueAt(0, 0).toString()); 854 } catch (Throwable th) { 855 try { 856 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 858 } catch (Exception e1) { 859 } 861 throw th; 862 } 863 } 864 865 868 public void testExceptionBreakpointFunctionality() throws Throwable { 869 try { 870 new NewBreakpointAction().perform(); 871 NbDialogOperator dialog = new NbDialogOperator(Utilities.newBreakpointTitle); 872 new JComboBoxOperator(dialog, 0).selectItem("Exception"); 873 new JTextFieldOperator(dialog, 2).setText("java.lang"); 874 new JComboBoxOperator(dialog, 2).typeText("ClassNotFoundException"); 875 new JComboBoxOperator(dialog, 1).selectItem("Caught or Uncaught"); 876 dialog.ok(); 877 Utilities.startDebugger(); 878 new ContinueAction().perform(); 879 Utilities.waitDebuggerConsole("Thread main stopped at URLClassLoader.java", 0); 880 } catch (Throwable th) { 881 try { 882 PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png"); 884 } catch (Exception e1) { 885 } 887 throw th; 888 } 889 } 890 } 891 | Popular Tags |