Package org.osgi.test.junit5.context
Class BundleContextExtension
java.lang.Object
org.osgi.test.junit5.inject.InjectingExtension<InjectBundleContext>
org.osgi.test.junit5.context.BundleContextExtension
- 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
@ExtendWith(BundleInstallerExtension.class)
public class BundleContextExtension
extends InjectingExtension<InjectBundleContext>
A JUnit 5 Extension to get the OSGi
BundleContext of the test bundle.
The BundleContext implementation provided by this extension will
automatically clean up all service registrations, bundle, service and
framework listeners, as well as installed bundles left behind.
Example:
@ExtendWith(BundleContextExtension.class)
class MyTests {
@InjectBundleContext
BundleContext bundleContext;
@Test
public void aTest() {
Bundle bundle = bundleContext.getBundle();
}
}
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.osgi.framework.BundleContextgetBundleContext(org.junit.jupiter.api.extension.ExtensionContext extensionContext) static BundleInstallergetBundleInstaller(org.junit.jupiter.api.extension.ExtensionContext extensionContext) Deprecated.protected ObjectresolveValue(TargetType targetType, InjectBundleContext injection, org.junit.jupiter.api.extension.ExtensionContext extensionContext) Resolve the value for the specifiedTargetTypeand injection annotation for the specifiedExtensionContext.Methods inherited from class org.osgi.test.junit5.inject.InjectingExtension
afterAll, afterEach, annotation, beforeAll, beforeEach, disallowedFieldModifiers, isLifecyclePerClass, isLifecyclePerClass, resolveField, resolveParameter, supportsField, supportsParameter, supportsType, targetTypes
-
Field Details
-
BUNDLE_CONTEXT_KEY
- See Also:
-
INSTALL_BUNDLE_KEY
Deprecated.Replaced byBundleInstallerExtension.INSTALL_BUNDLE_KEY.- See Also:
-
-
Constructor Details
-
BundleContextExtension
public BundleContextExtension()
-
-
Method Details
-
getBundleContext
public static org.osgi.framework.BundleContext getBundleContext(org.junit.jupiter.api.extension.ExtensionContext extensionContext) -
getBundleInstaller
@Deprecated public static BundleInstaller getBundleInstaller(org.junit.jupiter.api.extension.ExtensionContext extensionContext) Deprecated. -
resolveValue
protected Object resolveValue(TargetType targetType, InjectBundleContext injection, 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<InjectBundleContext>- Throws:
org.junit.jupiter.api.extension.ParameterResolutionException
-
BundleInstallerExtension.INSTALL_BUNDLE_KEY.