public final class ExecutionContextRule extends org.junit.rules.ExternalResource implements ExecutionContext
ExecutionContext
for your test case or suite.
Can be used with a @Rule
field and a static
field with @ClassRule
.
Constructor and Description |
---|
ExecutionContextRule(java.util.function.Supplier<BufferAllocator> allocatorSupplier,
java.util.function.Supplier<IoExecutor> ioExecutorSupplier,
java.util.function.Supplier<Executor> executorSupplier) |
ExecutionContextRule(java.util.function.Supplier<BufferAllocator> allocatorSupplier,
java.util.function.Supplier<IoExecutor> ioExecutorSupplier,
java.util.function.Supplier<Executor> executorSupplier,
java.util.function.Supplier<ExecutionStrategy> executionStrategySupplier) |
Modifier and Type | Method and Description |
---|---|
protected void |
after() |
protected void |
before() |
BufferAllocator |
bufferAllocator()
Return the
BufferAllocator that can be used to allocate Buffer s if needed. |
static ExecutionContextRule |
cached() |
static ExecutionContextRule |
cached(java.lang.String ioThreadPrefix,
java.lang.String executorThreadPrefix) |
static ExecutionContextRule |
cached(java.util.concurrent.ThreadFactory ioThreadFactory) |
ExecutionStrategy |
executionStrategy()
Returns the
ExecutionStrategy associated with this context. |
Executor |
executor()
Get the
Executor that is used to create any asynchronous sources. |
static ExecutionContextRule |
fixed(int size) |
static ExecutionContextRule |
fixed(int size,
java.util.concurrent.ThreadFactory ioThreadFactory) |
static ExecutionContextRule |
immediate() |
static ExecutionContextRule |
immediate(java.util.concurrent.ThreadFactory ioThreadFactory) |
IoExecutor |
ioExecutor()
Get the
IoExecutor that is used to handle the IO. |
static ExecutionContextRule |
single() |
static ExecutionContextRule |
single(java.util.concurrent.ThreadFactory ioThreadFactory) |
public ExecutionContextRule(java.util.function.Supplier<BufferAllocator> allocatorSupplier, java.util.function.Supplier<IoExecutor> ioExecutorSupplier, java.util.function.Supplier<Executor> executorSupplier)
public ExecutionContextRule(java.util.function.Supplier<BufferAllocator> allocatorSupplier, java.util.function.Supplier<IoExecutor> ioExecutorSupplier, java.util.function.Supplier<Executor> executorSupplier, java.util.function.Supplier<ExecutionStrategy> executionStrategySupplier)
public static ExecutionContextRule immediate()
public static ExecutionContextRule immediate(java.util.concurrent.ThreadFactory ioThreadFactory)
public static ExecutionContextRule cached()
public static ExecutionContextRule cached(java.util.concurrent.ThreadFactory ioThreadFactory)
public static ExecutionContextRule cached(java.lang.String ioThreadPrefix, java.lang.String executorThreadPrefix)
public static ExecutionContextRule fixed(int size)
public static ExecutionContextRule fixed(int size, java.util.concurrent.ThreadFactory ioThreadFactory)
public static ExecutionContextRule single()
public static ExecutionContextRule single(java.util.concurrent.ThreadFactory ioThreadFactory)
protected void before()
before
in class org.junit.rules.ExternalResource
protected void after()
after
in class org.junit.rules.ExternalResource
public BufferAllocator bufferAllocator()
ExecutionContext
BufferAllocator
that can be used to allocate Buffer
s if needed.bufferAllocator
in interface ExecutionContext
BufferAllocator
to usepublic IoExecutor ioExecutor()
ExecutionContext
IoExecutor
that is used to handle the IO.ioExecutor
in interface ExecutionContext
IoExecutor
that is used to handle the.public Executor executor()
ExecutionContext
Executor
that is used to create any asynchronous sources.executor
in interface ExecutionContext
Executor
that is used to create any asynchronous sources.public ExecutionStrategy executionStrategy()
ExecutionContext
ExecutionStrategy
associated with this context.executionStrategy
in interface ExecutionContext
ExecutionStrategy
associated with this context.