Package generic.test
Class ConcurrentTestExceptionHandler
java.lang.Object
generic.test.ConcurrentTestExceptionHandler
- All Implemented Interfaces:
Thread.UncaughtExceptionHandler
public class ConcurrentTestExceptionHandler
extends Object
implements Thread.UncaughtExceptionHandler
A class which handles exceptions that occur off of the main test thread. Exceptions can be
reported to this class, which will later be checked by
AbstractGenericTest.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclear()Clears all exceptions being tracked by this classstatic voiddisable()Disables this class's tracking of exceptions.static voidenable()Enables this class after a call todisable()has been madestatic List<TestExceptionTracker> Returns all exceptions tracked by this classstatic voidTells this class to process the given throwablestatic booleanReturns true if this class has been given any exceptions to handle since last being clearedstatic booleanReturns true if this class is enabled.static voidInstalls this exception handler as the default uncaught exception handler.voiduncaughtException(Thread thread, Throwable t)
-
Constructor Details
-
ConcurrentTestExceptionHandler
public ConcurrentTestExceptionHandler()
-
-
Method Details
-
registerHandler
public static void registerHandler()Installs this exception handler as the default uncaught exception handler. SeeThread.setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler) -
handle
Tells this class to process the given throwable- Parameters:
thread- the thread that encountered the throwablet- the throwable
-
clear
public static void clear()Clears all exceptions being tracked by this class -
enable
public static void enable()Enables this class after a call todisable()has been made -
disable
public static void disable()Disables this class's tracking of exceptions. Clients use this method to have this class ignore expected exceptions. This is a bit course-grained, as it does not allow clients to ignore specific expected exceptions. -
isEnabled
public static boolean isEnabled()Returns true if this class is enabled. When disabled this class does not track exceptions.- Returns:
- true if enabled
-
getExceptions
Returns all exceptions tracked by this class- Returns:
- all exceptions tracked by this class
-
hasException
public static boolean hasException()Returns true if this class has been given any exceptions to handle since last being cleared- Returns:
- true if this class has been given any exceptions to handle since last being cleared
-
uncaughtException
- Specified by:
uncaughtExceptionin interfaceThread.UncaughtExceptionHandler
-