1 33 34 package edu.rice.cs.drjava.model.debug; 35 36 import java.io.*; 37 import java.util.Vector ; 38 39 import edu.rice.cs.drjava.DrJava; 40 import edu.rice.cs.drjava.config.*; 41 import edu.rice.cs.drjava.model.*; 42 import edu.rice.cs.util.swing.Utilities; 43 44 47 public final class DebugContextTest extends DebugTestCase { 48 49 50 53 54 public void testDebugSourcepath() throws Exception { 55 _log.log("----testDebugSourcePath----"); 56 final StepTestListener debugListener = new StepTestListener(); 57 _debugger.addListener(debugListener); 58 59 final OpenDefinitionsDocument doc = _startupDebugger("DrJavaDebugClass.java", DEBUG_CLASS); 61 final Vector <File> path = new Vector <File>(); 62 path.addElement(_tempDir); 64 _debugger.toggleBreakpoint(doc,DEBUG_CLASS.indexOf("bar();"),4,true); 66 67 synchronized(_notifierLock) { 69 _setPendingNotifies(3); interpretIgnoreResult("new DrJavaDebugClass().foo()"); 71 while (_pendingNotifies > 0) _notifierLock.wait(); 72 } 73 debugListener.assertThreadLocationUpdatedCount(1); 76 synchronized(_notifierLock) { 78 _setPendingNotifies(2); _asyncStep(Debugger.STEP_INTO); 80 while (_pendingNotifies > 0) _notifierLock.wait(); 81 } 82 debugListener.assertStepRequestedCount(1); debugListener.assertThreadLocationUpdatedCount(2); 86 _model.closeFile(doc); 88 Utilities.clearEventQueue(); 89 debugListener.assertRegionRemovedCount(1); 90 91 synchronized(_notifierLock) { 93 _setPendingNotifies(1); _asyncStep(Debugger.STEP_OVER); 95 while (_pendingNotifies > 0) _notifierLock.wait(); 96 } 97 debugListener.assertStepRequestedCount(2); debugListener.assertThreadLocationUpdatedCount(2); 101 synchronized(_debugger) { 102 Utilities.invokeAndWait(new Runnable () { 104 public void run() { 105 DrJava.getConfig().setSetting(OptionConstants.DEBUG_SOURCEPATH, path); 106 } 107 }); 108 } 109 110 synchronized(_notifierLock) { 112 _asyncStep(Debugger.STEP_OVER); 113 _setPendingNotifies(2); while (_pendingNotifies > 0) _notifierLock.wait(); 115 } 116 debugListener.assertStepRequestedCount(3); debugListener.assertThreadLocationUpdatedCount(3); 120 _log.log("Shutting down testDebugSourcePath"); 121 122 _shutdownAndWaitForInteractionEnded(); 124 _debugger.removeListener(debugListener); 125 } 126 127 128 public synchronized void testBreakpointsAndStepsInNonPublicClasses() throws Exception { 129 _log.log("----testBreakpointsAndStepsInNonPublicClasses----"); 130 final StepTestListener debugListener = new StepTestListener(); 131 _debugger.addListener(debugListener); 132 133 OpenDefinitionsDocument doc = _startupDebugger("DrJavaDebugClass.java", DEBUG_CLASS); 135 136 _debugger.toggleBreakpoint(doc,DEBUG_CLASS.indexOf("Baz Line 1"), 14,true); 138 139 Utilities.clearEventQueue(); 140 debugListener.assertRegionAddedCount(1); 141 142 synchronized(_notifierLock) { 144 _setPendingNotifies(3); interpretIgnoreResult("new DrJavaDebugClass2().baz()"); 146 while (_pendingNotifies > 0) _notifierLock.wait(); 147 } 148 149 151 debugListener.assertBreakpointReachedCount(1); debugListener.assertThreadLocationUpdatedCount(1); debugListener.assertCurrThreadSuspendedCount(1); debugListener.assertCurrThreadResumedCount(0); 156 debugListener.assertCurrThreadDiedCount(0); 157 assertInteractionsDoesNotContain("Baz Line 1"); 158 159 161 _debugger.toggleBreakpoint(doc, DEBUG_CLASS.indexOf("System.out.println(\"Bar Line 2\")"), 9,true); 163 164 Utilities.clearEventQueue(); 165 debugListener.assertRegionAddedCount(2); 166 167 synchronized(_notifierLock) { 169 _setPendingNotifies(2); _asyncStep(Debugger.STEP_OVER); 171 while (_pendingNotifies > 0) _notifierLock.wait(); 172 } 173 174 debugListener.assertStepRequestedCount(1); debugListener.assertCurrThreadResumedCount(1); debugListener.assertThreadLocationUpdatedCount(2); debugListener.assertCurrThreadDiedCount(0); 179 debugListener.assertCurrThreadSuspendedCount(2); debugListener.assertBreakpointReachedCount(1); 181 assertInteractionsContains("Baz Line 1"); 182 assertInteractionsDoesNotContain("Bar Line 1"); 183 184 synchronized(_notifierLock) { 186 _setPendingNotifies(3); _asyncResume(); 189 while (_pendingNotifies > 0) _notifierLock.wait(); 190 } 191 debugListener.assertCurrThreadResumedCount(2); debugListener.assertBreakpointReachedCount(2); debugListener.assertThreadLocationUpdatedCount(3); debugListener.assertCurrThreadSuspendedCount(3); debugListener.assertCurrThreadDiedCount(0); 197 assertInteractionsContains("Bar Line 1"); 198 assertInteractionsDoesNotContain("Bar Line 2"); 199 200 InterpretListener interpretListener = new InterpretListener(); 203 _model.addListener(interpretListener); 204 synchronized(_notifierLock) { 205 _setPendingNotifies(3); _asyncResume(); 208 while (_pendingNotifies > 0) _notifierLock.wait(); 209 } 210 interpretListener.assertInteractionEndCount(1); 211 _model.removeListener(interpretListener); 212 213 _log.log("----After second resume:\n" + getInteractionsText()); 214 debugListener.assertCurrThreadResumedCount(3); debugListener.assertBreakpointReachedCount(2); 216 debugListener.assertThreadLocationUpdatedCount(3); 217 debugListener.assertCurrThreadSuspendedCount(3); 218 assertInteractionsContains("Bar Line 2"); 219 220 _shutdownWithoutSuspendedInteraction(); 222 _debugger.removeListener(debugListener); 223 } 224 225 226 public synchronized void testStepIntoOverBreakpoint() throws Exception { 227 _log.log("----testStepIntoOverBreakpoint----"); 228 StepTestListener debugListener = new StepTestListener(); 229 _debugger.addListener(debugListener); 230 231 OpenDefinitionsDocument doc = _startupDebugger("DrJavaDebugClass.java", DEBUG_CLASS); 233 234 _debugger.toggleBreakpoint(doc,DEBUG_CLASS.indexOf("Foo Line 1"), 3,true); 236 _debugger.toggleBreakpoint(doc,DEBUG_CLASS.indexOf("bar();\n"), 4,true); 237 238 Utilities.clearEventQueue(); 239 debugListener.assertRegionAddedCount(2); 240 241 synchronized(_notifierLock) { 243 _setPendingNotifies(3); interpretIgnoreResult("new DrJavaDebugClass().foo()"); 245 while (_pendingNotifies > 0) _notifierLock.wait(); 246 } 247 248 250 debugListener.assertBreakpointReachedCount(1); debugListener.assertThreadLocationUpdatedCount(1); debugListener.assertCurrThreadSuspendedCount(1); debugListener.assertCurrThreadResumedCount(0); 255 debugListener.assertCurrThreadDiedCount(0); 256 assertInteractionsDoesNotContain("Foo Line 1"); 257 258 synchronized(_notifierLock) { 260 _setPendingNotifies(2); _asyncStep(Debugger.STEP_OVER); 262 while (_pendingNotifies > 0) _notifierLock.wait(); 263 } 264 debugListener.assertStepRequestedCount(1); debugListener.assertCurrThreadResumedCount(1); debugListener.assertThreadLocationUpdatedCount(2); debugListener.assertCurrThreadSuspendedCount(2); debugListener.assertBreakpointReachedCount(1); 269 debugListener.assertCurrThreadDiedCount(0); 270 assertInteractionsContains("Foo Line 1"); 271 272 synchronized(_notifierLock) { 274 _setPendingNotifies(2); _asyncStep(Debugger.STEP_OVER); 276 while (_pendingNotifies > 0) _notifierLock.wait(); 277 } 278 279 debugListener.assertStepRequestedCount(2); debugListener.assertCurrThreadResumedCount(2); debugListener.assertThreadLocationUpdatedCount(3); debugListener.assertCurrThreadDiedCount(0); 284 debugListener.assertCurrThreadSuspendedCount(3); debugListener.assertBreakpointReachedCount(1); 286 287 InterpretListener interpretListener = new InterpretListener(); 289 _model.addListener(interpretListener); 290 synchronized(_notifierLock) { 291 _setPendingNotifies(3); _asyncResume(); 293 while (_pendingNotifies > 0) _notifierLock.wait(); 294 } 295 interpretListener.assertInteractionEndCount(1); 296 _model.removeListener(interpretListener); 297 298 debugListener.assertCurrThreadResumedCount(3); debugListener.assertBreakpointReachedCount(1); 301 debugListener.assertThreadLocationUpdatedCount(3); 302 debugListener.assertCurrThreadSuspendedCount(3); 303 304 _model.closeFile(doc); 306 Utilities.clearEventQueue(); 307 debugListener.assertRegionRemovedCount(2); 309 312 synchronized(_notifierLock) { 313 _setPendingNotifies(1); _debugger.shutdown(); 315 while (_pendingNotifies > 0) _notifierLock.wait(); 316 } 317 318 debugListener.assertDebuggerShutdownCount(1); _log.log("Completed testStepIntoOverBreakpoint"); 320 _debugger.removeListener(debugListener); 321 } 322 323 324 public void testStaticFieldsConsistent() throws Exception { 325 _log.log("----testStaticFieldsConsistent----"); 326 StepTestListener debugListener = new StepTestListener(); 327 _debugger.addListener(debugListener); 328 329 OpenDefinitionsDocument doc = _startupDebugger("DrJavaDebugStaticField.java", CLASS_WITH_STATIC_FIELD); 331 332 _debugger.toggleBreakpoint(doc,CLASS_WITH_STATIC_FIELD.indexOf("System.out.println"), 4,true); 334 335 Utilities.clearEventQueue(); 336 debugListener.assertRegionAddedCount(1); 337 338 synchronized(_notifierLock) { 340 _setPendingNotifies(6); interpretIgnoreResult("java DrJavaDebugStaticField"); 342 while (_pendingNotifies > 0) _notifierLock.wait(); 343 } 344 345 DebugThreadData threadA = new DebugThreadData(_debugger.getCurrentThread()); 347 DebugThreadData threadB = new DebugThreadData(_debugger.getThreadAt(1)); 348 350 debugListener.assertBreakpointReachedCount(2); debugListener.assertThreadLocationUpdatedCount(2); debugListener.assertCurrThreadSuspendedCount(2); debugListener.assertCurrThreadResumedCount(0); 355 debugListener.assertCurrThreadDiedCount(0); 356 assertEquals("x has correct value at start", "0", interpret("DrJavaDebugStaticField.x")); 357 assertEquals("assigning x succeeds", "5", interpret("DrJavaDebugStaticField.x = 5")); 358 assertEquals("assignment reflected in this", "5", interpret("this.x")); 359 360 synchronized(_notifierLock) { 362 _setPendingNotifies(2); _asyncStep(Debugger.STEP_OVER); 364 while (_pendingNotifies > 0) _notifierLock.wait(); 365 } 366 debugListener.assertStepRequestedCount(1); debugListener.assertCurrThreadResumedCount(1); debugListener.assertThreadLocationUpdatedCount(3); debugListener.assertCurrThreadSuspendedCount(3); debugListener.assertBreakpointReachedCount(2); 371 debugListener.assertCurrThreadDiedCount(0); 372 assertInteractionsContains("x == 5"); 373 assertEquals("x retains correct value after step", "5", interpret("DrJavaDebugStaticField.x")); 374 assertEquals("this has correct value for x after step", "5", interpret("this.x")); 375 376 synchronized(_notifierLock) { 378 _setPendingNotifies(2); _asyncStep(Debugger.STEP_OVER); 380 while (_pendingNotifies > 0) _notifierLock.wait(); 381 } 382 debugListener.assertStepRequestedCount(2); debugListener.assertCurrThreadResumedCount(2); debugListener.assertThreadLocationUpdatedCount(4); debugListener.assertCurrThreadSuspendedCount(4); debugListener.assertBreakpointReachedCount(2); 388 debugListener.assertCurrThreadDiedCount(0); 389 assertEquals("x has correct value after increment", "6", interpret("DrJavaDebugStaticField.x")); 390 assertEquals("this has correct value for x after increment", "6", interpret("this.x")); 391 392 synchronized(_notifierLock) { 393 _setPendingNotifies(2); _asyncDoSetCurrentThread(threadB); 395 while (_pendingNotifies > 0) _notifierLock.wait(); 396 } 397 interpret(""); 398 assertInteractionsContains("The current thread has changed."); 399 assertEquals("x has correct value in other thread", "6", interpret("DrJavaDebugStaticField.x")); 400 assertEquals("this has correct value for x in other thread", "6", interpret("this.x")); 401 402 _shutdownAndWaitForInteractionEnded(); 404 _debugger.removeListener(debugListener); 405 } 406 407 411 public void testNonStaticWatches() throws Exception { 412 _log.log("----testNonStaticWatches----"); 413 StepTestListener debugListener = new StepTestListener(); 414 _debugger.addListener(debugListener); 415 416 final String monkey = MONKEY_WITH_INNER_CLASS; 417 418 OpenDefinitionsDocument doc = _startupDebugger("Monkey.java", monkey); 420 421 _debugger.toggleBreakpoint(doc, monkey.indexOf("innerMethodFoo = 12;"), 10, true); 423 _debugger.toggleBreakpoint(doc, monkey.indexOf("System.out.println(\"localVar = \" + localVar);"), 32, true); 424 425 Utilities.clearEventQueue(); 426 debugListener.assertRegionAddedCount(2); 427 428 synchronized(_notifierLock) { 430 _setPendingNotifies(3); interpretIgnoreResult("new Monkey().bar()"); while (_pendingNotifies > 0) _notifierLock.wait(); 433 } 434 435 _debugger.addWatch("foo"); 436 _debugger.addWatch("innerFoo"); 437 _debugger.addWatch("innerInnerFoo"); 438 _debugger.addWatch("innerMethodFoo"); 439 _debugger.addWatch("asdf"); 440 _debugger.addWatch("nullString"); 441 _debugger.addWatch("localVar"); 442 Utilities.clearEventQueue(); 443 debugListener.assertWatchSetCount(7); 444 445 447 synchronized(_notifierLock) { 449 _setPendingNotifies(2); _asyncStep(Debugger.STEP_OVER); 451 while (_pendingNotifies > 0) _notifierLock.wait(); 452 } 453 debugListener.assertStepRequestedCount(1); debugListener.assertCurrThreadResumedCount(1); debugListener.assertThreadLocationUpdatedCount(2); debugListener.assertCurrThreadSuspendedCount(2); debugListener.assertBreakpointReachedCount(1); 458 debugListener.assertCurrThreadDiedCount(0); 459 460 Vector <DebugWatchData> watches = _debugger.getWatches(); 461 assertEquals("watch name incorrect", "foo", watches.get(0).getName()); 462 assertEquals("watch name incorrect", "innerFoo", watches.get(1).getName()); 463 assertEquals("watch name incorrect", "innerInnerFoo", watches.get(2).getName()); 464 assertEquals("watch name incorrect", "innerMethodFoo", watches.get(3).getName()); 465 assertEquals("watch name incorrect", "asdf", watches.get(4).getName()); 466 assertEquals("watch name incorrect", "nullString", watches.get(5).getName()); 467 assertEquals("watch value incorrect", "6", watches.get(0).getValue()); 468 assertEquals("watch value incorrect", "8", watches.get(1).getValue()); 469 assertEquals("watch value incorrect", "10", watches.get(2).getValue()); 470 assertEquals("watch value incorrect", "12", watches.get(3).getValue()); 471 assertEquals("watch value incorrect", DebugWatchData.NO_VALUE, watches.get(4).getValue()); 472 assertEquals("watch value incorrect", "null", watches.get(5).getValue()); 473 assertEquals("watch type incorrect", "java.lang.String", watches.get(5).getType()); 474 475 interpret("innerFoo = 0"); 476 watches = _debugger.getWatches(); 477 assertEquals("watch name incorrect", "innerFoo", watches.get(1).getName()); 478 assertEquals("watch value incorrect", "0", watches.get(1).getValue()); 479 480 interpret("innerFoo = 8"); 481 assertEquals("watch name incorrect", "innerFoo", watches.get(1).getName()); 482 assertEquals("watch value incorrect", "8", watches.get(1).getValue()); 483 484 486 synchronized(_notifierLock) { 488 _setPendingNotifies(2); _asyncStep(Debugger.STEP_OVER); 490 while (_pendingNotifies > 0) _notifierLock.wait(); 491 } 492 debugListener.assertStepRequestedCount(2); debugListener.assertCurrThreadResumedCount(2); debugListener.assertThreadLocationUpdatedCount(3); debugListener.assertCurrThreadSuspendedCount(3); debugListener.assertBreakpointReachedCount(1); 497 debugListener.assertCurrThreadDiedCount(0); 498 499 501 synchronized(_notifierLock) { 503 _setPendingNotifies(2); _asyncStep(Debugger.STEP_OVER); 505 while (_pendingNotifies > 0) _notifierLock.wait(); 506 } 507 debugListener.assertStepRequestedCount(3); debugListener.assertCurrThreadResumedCount(3); debugListener.assertThreadLocationUpdatedCount(4); debugListener.assertCurrThreadSuspendedCount(4); debugListener.assertBreakpointReachedCount(1); 512 debugListener.assertCurrThreadDiedCount(0); 513 514 516 synchronized(_notifierLock) { 518 _setPendingNotifies(2); _asyncStep(Debugger.STEP_OVER); 520 while (_pendingNotifies > 0) _notifierLock.wait(); 521 } 522 debugListener.assertStepRequestedCount(4); debugListener.assertCurrThreadResumedCount(4); debugListener.assertThreadLocationUpdatedCount(5); debugListener.assertCurrThreadSuspendedCount(5); debugListener.assertBreakpointReachedCount(1); 527 debugListener.assertCurrThreadDiedCount(0); 528 529 531 synchronized(_notifierLock) { 533 _setPendingNotifies(2); _asyncStep(Debugger.STEP_OVER); 535 while (_pendingNotifies > 0) _notifierLock.wait(); 536 } 537 debugListener.assertStepRequestedCount(5); debugListener.assertCurrThreadResumedCount(5); debugListener.assertThreadLocationUpdatedCount(6); debugListener.assertCurrThreadSuspendedCount(6); debugListener.assertBreakpointReachedCount(1); 542 debugListener.assertCurrThreadDiedCount(0); 543 544 watches = _debugger.getWatches(); 545 assertEquals("watch name incorrect", "foo", watches.get(0).getName()); 546 assertEquals("watch name incorrect", "innerFoo", watches.get(1).getName()); 547 assertEquals("watch name incorrect", "innerInnerFoo", watches.get(2).getName()); 548 assertEquals("watch name incorrect", "innerMethodFoo", watches.get(3).getName()); 549 assertEquals("watch name incorrect", "asdf", watches.get(4).getName()); 550 assertEquals("watch name incorrect", "nullString", watches.get(5).getName()); 551 assertEquals("watch value incorrect", "7", watches.get(0).getValue()); 552 assertEquals("watch value incorrect", "9", watches.get(1).getValue()); 553 assertEquals("watch value incorrect", "11", watches.get(2).getValue()); 554 assertEquals("watch value incorrect", "13", watches.get(3).getValue()); 555 assertEquals("watch value incorrect", DebugWatchData.NO_VALUE, watches.get(4).getValue()); 556 assertEquals("watch value incorrect", "null", watches.get(5).getValue()); 557 assertEquals("watch type incorrect", "java.lang.String", watches.get(5).getType()); 558 559 561 synchronized(_notifierLock) { 563 _setPendingNotifies(2); _asyncStep(Debugger.STEP_INTO); 565 while (_pendingNotifies > 0) _notifierLock.wait(); 566 } 567 debugListener.assertStepRequestedCount(6); debugListener.assertCurrThreadResumedCount(6); debugListener.assertThreadLocationUpdatedCount(7); debugListener.assertCurrThreadSuspendedCount(7); debugListener.assertBreakpointReachedCount(1); 572 debugListener.assertCurrThreadDiedCount(0); 573 574 watches = _debugger.getWatches(); 576 assertEquals("watch name incorrect", "foo", watches.get(0).getName()); 577 assertEquals("watch name incorrect", "innerFoo", watches.get(1).getName()); 578 assertEquals("watch name incorrect", "innerInnerFoo", watches.get(2).getName()); 579 assertEquals("watch name incorrect", "innerMethodFoo", watches.get(3).getName()); 580 assertEquals("watch name incorrect", "asdf", watches.get(4).getName()); 581 assertEquals("watch name incorrect", "nullString", watches.get(5).getName()); 582 assertEquals("watch value incorrect", "7", watches.get(0).getValue()); 583 assertEquals("watch value incorrect", DebugWatchData.NO_VALUE, watches.get(1).getValue()); 584 assertEquals("watch value incorrect", DebugWatchData.NO_VALUE, watches.get(2).getValue()); 585 assertEquals("watch value incorrect", DebugWatchData.NO_VALUE, watches.get(3).getValue()); 586 assertEquals("watch value incorrect", DebugWatchData.NO_VALUE, watches.get(4).getValue()); 587 assertEquals("watch value incorrect", DebugWatchData.NO_VALUE, watches.get(5).getValue()); 588 assertEquals("watch type incorrect", DebugWatchData.NO_TYPE, watches.get(5).getType()); 589 590 synchronized(_notifierLock) { 592 _setPendingNotifies(3); _asyncResume(); 594 while (_pendingNotifies > 0) _notifierLock.wait(); 595 } 596 debugListener.assertStepRequestedCount(6); debugListener.assertCurrThreadResumedCount(7); debugListener.assertThreadLocationUpdatedCount(8); debugListener.assertCurrThreadSuspendedCount(8); debugListener.assertBreakpointReachedCount(2); 601 debugListener.assertCurrThreadDiedCount(0); 602 603 watches = _debugger.getWatches(); 605 assertEquals("watch name incorrect", "localVar", watches.get(6).getName()); 606 assertEquals("watch value incorrect", "11", watches.get(6).getValue()); 607 608 _model.closeFile(doc); 610 Utilities.clearEventQueue(); 611 debugListener.assertRegionRemovedCount(2); 613 _shutdownAndWaitForInteractionEnded(); 615 _debugger.removeListener(debugListener); 616 } 617 618 622 public void testStaticWatches() throws Exception { 623 _log.log("----testStaticWatches----"); 624 StepTestListener debugListener = new StepTestListener(); 625 _debugger.addListener(debugListener); 626 627 OpenDefinitionsDocument doc = _startupDebugger("MonkeyStaticStuff.java", MONKEY_STATIC_STUFF); 629 630 int index = MONKEY_STATIC_STUFF.indexOf("System.out.println(MonkeyInner.MonkeyTwoDeep.twoDeepFoo);"); 632 _debugger.toggleBreakpoint(doc, index, 14, true); 633 634 Utilities.clearEventQueue(); 635 debugListener.assertRegionAddedCount(1); 636 637 synchronized(_notifierLock) { 639 _setPendingNotifies(3); interpretIgnoreResult("MonkeyStaticStuff.MonkeyInner.MonkeyTwoDeep.MonkeyThreeDeep.threeDeepMethod();"); 641 while (_pendingNotifies > 0) _notifierLock.wait(); 642 } 643 644 _debugger.addWatch("foo"); 645 _debugger.addWatch("innerFoo"); 646 _debugger.addWatch("twoDeepFoo"); 647 _debugger.addWatch("threeDeepFoo"); 648 _debugger.addWatch("asdf"); 649 Utilities.clearEventQueue(); 650 debugListener.assertWatchSetCount(5); 651 652 Vector <DebugWatchData> watches = _debugger.getWatches(); 653 assertEquals("watch name incorrect", "foo", watches.get(0).getName()); 654 assertEquals("watch name incorrect", "innerFoo", watches.get(1).getName()); 655 assertEquals("watch name incorrect", "twoDeepFoo", watches.get(2).getName()); 656 assertEquals("watch name incorrect", "threeDeepFoo", watches.get(3).getName()); 657 assertEquals("watch name incorrect", "asdf", watches.get(4).getName()); 658 assertEquals("watch value incorrect", "6", watches.get(0).getValue()); 659 assertEquals("watch value incorrect", "8", watches.get(1).getValue()); 660 assertEquals("watch value incorrect", "13", watches.get(2).getValue()); 661 assertEquals("watch value incorrect", "18", watches.get(3).getValue()); 662 assertEquals("watch value incorrect", DebugWatchData.NO_VALUE, watches.get(4).getValue()); 663 664 interpret("innerFoo = 0"); 665 watches = _debugger.getWatches(); 666 assertEquals("watch name incorrect", "innerFoo", watches.get(1).getName()); 667 assertEquals("watch value incorrect", "0", watches.get(1).getValue()); 668 669 interpret("innerFoo = 8"); 670 assertEquals("watch name incorrect", "innerFoo", watches.get(1).getName()); 671 assertEquals("watch value incorrect", "8", watches.get(1).getValue()); 672 673 _shutdownAndWaitForInteractionEnded(); 675 _debugger.removeListener(debugListener); 676 } 677 678 682 public void testWatchLocalVarsFromInnerClass() throws Exception { 683 _log.log("----testWatchLocalVarsFromInnerClass----"); 684 StepTestListener debugListener = new StepTestListener(); 685 _debugger.addListener(debugListener); 686 687 OpenDefinitionsDocument doc = _startupDebugger("InnerClassWithLocalVariables.java", INNER_CLASS_WITH_LOCAL_VARS); 689 690 int index = INNER_CLASS_WITH_LOCAL_VARS.indexOf("numArgs:"); 692 _debugger.toggleBreakpoint(doc, index, 7, true); 693 694 Utilities.clearEventQueue(); 695 debugListener.assertRegionAddedCount(1); 696 697 synchronized(_notifierLock) { 699 _setPendingNotifies(3); interpretIgnoreResult("java InnerClassWithLocalVariables arg"); 701 while (_pendingNotifies > 0) _notifierLock.wait(); 702 } 703 _debugger.addWatch("numArgs"); 704 _debugger.addWatch("args"); 705 _debugger.addWatch("inlined"); 706 Utilities.clearEventQueue(); 707 debugListener.assertWatchSetCount(3); 708 709 Vector <DebugWatchData> watches = _debugger.getWatches(); 711 assertEquals("numArgs watch value incorrect", "1", watches.get(0).getValue()); 712 String argsWatch = watches.get(1).getValue(); 713 assertTrue("args watch value incorrect", argsWatch.indexOf("java.lang.String") != -1); 714 715 assertEquals("watch value incorrect", DebugWatchData.NO_VALUE, watches.get(2).getValue()); 717 718 _shutdownAndWaitForInteractionEnded(); 720 _debugger.removeListener(debugListener); 721 } 722 723 727 public void testThreadShouldDie() throws Exception { 728 _log.log("----testThreadShouldDie----"); 729 StepTestListener debugListener = new StepTestListener(); 730 _debugger.addListener(debugListener); 731 732 OpenDefinitionsDocument doc = _startupDebugger("DrJavaThreadDeathTest.java", THREAD_DEATH_CLASS); 734 735 interpret("Jones.threadShouldDie()"); 738 739 _shutdownWithoutSuspendedInteraction(); 741 _debugger.removeListener(debugListener); 742 } 743 } 744 | Popular Tags |