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 anExecutionContextfor your test case or suite.Can be used with a @
Rulefield and astaticfield 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 voidafter()protected voidbefore()BufferAllocatorbufferAllocator()Return theBufferAllocatorthat can be used to allocateBuffers if needed.static ExecutionContextRulecached()static ExecutionContextRulecached(java.lang.String ioThreadPrefix, java.lang.String executorThreadPrefix)static ExecutionContextRulecached(java.util.concurrent.ThreadFactory ioThreadFactory)ExecutionStrategyexecutionStrategy()Returns theExecutionStrategyassociated with this context.Executorexecutor()Get theExecutorthat is used to create any asynchronous sources.static ExecutionContextRulefixed(int size)static ExecutionContextRulefixed(int size, java.util.concurrent.ThreadFactory ioThreadFactory)static ExecutionContextRuleimmediate()static ExecutionContextRuleimmediate(java.util.concurrent.ThreadFactory ioThreadFactory)IoExecutorioExecutor()Get theIoExecutorthat is used to handle the IO.static ExecutionContextRulesingle()static ExecutionContextRulesingle(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:
beforein classorg.junit.rules.ExternalResource
-
after
protected void after()
- Overrides:
afterin classorg.junit.rules.ExternalResource
-
bufferAllocator
public BufferAllocator bufferAllocator()
Description copied from interface:ExecutionContextReturn theBufferAllocatorthat can be used to allocateBuffers if needed.- Specified by:
bufferAllocatorin interfaceExecutionContext- Returns:
- the
BufferAllocatorto use
-
ioExecutor
public IoExecutor ioExecutor()
Description copied from interface:ExecutionContextGet theIoExecutorthat is used to handle the IO.- Specified by:
ioExecutorin interfaceExecutionContext- Returns:
- The
IoExecutorthat is used to handle the.
-
executor
public Executor executor()
Description copied from interface:ExecutionContextGet theExecutorthat is used to create any asynchronous sources.- Specified by:
executorin interfaceExecutionContext- Returns:
- The
Executorthat is used to create any asynchronous sources.
-
executionStrategy
public ExecutionStrategy executionStrategy()
Description copied from interface:ExecutionContextReturns theExecutionStrategyassociated with this context.- Specified by:
executionStrategyin interfaceExecutionContext- Returns:
- The
ExecutionStrategyassociated with this context.
-
-