@Target(value=FIELD) @Retention(value=RUNTIME) public @interface MockOsgiService
ServiceRegistrationRule
to the Pax Exam test class and annotate
any OSGi service field that needs to be mocked.
Service properties can be assigned to the service using the properties()
attribute,
and all supported Mockito Answers
modes can be specified using the answer()
attribute.
For instance, the following code would mock the Catalog Framework and Mime Type Resolver services in a Pax Exam test class:
public class TestClass { @Rule public final ServiceRegistrationRule serviceRegistrationRule = new ServiceRegistrationRule(); @MockOsgiService private CatalogFramework catalogFramework; @MockOsgiService(properties = { @Property(key = "name", value = "tikaMimeTypeResolver")}) private MimeTypeResolver mimeTypeResolver; // ... }
Modifier and Type | Optional Element and Description |
---|---|
org.mockito.Answers |
answer
Answer mode to use for the mock
|
MockOsgiService.Property[] |
properties
Properties to assign to the service when registering the mock with OSGi.
|
public abstract org.mockito.Answers answer
public abstract MockOsgiService.Property[] properties
This work is licensed under a Creative Commons Attribution 4.0 International License.