Package io.vertx.junit5
Class RunTestOnContext
- java.lang.Object
-
- io.vertx.junit5.RunTestOnContext
-
- All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterAllCallback
,org.junit.jupiter.api.extension.AfterEachCallback
,org.junit.jupiter.api.extension.BeforeAllCallback
,org.junit.jupiter.api.extension.Extension
,org.junit.jupiter.api.extension.InvocationInterceptor
public class RunTestOnContext extends Object implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.InvocationInterceptor, org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.AfterAllCallback
An extension that runs tests on a Vert.x context.When used as a
RegisterExtension
instance field, a newVertx
object andContext
are created for each tested method.BeforeEach
andAfterEach
methods are executed on this context.When used as a
RegisterExtension
static field, a singleVertx
object andContext
are created for all the tested methods.BeforeAll
andAfterAll
methods are executed on this context too.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.junit.jupiter.api.extension.InvocationInterceptor
org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T extends Object>
-
-
Constructor Summary
Constructors Constructor Description RunTestOnContext()
Create an instance of this extension that builds aVertx
object using default options.RunTestOnContext(VertxOptions options, boolean clustered)
Create an instance of this extension that builds aVertx
object using the specifiedoptions
.RunTestOnContext(java.util.function.Supplier<Future<Vertx>> supplier)
Create an instance of this extension that gets aVertx
object using the specified asynchronoussupplier
.RunTestOnContext(java.util.function.Supplier<Future<Vertx>> supplier, java.util.function.Function<Vertx,Future<Void>> shutdown)
Create an instance of this extension that gets aVertx
object using the specified asynchronoussupplier
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterAll(org.junit.jupiter.api.extension.ExtensionContext context)
void
afterEach(org.junit.jupiter.api.extension.ExtensionContext context)
void
beforeAll(org.junit.jupiter.api.extension.ExtensionContext context)
void
interceptAfterAllMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
void
interceptAfterEachMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
void
interceptBeforeAllMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
void
interceptBeforeEachMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
void
interceptDynamicTest(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
<T> T
interceptTestFactoryMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
void
interceptTestMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
void
interceptTestTemplateMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
Vertx
vertx()
-
-
-
Constructor Detail
-
RunTestOnContext
public RunTestOnContext()
Create an instance of this extension that builds aVertx
object using default options.
-
RunTestOnContext
public RunTestOnContext(VertxOptions options, boolean clustered)
Create an instance of this extension that builds aVertx
object using the specifiedoptions
.When the options hold a
ClusterManager
instance, a clusteredVertx
object is created.- Parameters:
options
- the vertx options
-
RunTestOnContext
public RunTestOnContext(java.util.function.Supplier<Future<Vertx>> supplier)
Create an instance of this extension that gets aVertx
object using the specified asynchronoussupplier
.- Parameters:
supplier
- the asynchronous supplier
-
RunTestOnContext
public RunTestOnContext(java.util.function.Supplier<Future<Vertx>> supplier, java.util.function.Function<Vertx,Future<Void>> shutdown)
Create an instance of this extension that gets aVertx
object using the specified asynchronoussupplier
. The asynchronousshutdown
function is invoked when theVertx
object is no longer needed.- Parameters:
supplier
- the asynchronous suppliershutdown
- the asynchronous shutdown function
-
-
Method Detail
-
vertx
public Vertx vertx()
- Returns:
- the current Vert.x instance
-
beforeAll
public void beforeAll(org.junit.jupiter.api.extension.ExtensionContext context)
- Specified by:
beforeAll
in interfaceorg.junit.jupiter.api.extension.BeforeAllCallback
-
interceptBeforeAllMethod
public void interceptBeforeAllMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable
- Specified by:
interceptBeforeAllMethod
in interfaceorg.junit.jupiter.api.extension.InvocationInterceptor
- Throws:
Throwable
-
interceptBeforeEachMethod
public void interceptBeforeEachMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable
- Specified by:
interceptBeforeEachMethod
in interfaceorg.junit.jupiter.api.extension.InvocationInterceptor
- Throws:
Throwable
-
interceptTestMethod
public void interceptTestMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable
- Specified by:
interceptTestMethod
in interfaceorg.junit.jupiter.api.extension.InvocationInterceptor
- Throws:
Throwable
-
interceptTestFactoryMethod
public <T> T interceptTestFactoryMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable
- Specified by:
interceptTestFactoryMethod
in interfaceorg.junit.jupiter.api.extension.InvocationInterceptor
- Throws:
Throwable
-
interceptTestTemplateMethod
public void interceptTestTemplateMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable
- Specified by:
interceptTestTemplateMethod
in interfaceorg.junit.jupiter.api.extension.InvocationInterceptor
- Throws:
Throwable
-
interceptDynamicTest
public void interceptDynamicTest(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable
- Specified by:
interceptDynamicTest
in interfaceorg.junit.jupiter.api.extension.InvocationInterceptor
- Throws:
Throwable
-
interceptAfterEachMethod
public void interceptAfterEachMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable
- Specified by:
interceptAfterEachMethod
in interfaceorg.junit.jupiter.api.extension.InvocationInterceptor
- Throws:
Throwable
-
interceptAfterAllMethod
public void interceptAfterAllMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable
- Specified by:
interceptAfterAllMethod
in interfaceorg.junit.jupiter.api.extension.InvocationInterceptor
- Throws:
Throwable
-
afterEach
public void afterEach(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
- Specified by:
afterEach
in interfaceorg.junit.jupiter.api.extension.AfterEachCallback
- Throws:
Exception
-
-