Class ExecutionControlsInjector

java.lang.Object
org.apache.drill.exec.testing.ExecutionControlsInjector
All Implemented Interfaces:
ControlsInjector

public class ExecutionControlsInjector extends Object implements ControlsInjector
Injects exceptions and pauses at execution time for testing. Any class that wants to simulate exceptions or inject pauses for testing should have it's own private static instance of an injector (similar to the use of loggers). Injection site either use FragmentContextImpl or QueryContext. See ControlsInjector for documentation.
  • Constructor Details

  • Method Details

    • getSiteClass

      public Class<?> getSiteClass()
      Description copied from interface: ControlsInjector
      Get the injector's owning class.
      Specified by:
      getSiteClass in interface ControlsInjector
      Returns:
      the injector's owning class
    • injectUnchecked

      public void injectUnchecked(ExecutionControls executionControls, String desc)
      Description copied from interface: ControlsInjector
      Inject (throw) an unchecked exception at this point, if an injection is specified, and it is time for it to be thrown.

      Implementors use this in their code at a site where they want to simulate an exception during testing.

      Specified by:
      injectUnchecked in interface ControlsInjector
      Parameters:
      executionControls - the controls in the current context
      desc - the site descriptor throws the exception specified by the injection, if it is time
    • injectChecked

      public <T extends Throwable> void injectChecked(ExecutionControls executionControls, String desc, Class<T> exceptionClass) throws T
      Description copied from interface: ControlsInjector
      Inject (throw) a checked exception at this point, if an injection is specified, and it is time for it to be thrown.

      Implementors use this in their code at a site where they want to simulate an exception during testing.

      Specified by:
      injectChecked in interface ControlsInjector
      Parameters:
      executionControls - the controls in the current context
      desc - the site descriptor
      exceptionClass - the expected class of the exception (or a super class of it)
      Throws:
      T - the exception specified by the injection, if it is time
    • injectPause

      public void injectPause(ExecutionControls executionControls, String desc, org.slf4j.Logger logger)
      Description copied from interface: ControlsInjector
      Pauses at this point, if such an injection is specified (i.e. matches the site description).

      Implementors use this in their code at a site where they want to simulate a pause during testing.

      Specified by:
      injectPause in interface ControlsInjector
      Parameters:
      executionControls - the controls in the current context
      desc - the site descriptor
      logger - logger of the class containing the injection site
    • injectInterruptiblePause

      public void injectInterruptiblePause(ExecutionControls executionControls, String desc, org.slf4j.Logger logger) throws InterruptedException
      Description copied from interface: ControlsInjector
      Insert a pause that can be interrupted using Thread.interrupt() at the given site point, if such an injection is specified (i.e. matches the site description).

      Implementors use this in their code at a site where they want to simulate a interruptible pause during testing.

      Specified by:
      injectInterruptiblePause in interface ControlsInjector
      Parameters:
      executionControls - the controls in the current context
      desc - the site descriptor
      logger - logger of the class containing the injection site
      Throws:
      InterruptedException - if interrupted using Thread.interrupt()
    • getLatch

      public CountDownLatchInjection getLatch(ExecutionControls executionControls, String desc)
      Description copied from interface: ControlsInjector
      Used to insert a latch in site class. See CountDownLatchInjection and org.apache.drill.exec.testing.TestCountDownLatchInjection for usage.
      Specified by:
      getLatch in interface ControlsInjector
      Parameters:
      executionControls - the controls in the current context
      desc - the site descriptor