コード例 #1
0
  /**
   * tests that breakpoint suspends on uncaught exceptions
   *
   * @throws Exception
   */
  public void testUncaughtException() throws Exception {
    String typeName = "HitCountException";
    IJavaExceptionBreakpoint ex =
        createExceptionBreakpoint("java.lang.NullPointerException", false, true);

    IJavaThread thread = null;
    try {
      thread = launchToBreakpoint(typeName);
      assertNotNull("Breakpoint not hit within timeout period", thread);

      IBreakpoint hit = getBreakpoint(thread);
      assertNotNull("suspended, but not by breakpoint", hit);
      assertEquals("suspended, but not by exception breakpoint", ex, hit);
      IJavaStackFrame frame = (IJavaStackFrame) thread.getTopStackFrame();
      assertTrue(
          "Should have been suspended at line number 35, not " + frame.getLineNumber(),
          frame.getLineNumber() == 35);
      ex.delete();
    } finally {
      terminateAndRemove(thread);
      removeAllBreakpoints();
    }
  }
コード例 #2
0
  /**
   * tests the hit count of an exception breakpoint
   *
   * @throws Exception
   */
  public void testHitCountException() throws Exception {
    String typeName = "HitCountException";
    IJavaExceptionBreakpoint ex =
        createExceptionBreakpoint("java.lang.NullPointerException", true, true);
    ex.setHitCount(2);

    IJavaThread thread = null;
    try {
      thread = launchToBreakpoint(typeName);
      IJavaStackFrame frame = (IJavaStackFrame) thread.getTopStackFrame();
      assertEquals("Should have been suspended at linenumber", 35, frame.getLineNumber());

      ex.delete();
    } finally {
      terminateAndRemove(thread);
      removeAllBreakpoints();
    }
  }