Class ResourcesExtension
- 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.BeforeEachCallback
,org.junit.jupiter.api.extension.Extension
,org.junit.jupiter.api.extension.ParameterResolver
Resource
annotation - the supported types are as follows:
Path. A Path
will be populated with the path representation of the provided classpath value.
File. A File
will be populated with the file representation of the provided classpath value.
String. A String
will be populated with the contents of the file at the classpath location,
as a String.
InputStream. An InputStream
will be populated with the content of the file at the classpath
location, as an InputStream.
Reader. A Reader
will be populated with the content of the file at the classpath location,
as a Reader.
byte[]. A byte array will be populated with the content of the file at the classpath location, as a array of bytes.
Everything else. Any other object type will attempt to deserialize the contents of the file at the
classpath location using the configured "serdes" value of the annotation (defaulting to JacksonJsonSerdes
if
none is specified.
The annotated types may be on:
Static Fields. A "static" field annotated with the Resource
annotation will be populated
during the "BeforeAll" callback.
Non-Static Fields. A non-static field annotated with the Resource
annotation will be populated
during the "BeforeEach" callback.
Callback or Test Method Parameters. A lifecycle callback or test method parameter annotated with the
Resource
annotation will be populated when that method is called by the test framework.
Note: All injected fields will be cleared (set to null) during the appropriate "after" callback.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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
beforeEach
(org.junit.jupiter.api.extension.ExtensionContext context) resolveParameter
(org.junit.jupiter.api.extension.ParameterContext paramContext, org.junit.jupiter.api.extension.ExtensionContext extContext) boolean
supportsParameter
(org.junit.jupiter.api.extension.ParameterContext paramContext, org.junit.jupiter.api.extension.ExtensionContext extContext)
-
Constructor Details
-
ResourcesExtension
public ResourcesExtension()
-
-
Method Details
-
beforeAll
- Specified by:
beforeAll
in interfaceorg.junit.jupiter.api.extension.BeforeAllCallback
- Throws:
Exception
-
beforeEach
- Specified by:
beforeEach
in interfaceorg.junit.jupiter.api.extension.BeforeEachCallback
- Throws:
Exception
-
afterEach
- Specified by:
afterEach
in interfaceorg.junit.jupiter.api.extension.AfterEachCallback
- Throws:
Exception
-
afterAll
- Specified by:
afterAll
in interfaceorg.junit.jupiter.api.extension.AfterAllCallback
- Throws:
Exception
-
supportsParameter
public boolean supportsParameter(org.junit.jupiter.api.extension.ParameterContext paramContext, org.junit.jupiter.api.extension.ExtensionContext extContext) throws org.junit.jupiter.api.extension.ParameterResolutionException - Specified by:
supportsParameter
in interfaceorg.junit.jupiter.api.extension.ParameterResolver
- Throws:
org.junit.jupiter.api.extension.ParameterResolutionException
-
resolveParameter
public Object resolveParameter(org.junit.jupiter.api.extension.ParameterContext paramContext, org.junit.jupiter.api.extension.ExtensionContext extContext) throws org.junit.jupiter.api.extension.ParameterResolutionException - Specified by:
resolveParameter
in interfaceorg.junit.jupiter.api.extension.ParameterResolver
- Throws:
org.junit.jupiter.api.extension.ParameterResolutionException
-