Class FakePeriodicRunner

    • Field Detail

      • started

        public boolean started
    • Constructor Detail

      • FakePeriodicRunner

        public FakePeriodicRunner()
    • Method Detail

      • setPeriodicTask

        public void setPeriodicTask​(Runnable task)
        Description copied from interface: PeriodicRunner
        Specify the task that this PeriodicRunner should run periodically. The specified task will not be run until after the PeriodicRunner.start() method has been called.
        Specified by:
        setPeriodicTask in interface PeriodicRunner
        Parameters:
        task - The task to run periodically.
      • start

        public void start()
        Set an internal flag saying that this runner is in the started state.
        Specified by:
        start in interface PeriodicRunner
        Throws:
        IllegalStateException - if no task has been provided.
      • stop

        public void stop()
        Set an internal flag saying that this runner is not in the started state.
        Specified by:
        stop in interface PeriodicRunner
        Throws:
        IllegalStateException - if the task is already not in the started state.
      • runOnce

        public void runOnce()
        Simulate the periodic timer firing and running the Runnable task. This will invoke the specified task once.

        This will also verify that this runner is in the started state: that is, that the start() method has been called more recently than the last call to stop(), if any.

        Throws:
        IllegalStateException - if this runner is not in the started state.