Class OsgiConfigParametersExtension
- java.lang.Object
-
- org.apache.sling.testing.mock.osgi.junit5.OsgiConfigParametersExtension
-
- All Implemented Interfaces:
org.junit.jupiter.api.extension.BeforeEachCallback
,org.junit.jupiter.api.extension.Extension
,org.junit.jupiter.api.extension.ParameterResolver
public class OsgiConfigParametersExtension extends Object implements org.junit.jupiter.api.extension.ParameterResolver, org.junit.jupiter.api.extension.BeforeEachCallback
AnExtension
which uses JUnit5 context reflection to discover OSGi Config Type Annotations present on test methods and classes, and then injects them as test parameters. For this to work for your config type annotation, you must specify@Retention(RetentionPolicy.RUNTIME)
on the desired config type annotation class, or useConfigType
to declare that your config type is supported as a test parameter. This extension is also responsible for discoveringSetConfig
annotations and installing them into theOsgiContextImpl
's ConfigurationAdmin service.
-
-
Constructor Summary
Constructors Constructor Description OsgiConfigParametersExtension()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beforeEach(org.junit.jupiter.api.extension.ExtensionContext extensionContext)
Object
resolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
boolean
supportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
-
-
-
Method Detail
-
beforeEach
public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Exception
- Specified by:
beforeEach
in interfaceorg.junit.jupiter.api.extension.BeforeEachCallback
- Throws:
Exception
-
supportsParameter
public boolean supportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) 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 parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws org.junit.jupiter.api.extension.ParameterResolutionException
- Specified by:
resolveParameter
in interfaceorg.junit.jupiter.api.extension.ParameterResolver
- Throws:
org.junit.jupiter.api.extension.ParameterResolutionException
-
-