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 Details

    • ConcurrentTestExceptionHandler

      public ConcurrentTestExceptionHandler()
  • Method Details

    • registerHandler

      public static void registerHandler()
      Installs this exception handler as the default uncaught exception handler. See Thread.setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler)
    • handle

      public static void handle(Thread thread, Throwable t)
      Tells this class to process the given throwable
      Parameters:
      thread - the thread that encountered the throwable
      t - 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 to disable() 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

      public static List<TestExceptionTracker> 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

      public void uncaughtException(Thread thread, Throwable t)
      Specified by:
      uncaughtException in interface Thread.UncaughtExceptionHandler