blob: b90f2c976b81515b9172ae0badb8816be9e4b412 [file] [log] [blame]
package org.eclipse.jdt.debug.tests.core;
/**********************************************************************
Copyright (c) 2000, 2002 IBM Corp. and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Common Public License v0.5
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/cpl-v05.html
Contributors:
IBM Corporation - Initial implementation
*********************************************************************/
import org.eclipse.debug.core.model.IVariable;
import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
import org.eclipse.jdt.debug.core.IJavaPrimitiveValue;
import org.eclipse.jdt.debug.core.IJavaStackFrame;
import org.eclipse.jdt.debug.core.IJavaThread;
import org.eclipse.jdt.debug.tests.AbstractDebugTest;
/**
* Tests hit count breakpoints
*/
public class HitCountBreakpointsTests extends AbstractDebugTest {
public HitCountBreakpointsTests(String name) {
super(name);
}
public void testResetHitCountBreakpoint() throws Exception {
String typeName = "HitCountLooper";
IJavaLineBreakpoint bp = createLineBreakpoint(16, typeName);
bp.setHitCount(3);
IJavaThread thread= null;
try {
thread= launchToLineBreakpoint(typeName, bp);
IJavaStackFrame frame = (IJavaStackFrame)thread.getTopStackFrame();
IVariable var = frame.findVariable("i");
assertNotNull("Could not find variable 'i'", var);
IJavaPrimitiveValue value = (IJavaPrimitiveValue)var.getValue();
assertNotNull("variable 'i' has no value", value);
int iValue = value.getIntValue();
assertTrue("value of 'i' should be '2', but was " + iValue, iValue == 2);
bp.setHitCount(2);
IJavaThread thread2 = resumeToLineBreakpoint(thread, bp);
assertTrue("second suspended thread not the same as first", thread == thread2);
frame = (IJavaStackFrame)thread2.getTopStackFrame();
var = frame.findVariable("i");
value = (IJavaPrimitiveValue)var.getValue();
assertNotNull("variable 'i' has no value", value);
iValue = value.getIntValue();
assertTrue("value of 'i' should be '4', but was " + iValue, iValue == 4);
resumeAndExit(thread2);
bp.delete();
} finally {
terminateAndRemove(thread);
removeAllBreakpoints();
}
}
public void testExpiredHitCountBreakpoint() throws Exception {
String typeName = "HitCountLooper";
IJavaLineBreakpoint bp = createLineBreakpoint(16, typeName);
bp.setHitCount(3);
IJavaThread thread= null;
try {
thread= launchToLineBreakpoint(typeName, bp);
IJavaStackFrame frame = (IJavaStackFrame)thread.getTopStackFrame();
IVariable var = frame.findVariable("i");
assertNotNull("Could not find variable 'i'", var);
IJavaPrimitiveValue value = (IJavaPrimitiveValue)var.getValue();
assertNotNull("variable 'i' has no value", value);
int iValue = value.getIntValue();
assertTrue("value of 'i' should be '2', but was " + iValue, iValue == 2);
resumeAndExit(thread);
bp.delete();
} finally {
terminateAndRemove(thread);
removeAllBreakpoints();
}
}
}