com.google.testing.threadtester
Interface Breakpoint

All Known Subinterfaces:
ReusableBreakpoint
All Known Implementing Classes:
AbstractBreakpoint, SinglePositionBreakpoint

public interface Breakpoint

Represents a request for execution to block at a particular position. Breakpoints are normally obtained by calling ObjectInstrumentation.createBreakpoint(CodePosition, Thread), but other classes may also implement the Breakpoint interface. A Breakpoint is a single-shot object. Once execution blocks at a particular Breakpoint, it will not block again when that position is reached a second time. A new Breakpoint must be created.

Author:
alasdair.mackintosh@gmail.com (Alasdair Mackintosh)

Method Summary
 void await()
          Waits for this breakpoint to be reached.
 void disable()
          Disables the Breakpoint.
 void enable()
          Enables the Breakpoint.
 int getLimit()
          Gets the limit.
 Thread getThread()
          Gets the thread associated with this Breakpoint, if any.
 boolean isBlocked()
          Returns true if the associated thread is currently blocked at this breakpoint.
 boolean isEnabled()
          Returns true if this breakpoint is enabled.
 void resume()
          Tells the blocked thread to continue.
 void resume(Breakpoint nextBreak)
          Tells the blocked thread to continue, and then wait for the given breakpoint.
 void setHandler(BreakpointHandler handler)
          Sets a handler for this Breakpoint.
 void setLimit(int limit)
          Sets the limit.
 

Method Detail

getThread

Thread getThread()
Gets the thread associated with this Breakpoint, if any. Some Breakpoints may only be valid for a given thread, and will not block when reached by another thread. Consult the documentation for the specific Breakpoint type for details. If this Breakpoint is not associated with a thread, returns null.


setHandler

void setHandler(BreakpointHandler handler)
Sets a handler for this Breakpoint. If a handler is set, then when the breakpoint is reached it will invoke the handler's BreakpointHandler.handleBreakpoint(com.google.testing.threadtester.Breakpoint) method.


setLimit

void setLimit(int limit)
Sets the limit. This determines how many times the breakpoint must be hit before it will stop. The default limit is 1, meaning that the breakpoint will stop as soon as it is reached. Setting the limit to N will mean that the breakpoint will not stop the first N-1 times it is reached.

Note that once a breakpoint has stopped, it is no longer active, and will not stop again.

Throws:
IllegalArgumentException - if limit < 1
IllegalStateException - if this breakpoint has already been reached.

getLimit

int getLimit()
Gets the limit. This is the initial limit value that was set in the call to setLimit(int).


isEnabled

boolean isEnabled()
Returns true if this breakpoint is enabled. By default, a Breakpoint is active when it is created, but can be deactivated by disable(). A Breakpoint's thread will only stop if the Breakpoint is enabled.


disable

void disable()
Disables the Breakpoint. If a breakpoint is not enabled, then its thread will not stop when the breakpoint is reached.


enable

void enable()
Enables the Breakpoint. If a breakpoint is enabled, then its thread will stop when the breakpoint is reached. Breakpoints are enabled when created, but may be disabled by a call to disable().


isBlocked

boolean isBlocked()
Returns true if the associated thread is currently blocked at this breakpoint.


await

void await()
           throws TestTimeoutException
Waits for this breakpoint to be reached. The caller thread will block until the breakpoint is reached. If the executing thread is already stopped at this breakpoint, then this method will return immediately.

It is the caller's responsibility to ensure that this breakpoint is reachable in the current environment. Waiting for a breakpoint that is not reached will eventually throw a TestTimeoutException.

Throws:
IllegalStateException - if this breakpoint is not currently active
TestTimeoutException - if this breakpoint is not reached within the time limit defined by Options.timeout. The thread of the timeout exception will be set to the thread of this breakpoint, not to the thread that called await.

resume

void resume()
Tells the blocked thread to continue. This method can only be called after await() has been successfully called.

Throws:
IllegalStateException - if await has not been called.

resume

void resume(Breakpoint nextBreak)
            throws TestTimeoutException
Tells the blocked thread to continue, and then wait for the given breakpoint. This is a shorthand for:
   breakPoint.resume();
   nextBreak.await();
 

Throws:
TestTimeoutException


Copyright © 2013. All Rights Reserved.