Package org.osgi.test.junit5.service
Class ServiceExtension
java.lang.Object
org.osgi.test.junit5.inject.InjectingExtension<InjectService>
org.osgi.test.junit5.service.ServiceExtension
- 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
A JUnit 5 Extension to depend on OSGi services.
Example:
@ExtendWith(ServiceExtension.class)
class MyTests {
@InjectService
Foo foo;
@Test
public void test() {
// use foo
}
}
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <S> ServiceConfiguration<S>getServiceConfiguration(Class<S> serviceType, String format, String[] args, int cardinality, long timeout, org.junit.jupiter.api.extension.ExtensionContext extensionContext) protected ObjectresolveValue(TargetType targetType, InjectService injectService, org.junit.jupiter.api.extension.ExtensionContext extensionContext) Resolve the value for the specifiedTargetTypeand injection annotation for the specifiedExtensionContext.protected booleansupportsType(TargetType targetType, org.junit.jupiter.api.extension.ExtensionContext extensionContext) Determine if this extender supports resolution for the specifiedTargetTypefor the specifiedExtensionContext.Methods inherited from class org.osgi.test.junit5.inject.InjectingExtension
afterAll, afterEach, annotation, beforeAll, beforeEach, disallowedFieldModifiers, isLifecyclePerClass, isLifecyclePerClass, resolveField, resolveParameter, supportsField, supportsParameter, targetTypes
-
Constructor Details
-
ServiceExtension
public ServiceExtension()
-
-
Method Details
-
supportsType
protected boolean supportsType(TargetType targetType, org.junit.jupiter.api.extension.ExtensionContext extensionContext) Description copied from class:InjectingExtensionDetermine if this extender supports resolution for the specifiedTargetTypefor the specifiedExtensionContext. The default implementation checks through all of the types that were passed to the constructor.- Overrides:
supportsTypein classInjectingExtension<InjectService>
-
resolveValue
protected Object resolveValue(TargetType targetType, InjectService injectService, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws org.junit.jupiter.api.extension.ParameterResolutionException Description copied from class:InjectingExtensionResolve the value for the specifiedTargetTypeand injection annotation for the specifiedExtensionContext.- Specified by:
resolveValuein classInjectingExtension<InjectService>- Throws:
org.junit.jupiter.api.extension.ParameterResolutionException
-
getServiceConfiguration
public static <S> ServiceConfiguration<S> getServiceConfiguration(Class<S> serviceType, String format, String[] args, int cardinality, long timeout, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
-