class TimeoutExtension extends java.lang.Object implements BeforeAllCallback, BeforeEachCallback, InvocationInterceptor
Modifier and Type | Class and Description |
---|---|
private static class |
TimeoutExtension.ExecutorResource |
private static interface |
TimeoutExtension.TimeoutProvider |
InvocationInterceptor.Invocation<T>
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
DISABLED_MODE_VALUE |
private static java.lang.String |
DISABLED_ON_DEBUG_MODE_VALUE |
private static java.lang.String |
ENABLED_MODE_VALUE |
private static java.lang.String |
GLOBAL_TIMEOUT_CONFIG_KEY |
private static ExtensionContext.Namespace |
NAMESPACE |
private static java.lang.String |
TESTABLE_METHOD_TIMEOUT_KEY |
Constructor and Description |
---|
TimeoutExtension() |
Modifier and Type | Method and Description |
---|---|
void |
beforeAll(ExtensionContext context)
Callback that is invoked once before all tests in the current
container.
|
void |
beforeEach(ExtensionContext context)
Callback that is invoked before each test is invoked.
|
private <T> InvocationInterceptor.Invocation<T> |
decorate(InvocationInterceptor.Invocation<T> invocation,
ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext,
ExtensionContext extensionContext,
TimeoutDuration timeout) |
private java.lang.String |
describe(ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext,
ExtensionContext extensionContext) |
private TimeoutDuration |
getDefaultTimeout(ExtensionContext extensionContext,
TimeoutExtension.TimeoutProvider defaultTimeoutProvider) |
private java.util.concurrent.ScheduledExecutorService |
getExecutor(ExtensionContext extensionContext) |
private TimeoutConfiguration |
getGlobalTimeoutConfiguration(ExtensionContext extensionContext) |
private <T> T |
intercept(InvocationInterceptor.Invocation<T> invocation,
ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext,
ExtensionContext extensionContext,
TimeoutDuration explicitTimeout,
TimeoutExtension.TimeoutProvider defaultTimeoutProvider) |
void |
interceptAfterAllMethod(InvocationInterceptor.Invocation<java.lang.Void> invocation,
ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext,
ExtensionContext extensionContext)
Intercept the invocation of an
@AfterAll method. |
void |
interceptAfterEachMethod(InvocationInterceptor.Invocation<java.lang.Void> invocation,
ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext,
ExtensionContext extensionContext)
Intercept the invocation of an
@AfterEach method. |
void |
interceptBeforeAllMethod(InvocationInterceptor.Invocation<java.lang.Void> invocation,
ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext,
ExtensionContext extensionContext)
Intercept the invocation of a
@BeforeAll method. |
void |
interceptBeforeEachMethod(InvocationInterceptor.Invocation<java.lang.Void> invocation,
ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext,
ExtensionContext extensionContext)
Intercept the invocation of a
@BeforeEach method. |
private void |
interceptLifecycleMethod(InvocationInterceptor.Invocation<java.lang.Void> invocation,
ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext,
ExtensionContext extensionContext,
TimeoutExtension.TimeoutProvider defaultTimeoutProvider) |
private <T> T |
interceptTestableMethod(InvocationInterceptor.Invocation<T> invocation,
ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext,
ExtensionContext extensionContext,
TimeoutExtension.TimeoutProvider defaultTimeoutProvider) |
<T> T |
interceptTestFactoryMethod(InvocationInterceptor.Invocation<T> invocation,
ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext,
ExtensionContext extensionContext)
Intercept the invocation of a
@TestFactory method. |
void |
interceptTestMethod(InvocationInterceptor.Invocation<java.lang.Void> invocation,
ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext,
ExtensionContext extensionContext)
Intercept the invocation of a
@Test method. |
void |
interceptTestTemplateMethod(InvocationInterceptor.Invocation<java.lang.Void> invocation,
ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext,
ExtensionContext extensionContext)
Intercept the invocation of a
@TestTemplate method. |
private boolean |
isTimeoutDisabled(ExtensionContext extensionContext)
Determine if timeouts are disabled for the supplied extension context.
|
private boolean |
isTimeoutDisabled(java.lang.String mode)
Determine if timeouts are disabled for the supplied mode.
|
private void |
readAndStoreTimeoutSoChildrenInheritIt(ExtensionContext context) |
private java.util.Optional<TimeoutDuration> |
readTimeoutFromAnnotation(java.util.Optional<java.lang.reflect.AnnotatedElement> element) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
interceptDynamicTest, interceptTestClassConstructor
private static final ExtensionContext.Namespace NAMESPACE
private static final java.lang.String TESTABLE_METHOD_TIMEOUT_KEY
private static final java.lang.String GLOBAL_TIMEOUT_CONFIG_KEY
private static final java.lang.String ENABLED_MODE_VALUE
private static final java.lang.String DISABLED_MODE_VALUE
private static final java.lang.String DISABLED_ON_DEBUG_MODE_VALUE
public void beforeAll(ExtensionContext context)
BeforeAllCallback
beforeAll
in interface BeforeAllCallback
context
- the current extension context; never null
public void beforeEach(ExtensionContext context)
BeforeEachCallback
beforeEach
in interface BeforeEachCallback
context
- the current extension context; never null
private void readAndStoreTimeoutSoChildrenInheritIt(ExtensionContext context)
public void interceptBeforeAllMethod(InvocationInterceptor.Invocation<java.lang.Void> invocation, ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext, ExtensionContext extensionContext) throws java.lang.Throwable
InvocationInterceptor
@BeforeAll
method.interceptBeforeAllMethod
in interface InvocationInterceptor
invocation
- the invocation that is being intercepted; never
null
invocationContext
- the context of the invocation that is being
intercepted; never null
extensionContext
- the current extension context; never null
java.lang.Throwable
- in case of failurespublic void interceptBeforeEachMethod(InvocationInterceptor.Invocation<java.lang.Void> invocation, ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext, ExtensionContext extensionContext) throws java.lang.Throwable
InvocationInterceptor
@BeforeEach
method.interceptBeforeEachMethod
in interface InvocationInterceptor
invocation
- the invocation that is being intercepted; never
null
invocationContext
- the context of the invocation that is being
intercepted; never null
extensionContext
- the current extension context; never null
java.lang.Throwable
- in case of failurespublic void interceptTestMethod(InvocationInterceptor.Invocation<java.lang.Void> invocation, ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext, ExtensionContext extensionContext) throws java.lang.Throwable
InvocationInterceptor
@Test
method.interceptTestMethod
in interface InvocationInterceptor
invocation
- the invocation that is being intercepted; never
null
invocationContext
- the context of the invocation that is being
intercepted; never null
extensionContext
- the current extension context; never null
java.lang.Throwable
- in case of failurespublic void interceptTestTemplateMethod(InvocationInterceptor.Invocation<java.lang.Void> invocation, ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext, ExtensionContext extensionContext) throws java.lang.Throwable
InvocationInterceptor
@TestTemplate
method.interceptTestTemplateMethod
in interface InvocationInterceptor
invocation
- the invocation that is being intercepted; never
null
invocationContext
- the context of the invocation that is being
intercepted; never null
extensionContext
- the current extension context; never null
java.lang.Throwable
- in case of failurespublic <T> T interceptTestFactoryMethod(InvocationInterceptor.Invocation<T> invocation, ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext, ExtensionContext extensionContext) throws java.lang.Throwable
InvocationInterceptor
@TestFactory
method.interceptTestFactoryMethod
in interface InvocationInterceptor
T
- the result typeinvocation
- the invocation that is being intercepted; never
null
invocationContext
- the context of the invocation that is being
intercepted; never null
extensionContext
- the current extension context; never null
null
java.lang.Throwable
- in case of failurespublic void interceptAfterEachMethod(InvocationInterceptor.Invocation<java.lang.Void> invocation, ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext, ExtensionContext extensionContext) throws java.lang.Throwable
InvocationInterceptor
@AfterEach
method.interceptAfterEachMethod
in interface InvocationInterceptor
invocation
- the invocation that is being intercepted; never
null
invocationContext
- the context of the invocation that is being
intercepted; never null
extensionContext
- the current extension context; never null
java.lang.Throwable
- in case of failurespublic void interceptAfterAllMethod(InvocationInterceptor.Invocation<java.lang.Void> invocation, ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext, ExtensionContext extensionContext) throws java.lang.Throwable
InvocationInterceptor
@AfterAll
method.interceptAfterAllMethod
in interface InvocationInterceptor
invocation
- the invocation that is being intercepted; never
null
invocationContext
- the context of the invocation that is being
intercepted; never null
extensionContext
- the current extension context; never null
java.lang.Throwable
- in case of failuresprivate void interceptLifecycleMethod(InvocationInterceptor.Invocation<java.lang.Void> invocation, ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext, ExtensionContext extensionContext, TimeoutExtension.TimeoutProvider defaultTimeoutProvider) throws java.lang.Throwable
java.lang.Throwable
private java.util.Optional<TimeoutDuration> readTimeoutFromAnnotation(java.util.Optional<java.lang.reflect.AnnotatedElement> element)
private <T> T interceptTestableMethod(InvocationInterceptor.Invocation<T> invocation, ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext, ExtensionContext extensionContext, TimeoutExtension.TimeoutProvider defaultTimeoutProvider) throws java.lang.Throwable
java.lang.Throwable
private <T> T intercept(InvocationInterceptor.Invocation<T> invocation, ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext, ExtensionContext extensionContext, TimeoutDuration explicitTimeout, TimeoutExtension.TimeoutProvider defaultTimeoutProvider) throws java.lang.Throwable
java.lang.Throwable
private TimeoutDuration getDefaultTimeout(ExtensionContext extensionContext, TimeoutExtension.TimeoutProvider defaultTimeoutProvider)
private TimeoutConfiguration getGlobalTimeoutConfiguration(ExtensionContext extensionContext)
private <T> InvocationInterceptor.Invocation<T> decorate(InvocationInterceptor.Invocation<T> invocation, ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext, ExtensionContext extensionContext, TimeoutDuration timeout)
private java.lang.String describe(ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext, ExtensionContext extensionContext)
private java.util.concurrent.ScheduledExecutorService getExecutor(ExtensionContext extensionContext)
private boolean isTimeoutDisabled(ExtensionContext extensionContext)
private boolean isTimeoutDisabled(java.lang.String mode)