FakeScheduledExecutorService


class FakeScheduledExecutorService : AbstractExecutorService, ScheduledExecutorService, AutoCloseable


Fake implementation of ScheduledExecutorService that lets tests control when tasks are executed.

Summary

Public constructors

Public functions

Boolean
awaitTermination(timeout: Long, unit: TimeUnit?)
Unit
Unit
execute(command: Runnable?)
Boolean

Returns true if the execute queue contains at least one runnable.

Boolean

Returns whether any runnable is in the execute or schedule queue.

Boolean
Boolean
Unit

Runs all of the runnables that execute enqueued.

Unit

Runs the next runnable in the execute queue.

ScheduledFuture<V!>
<V> schedule(callable: Callable<V!>?, delay: Long, unit: TimeUnit?)
ScheduledFuture<Any!>
schedule(command: Runnable?, delay: Long, unit: TimeUnit?)
ScheduledFuture<Any!>
scheduleAtFixedRate(
    command: Runnable?,
    initialDelay: Long,
    period: Long,
    unit: TimeUnit?
)
ScheduledFuture<Any!>
scheduleWithFixedDelay(
    command: Runnable?,
    initialDelay: Long,
    delay: Long,
    unit: TimeUnit?
)
Unit
(Mutable)List<Runnable!>
Unit

Executes tasks from the schedule queue until the given amount of simulated time has passed.

Boolean

Simulates sleeping as long as necessary before executing the next scheduled task.

Boolean

Simulates sleeping up to the given timeout before executing the next scheduled task, if any.

Inherited functions

From java.util.concurrent.AbstractExecutorService
(Mutable)List<Future<T!>!>!
<T> invokeAll(tasks: (Mutable)Collection<Callable<T!>!>!)
T!
<T> invokeAny(tasks: (Mutable)Collection<Callable<T!>!>!)
RunnableFuture<T!>!
<T> newTaskFor(runnable: Runnable!, value: T!)
Future<Any!>!
submit(task: Runnable!)
Future<T!>!
<T> submit(task: Runnable!, result: T!)

Public constructors

FakeScheduledExecutorService

Added in 1.0.0-alpha01
FakeScheduledExecutorService()

Public functions

awaitTermination

Added in 1.0.0-alpha01
fun awaitTermination(timeout: Long, unit: TimeUnit?): Boolean

close

Added in 1.0.0-alpha01
fun close(): Unit

execute

Added in 1.0.0-alpha01
fun execute(command: Runnable?): Unit

hasNext

Added in 1.0.0-alpha01
fun hasNext(): Boolean

Returns true if the execute queue contains at least one runnable.

isEmpty

Added in 1.0.0-alpha01
@CheckReturnValue
fun isEmpty(): Boolean

Returns whether any runnable is in the execute or schedule queue.

isShutdown

Added in 1.0.0-alpha01
fun isShutdown(): Boolean

isTerminated

Added in 1.0.0-alpha01
fun isTerminated(): Boolean

runAll

Added in 1.0.0-alpha01
fun runAll(): Unit

Runs all of the runnables that execute enqueued.

runNext

Added in 1.0.0-alpha01
fun runNext(): Unit

Runs the next runnable in the execute queue.

schedule

Added in 1.0.0-alpha01
fun <V> schedule(callable: Callable<V!>?, delay: Long, unit: TimeUnit?): ScheduledFuture<V!>

schedule

Added in 1.0.0-alpha01
fun schedule(command: Runnable?, delay: Long, unit: TimeUnit?): ScheduledFuture<Any!>

scheduleAtFixedRate

Added in 1.0.0-alpha01
fun scheduleAtFixedRate(
    command: Runnable?,
    initialDelay: Long,
    period: Long,
    unit: TimeUnit?
): ScheduledFuture<Any!>

scheduleWithFixedDelay

Added in 1.0.0-alpha01
fun scheduleWithFixedDelay(
    command: Runnable?,
    initialDelay: Long,
    delay: Long,
    unit: TimeUnit?
): ScheduledFuture<Any!>

shutdown

Added in 1.0.0-alpha01
fun shutdown(): Unit

shutdownNow

Added in 1.0.0-alpha01
fun shutdownNow(): (Mutable)List<Runnable!>

simulateSleepExecutingAllTasks

Added in 1.0.0-alpha01
fun simulateSleepExecutingAllTasks(duration: Duration): Unit

Executes tasks from the schedule queue until the given amount of simulated time has passed.

simulateSleepExecutingAtMostOneTask

Added in 1.0.0-alpha01
fun simulateSleepExecutingAtMostOneTask(): Boolean

Simulates sleeping as long as necessary before executing the next scheduled task. Does nothing if the schedule queue is empty.

simulateSleepExecutingAtMostOneTask

Added in 1.0.0-alpha01
fun simulateSleepExecutingAtMostOneTask(duration: Duration): Boolean

Simulates sleeping up to the given timeout before executing the next scheduled task, if any.