Skip to content

Commit

Permalink
Conditional breakpoint in java.io.File class fix + code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SougandhS committed Sep 24, 2024
1 parent 75a851a commit 71a83de
Show file tree
Hide file tree
Showing 6 changed files with 205 additions and 199 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*******************************************************************************
* Copyright (c) 2024 IBM Corporation.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import java.io.File;

public class FileConditionSnippet2 {
public static void main(String[] ecs) {
int i = 0;
File parent = new File("parent");
File file = new File(parent,"test");
System.out.println("COMPLETED");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ public abstract class AbstractDebugTest extends TestCase implements IEvaluation
public static final String BOUND_JRE_PROJECT_NAME = "BoundJRE";
public static final String CLONE_SUFFIX = "Clone";

final String[] LAUNCH_CONFIG_NAMES_1_4 = {"LargeSourceFile", "LotsOfFields", "Breakpoints", "InstanceVariablesTests", "LocalVariablesTests", "LocalVariableTests2", "StaticVariablesTests",
final String[] LAUNCH_CONFIG_NAMES_1_4 = { "LargeSourceFile", "LotsOfFields",
"Breakpoints",
"InstanceVariablesTests",
"LocalVariablesTests", "LocalVariableTests2", "StaticVariablesTests",
"DropTests", "ThrowsNPE", "ThrowsException", "org.eclipse.debug.tests.targets.Watchpoint",
"org.eclipse.debug.tests.targets.BreakpointsLocationBug344984", "org.eclipse.debug.tests.targets.CallLoop", "A",
"HitCountLooper", "CompileError", "MultiThreadedLoop", "HitCountException", "MultiThreadedException", "MultiThreadedList", "MethodLoop", "StepFilterOne",
Expand All @@ -201,7 +204,7 @@ public abstract class AbstractDebugTest extends TestCase implements IEvaluation
"StepResult2", "StepResult3", "StepUncaught", "TriggerPoint_01", "BulkThreadCreationTest", "MethodExitAndException",
"Bug534319earlyStart", "Bug534319lateStart", "Bug534319singleThread", "Bug534319startBetwen", "MethodCall", "Bug538303", "Bug540243",
"OutSync", "OutSync2", "ConsoleOutputUmlaut", "ErrorRecurrence", "ModelPresentationTests", "Bug565982",
"SuspendVMConditionalBreakpointsTestSnippet" };
"SuspendVMConditionalBreakpointsTestSnippet", "FileConditionSnippet2" };

/**
* the default timeout
Expand Down Expand Up @@ -1553,7 +1556,6 @@ protected IJavaThread launchToLineBreakpoint(ILaunchConfiguration config, ILineB
int lineNumber = breakpoint.getLineNumber();
int stackLine = thread.getTopStackFrame().getLineNumber();
assertEquals("line numbers of breakpoint and stack frame do not match", lineNumber, stackLine); //$NON-NLS-1$

return thread;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.eclipse.jdt.debug.tests.breakpoints.BreakpointWorkingSetTests;
import org.eclipse.jdt.debug.tests.breakpoints.ConditionalBreakpointsInJava8Tests;
import org.eclipse.jdt.debug.tests.breakpoints.ConditionalBreakpointsTests;
import org.eclipse.jdt.debug.tests.breakpoints.ConditionalBreakpointsWithFileClass;
import org.eclipse.jdt.debug.tests.breakpoints.ConditionalBreakpointsWithGenerics;
import org.eclipse.jdt.debug.tests.breakpoints.DeferredBreakpointTests;
import org.eclipse.jdt.debug.tests.breakpoints.ExceptionBreakpointTests;
Expand Down Expand Up @@ -394,6 +395,7 @@ public AutomatedSuite() {
addTest(new TestSuite(TestToggleBreakpointsTarget.class));
addTest(new TestSuite(TriggerPointBreakpointsTests.class));
addTest(new TestSuite(JavaThreadEventHandlerTests.class));
addTest(new TestSuite(ConditionalBreakpointsWithFileClass.class));

if (JavaProjectHelper.isJava8Compatible()) {
addTest(new TestSuite(TestToggleBreakpointsTarget8.class));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*******************************************************************************
* Copyright (c) 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation -- initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.debug.tests.breakpoints;

import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
import org.eclipse.jdt.debug.core.IJavaThread;
import org.eclipse.jdt.debug.tests.AbstractDebugTest;

public class ConditionalBreakpointsWithFileClass extends AbstractDebugTest {


public ConditionalBreakpointsWithFileClass(String name) {
super(name);
}

@Override
protected IJavaProject getProjectContext() {
return get14Project();
}

public void testFileConditionalBreakpointforFalse() throws Exception {
String typeName = "FileConditionSnippet2";
IJavaLineBreakpoint bp3 = createLineBreakpoint(20, typeName);
IJavaLineBreakpoint bp2 = createConditionalLineBreakpoint(364, "java.io.File", "false", true);
IJavaThread mainThread = null;
try {
Thread.sleep(10);
mainThread = launchToBreakpoint(typeName);
int hitLine = 0;
assertTrue("Thread should be suspended", mainThread.isSuspended());
hitLine = mainThread.getStackFrames()[0].getLineNumber();
assertEquals("Didn't suspend at the expected line", 20, hitLine);

bp2.delete();
bp3.delete();
} finally {
terminateAndRemove(mainThread);
removeAllBreakpoints();
}
}

public void testFileConditionalBreakpointforTrue() throws Exception {
String typeName = "FileConditionSnippet2";
IJavaLineBreakpoint bp3 = createLineBreakpoint(20, typeName);
IJavaThread mainThread = null;

try {
Thread.sleep(10);
mainThread = launchToBreakpoint(typeName);
mainThread.getTopStackFrame().stepInto();
IJavaLineBreakpoint bp2 = createConditionalLineBreakpoint(364, "java.io.File", "true", true);
int hitLine = 0;
mainThread.resume();
Thread.sleep(1000);
assertTrue("Thread should be suspended", mainThread.isSuspended());
hitLine = mainThread.getStackFrames()[0].getLineNumber();
assertEquals("Didn't suspend at the expected line", 364, hitLine);

bp2.delete();
bp3.delete();
} finally {
terminateAndRemove(mainThread);
removeAllBreakpoints();
}
}

}
Loading

0 comments on commit 71a83de

Please sign in to comment.