|
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.hidden;
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.Debugger;
import org.netbeans.modules.debugger.CoreBreakpoint;
import org.netbeans.modules.debugger.jpda.ThreadBreakpoint;
import org.netbeans.modules.debugger.delegator.DelegatingDebugger;
/**
* Tests hidden thread breakpoints.
*
* @author Jan Stola
*/
public class HiddenThreadBreakpointCommon2 extends junit.framework.TestCase {
public HiddenThreadBreakpointCommon2(String name) {
super(name);
}
/**
* Tests hidden 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) {
String className="breakpoints.disabled.DisabledThreadBreakpointClass";
CoreBreakpoint temp=(CoreBreakpoint)DebuggerOpenAPI.addLineBreakpoint(className, 25);
assertNotNull(Common.addBug, temp);
assertNotNull(Common.addFindBug, DebuggerOpenAPI.findLineBreakpoint (className, 25));
assertNotNull(Common.addBug, DebuggerOpenAPI.addLineBreakpoint(className, 36));
assertNotNull(Common.addFindBug, DebuggerOpenAPI.findLineBreakpoint (className, 36));
assertNotNull(Common.addBug, DebuggerOpenAPI.addLineBreakpoint(className, 38));
assertNotNull(Common.addFindBug, DebuggerOpenAPI.findLineBreakpoint (className, 38));
assertNotNull(Common.addBug, DebuggerOpenAPI.addLineBreakpoint(className, 40));
assertNotNull(Common.addFindBug, DebuggerOpenAPI.findLineBreakpoint (className, 40));
boolean ok=DebuggerAPI.start(debuggerType, className, new String[0], false);
assertTrue(Common.startBug+Common.error, ok);
Debugger d=((DelegatingDebugger)DebuggerOpenAPI.getDebugger()).getCurrentDebugger();
assertNotNull(Common.error, d);
CoreBreakpoint b=(CoreBreakpoint)DebuggerAPI.addThreadBreakpoint(ThreadBreakpoint.TYPE_START);
assertNotNull(Common.addBug, b);
assertNotNull(Common.addFindBug, DebuggerAPI.findThreadBreakpoint (ThreadBreakpoint.TYPE_START));
b.setHidden(true);
assertNotNull(Common.addFindBug, DebuggerAPI.findThreadBreakpoint (ThreadBreakpoint.TYPE_START));
int threads=0;
String name;
do {
name=((ThreadBreakpoint)b.getEvent(d)).getThread().getName();
if ((name!=null) && (name.startsWith("XXX"))) {
threads++;
}
} while (DebuggerOpenAPI.go()&&(threads!=1));
b.setHidden(false);
assertNotNull(Common.addFindBug, DebuggerAPI.findThreadBreakpoint (ThreadBreakpoint.TYPE_START));
threads=0;
do {
name=((ThreadBreakpoint)b.getEvent(d)).getThread().getName();
if ((name!=null) && (name.startsWith("XXX"))) {
threads++;
}
} while (DebuggerOpenAPI.go()&&(threads!=1));
b.setHidden(true);
assertNotNull(Common.addFindBug, DebuggerAPI.findThreadBreakpoint (ThreadBreakpoint.TYPE_START));
threads=0;
StringBuffer names=new StringBuffer();
do {
name=((ThreadBreakpoint)b.getEvent(d)).getThread().getName();
if ((name!=null) && (name.startsWith("XXX"))) {
names.append(name).append(' ');
threads++;
}
} while (DebuggerOpenAPI.go());
Common.closeEditor(className);
assertEquals("Debugger should stop only once, it stopped "+threads+", on threads "+names.toString(), 1, threads);
}
}
|