Class ExecutionContextRule
- java.lang.Object
-
- org.junit.rules.ExternalResource
-
- io.servicetalk.transport.netty.internal.ExecutionContextRule
-
- All Implemented Interfaces:
ExecutionContext
,org.junit.rules.TestRule
public final class ExecutionContextRule extends org.junit.rules.ExternalResource implements ExecutionContext
Test helper that creates and disposes anExecutionContext
for your test case or suite.Can be used with a @
Rule
field and astatic
field with @ClassRule
.
-
-
Constructor Summary
Constructors Constructor 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)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
after()
protected void
before()
BufferAllocator
bufferAllocator()
Return theBufferAllocator
that can be used to allocateBuffer
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 theExecutionStrategy
associated with this context.Executor
executor()
Get theExecutor
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 theIoExecutor
that is used to handle the IO.static ExecutionContextRule
single()
static ExecutionContextRule
single(java.util.concurrent.ThreadFactory ioThreadFactory)
-
-
-
Constructor Detail
-
ExecutionContextRule
public ExecutionContextRule(java.util.function.Supplier<BufferAllocator> allocatorSupplier, java.util.function.Supplier<IoExecutor> ioExecutorSupplier, java.util.function.Supplier<Executor> executorSupplier)
-
ExecutionContextRule
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)
-
-
Method Detail
-
immediate
public static ExecutionContextRule immediate()
-
immediate
public static ExecutionContextRule immediate(java.util.concurrent.ThreadFactory ioThreadFactory)
-
cached
public static ExecutionContextRule cached()
-
cached
public static ExecutionContextRule cached(java.util.concurrent.ThreadFactory ioThreadFactory)
-
cached
public static ExecutionContextRule cached(java.lang.String ioThreadPrefix, java.lang.String executorThreadPrefix)
-
fixed
public static ExecutionContextRule fixed(int size)
-
fixed
public static ExecutionContextRule fixed(int size, java.util.concurrent.ThreadFactory ioThreadFactory)
-
single
public static ExecutionContextRule single()
-
single
public static ExecutionContextRule single(java.util.concurrent.ThreadFactory ioThreadFactory)
-
before
protected void before()
- Overrides:
before
in classorg.junit.rules.ExternalResource
-
after
protected void after()
- Overrides:
after
in classorg.junit.rules.ExternalResource
-
bufferAllocator
public BufferAllocator bufferAllocator()
Description copied from interface:ExecutionContext
Return theBufferAllocator
that can be used to allocateBuffer
s if needed.- Specified by:
bufferAllocator
in interfaceExecutionContext
- Returns:
- the
BufferAllocator
to use
-
ioExecutor
public IoExecutor ioExecutor()
Description copied from interface:ExecutionContext
Get theIoExecutor
that is used to handle the IO.- Specified by:
ioExecutor
in interfaceExecutionContext
- Returns:
- The
IoExecutor
that is used to handle the.
-
executor
public Executor executor()
Description copied from interface:ExecutionContext
Get theExecutor
that is used to create any asynchronous sources.- Specified by:
executor
in interfaceExecutionContext
- Returns:
- The
Executor
that is used to create any asynchronous sources.
-
executionStrategy
public ExecutionStrategy executionStrategy()
Description copied from interface:ExecutionContext
Returns theExecutionStrategy
associated with this context.- Specified by:
executionStrategy
in interfaceExecutionContext
- Returns:
- The
ExecutionStrategy
associated with this context.
-
-