Skip to content

Commit b9241b9

Browse files
Added Unit test
1 parent 0d0d691 commit b9241b9

2 files changed

Lines changed: 74 additions & 0 deletions

File tree

org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AutomatedSuite.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.eclipse.jdt.debug.tests.breakpoints.ConditionalBreakpointsWithFileClass;
3030
import org.eclipse.jdt.debug.tests.breakpoints.ConditionalBreakpointsWithGenerics;
3131
import org.eclipse.jdt.debug.tests.breakpoints.DeferredBreakpointTests;
32+
import org.eclipse.jdt.debug.tests.breakpoints.DisableOnHitTest;
3233
import org.eclipse.jdt.debug.tests.breakpoints.ExceptionBreakpointTests;
3334
import org.eclipse.jdt.debug.tests.breakpoints.HitCountBreakpointsTests;
3435
import org.eclipse.jdt.debug.tests.breakpoints.ImportBreakpointsTest;
@@ -399,6 +400,7 @@ public AutomatedSuite() {
399400
addTest(new TestSuite(JavaThreadEventHandlerTests.class));
400401
addTest(new TestSuite(ConditionalBreakpointsWithFileClass.class));
401402
addTest(new TestSuite(CompareObjectsTest.class));
403+
addTest(new TestSuite(DisableOnHitTest.class));
402404

403405
if (JavaProjectHelper.isJava8Compatible()) {
404406
addTest(new TestSuite(TestToggleBreakpointsTarget8.class));
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 IBM Corporation and others.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* IBM Corporation - initial API and implementation
13+
*******************************************************************************/
14+
package org.eclipse.jdt.debug.tests.breakpoints;
15+
16+
import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
17+
import org.eclipse.jdt.debug.core.IJavaThread;
18+
import org.eclipse.jdt.debug.tests.AbstractDebugTest;
19+
20+
/**
21+
* Tests for disable on hit breakpoints.
22+
*/
23+
24+
public class DisableOnHitTest extends AbstractDebugTest {
25+
26+
/**
27+
* Constructor
28+
*
29+
* @param name
30+
* the name of the test
31+
*/
32+
public DisableOnHitTest(String name) {
33+
super(name);
34+
}
35+
36+
public void testBreakpointHitWith() throws Exception {
37+
String typeName = "TriggerPoint_01";
38+
IJavaLineBreakpoint bp1 = createLineBreakpoint(19, typeName);
39+
IJavaLineBreakpoint bp2 = createLineBreakpoint(20, typeName);
40+
bp1.setDisableOnHit(true);
41+
IJavaThread thread = null;
42+
try {
43+
thread = launchToBreakpoint(typeName);
44+
thread.resume();
45+
boolean isBp1Disabled = bp1.isEnabled();
46+
assertFalse("Breakpoint should be disabled after hit", isBp1Disabled);
47+
bp1.delete();
48+
bp2.delete();
49+
} finally {
50+
terminateAndRemove(thread);
51+
removeAllBreakpoints();
52+
}
53+
}
54+
55+
public void testBreakpointHitWithout() throws Exception {
56+
String typeName = "TriggerPoint_01";
57+
IJavaLineBreakpoint bp1 = createLineBreakpoint(19, typeName);
58+
IJavaLineBreakpoint bp2 = createLineBreakpoint(20, typeName);
59+
IJavaThread thread = null;
60+
try {
61+
thread = launchToBreakpoint(typeName);
62+
thread.resume();
63+
boolean isBp1Disabled = bp1.isEnabled();
64+
assertTrue("Breakpoint should be not be disabled after hit", isBp1Disabled);
65+
bp1.delete();
66+
bp2.delete();
67+
} finally {
68+
terminateAndRemove(thread);
69+
removeAllBreakpoints();
70+
}
71+
}
72+
}

0 commit comments

Comments
 (0)