public class StubServiceRegistration<T>
extends org.junit.rules.ExternalResource
Rule
annotation that allows to register an OSGi
service for the duration of the test.Modifier and Type | Field and Description |
---|---|
private T |
instance |
private org.osgi.framework.ServiceRegistration<T> |
serviceRegistration |
private java.lang.Class<T> |
type |
Constructor and Description |
---|
StubServiceRegistration(java.lang.Class<T> type)
Rule that can be used to register a service of the given type. |
StubServiceRegistration(java.lang.Class<T> type,
T instance)
Rule that registers (and unregisters) the given instance as service of the given
type. |
Modifier and Type | Method and Description |
---|---|
protected void |
after() |
protected void |
before() |
private void |
internalRegisterService() |
void |
registerService(T instance) |
private final java.lang.Class<T> type
private T instance
private org.osgi.framework.ServiceRegistration<T> serviceRegistration
public StubServiceRegistration(java.lang.Class<T> type, T instance)
Rule
that registers (and unregisters) the given instance as service of the given
type.type
- The type of service to be registered.instance
- The instance to be registered as service.public StubServiceRegistration(java.lang.Class<T> type)
Rule
that can be used to register a service of the given type.type
- The type of service to be registered.#registerService(T)
protected void before() throws java.lang.Throwable
before
in class org.junit.rules.ExternalResource
java.lang.Throwable
public void registerService(T instance)
private void internalRegisterService()
protected void after()
after
in class org.junit.rules.ExternalResource