Package io.servicetalk.concurrent.api
Class ExecutorExtension<E extends Executor>
- java.lang.Object
-
- io.servicetalk.concurrent.api.ExecutorExtension<E>
-
- Type Parameters:
E
- The type ofExecutor
.
- All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterEachCallback
,org.junit.jupiter.api.extension.BeforeEachCallback
,org.junit.jupiter.api.extension.Extension
public final class ExecutorExtension<E extends Executor> extends java.lang.Object implements org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterEachCallback
AnExtension
wrapper for anExecutor
.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterEach(org.junit.jupiter.api.extension.ExtensionContext context)
void
beforeEach(org.junit.jupiter.api.extension.ExtensionContext context)
E
executor()
ReturnsExecutor
created on the last call tobeforeEach(ExtensionContext)
()}.static ExecutorExtension<Executor>
withCachedExecutor()
Create anExecutorExtension
with a default executor.static ExecutorExtension<Executor>
withCachedExecutor(java.lang.String namePrefix)
Create anExecutorExtension
with a default executor, configured to prefix thread names withnamePrefix
.static ExecutorExtension<Executor>
withExecutor(java.util.function.Supplier<Executor> executorSupplier)
Create anExecutorExtension
with the specifiedexecutor
.static ExecutorExtension<TestExecutor>
withTestExecutor()
Create anExecutorExtension
with aTestExecutor
.
-
-
-
Method Detail
-
withCachedExecutor
public static ExecutorExtension<Executor> withCachedExecutor()
Create anExecutorExtension
with a default executor.- Returns:
- a new
ExecutorExtension
.
-
withTestExecutor
public static ExecutorExtension<TestExecutor> withTestExecutor()
Create anExecutorExtension
with aTestExecutor
.executor()
will return theTestExecutor
to allow controlling the executor in tests.- Returns:
- a new
ExecutorExtension
.
-
withExecutor
public static ExecutorExtension<Executor> withExecutor(java.util.function.Supplier<Executor> executorSupplier)
Create anExecutorExtension
with the specifiedexecutor
.- Parameters:
executorSupplier
- TheExecutor
Supplier
to use.- Returns:
- a new
ExecutorExtension
.
-
withCachedExecutor
public static ExecutorExtension<Executor> withCachedExecutor(java.lang.String namePrefix)
Create anExecutorExtension
with a default executor, configured to prefix thread names withnamePrefix
.- Parameters:
namePrefix
- the name to prefix thread names with.- Returns:
- a new
ExecutorExtension
.
-
executor
public E executor()
ReturnsExecutor
created on the last call tobeforeEach(ExtensionContext)
()}.- Returns:
Executor
created on the last call tobeforeEach(ExtensionContext)
()}.null
ifbeforeEach(ExtensionContext)
()} has not been called yet.
-
beforeEach
public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context)
- Specified by:
beforeEach
in interfaceorg.junit.jupiter.api.extension.BeforeEachCallback
-
afterEach
public void afterEach(org.junit.jupiter.api.extension.ExtensionContext context) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
- Specified by:
afterEach
in interfaceorg.junit.jupiter.api.extension.AfterEachCallback
- Throws:
java.util.concurrent.ExecutionException
java.lang.InterruptedException
-
-