|
What this is
This file is included in the DevDaily.com
"Java Source Code
Warehouse" project. The intent of this project is to help you "Learn
Java by Example" TM.
Other links
The source code
/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is NetBeans. The Initial Developer of the Original
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun
* Microsystems, Inc. All Rights Reserved.
*/
package org.netbeans.test.debugger.breakpoints.thread;
import org.netbeans.test.debugger.Util.Common;
import org.netbeans.test.debugger.Util.DebuggerAPI;
import org.netbeans.test.debugger.Util.DebuggerOpenAPI;
import org.openide.debugger.DebuggerException;
import org.netbeans.modules.debugger.CoreBreakpoint;
import org.netbeans.modules.debugger.delegator.DelegatingDebugger;
import org.netbeans.modules.debugger.jpda.ThreadBreakpoint;
/**
* Tests change of Set on property of thread breakpoints.
*
* @author Jan Stola
*/
public class CoreThreadBreakpointTypeChangeCommon extends junit.framework.TestCase {
public CoreThreadBreakpointTypeChangeCommon(String name) {
super(name);
}
/**
* Tests change of Set on property of thread breakpoints
* using given debuggerType .
*
* @param debuggerType type of the debugger to be used.
* @return value indicating whether the test was successful.
*/
public void test(String debuggerType) {
DelegatingDebugger d=(DelegatingDebugger)DebuggerOpenAPI.getDebugger();
assertNotNull(Common.error, d);
String className="breakpoints.thread.CoreThreadBreakpointClass";
CoreBreakpoint c=(CoreBreakpoint)DebuggerAPI.addThreadBreakpoint(ThreadBreakpoint.TYPE_START);
assertNotNull(Common.addBug, c);
assertNotNull(Common.addFindBug, DebuggerAPI.findThreadBreakpoint(ThreadBreakpoint.TYPE_START));
boolean ok=DebuggerAPI.start(debuggerType, className, new String[0], false);
assertTrue(Common.startBug+Common.error, ok);
String name;
int threads=0;
do {
name=((ThreadBreakpoint)c.getEvent(d.getCurrentDebugger())).getThread().getName();
if ((name!=null) && (name.startsWith("XYZ3"))) {
threads++;
}
} while ((threads!=1)&&DebuggerOpenAPI.go());
assertEquals(Common.stopBug, threads, 1);
((ThreadBreakpoint)c.getEvent(d)).setType(ThreadBreakpoint.TYPE_DEATH);
threads=0;
StringBuffer names=new StringBuffer();
while (DebuggerOpenAPI.go()) {
name=((ThreadBreakpoint)c.getEvent(d.getCurrentDebugger())).getThread().getName();
if ((name!=null) && (name.startsWith("XYZ3"))) {
names.append(name).append(' ');
threads++;
}
}
assertEquals("Debugger didn't stop only once. It stopped on threads "+names.toString(), 1, threads);
}
}
|