Class 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
    An Extension 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 use ConfigType to declare that your config type is supported as a test parameter. This extension is also responsible for discovering SetConfig annotations and installing them into the OsgiContextImpl's ConfigurationAdmin service.
    • Constructor Detail

      • OsgiConfigParametersExtension

        public OsgiConfigParametersExtension()
    • Method Detail

      • beforeEach

        public void beforeEach​(org.junit.jupiter.api.extension.ExtensionContext extensionContext)
                        throws Exception
        Specified by:
        beforeEach in interface org.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 interface org.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 interface org.junit.jupiter.api.extension.ParameterResolver
        Throws:
        org.junit.jupiter.api.extension.ParameterResolutionException