public abstract class DeclarativeServiceTestCase
extends TestCase
| Modifier and Type | Field and Description |
|---|---|
protected Log |
_log
The log.
|
protected static int |
DEFAULT_SERVICE_MAX_WAITING
The Constant DEFAULT_SERVICE_MAX_WAITING.
|
| Constructor and Description |
|---|
DeclarativeServiceTestCase() |
| Modifier and Type | Method and Description |
|---|---|
protected static void |
assertServiceRegistered(java.lang.Class<?> serviceInterface,
java.lang.Class<?> implementationClass)
check if a service with the given service and implementation class was registered.
|
protected <T> T |
getService(java.lang.Class<T> clazz)
Gets the service with default wait delay.
|
protected <T> T |
getService(java.lang.Class<T> clazz,
long timeout)
Deprecated.
|
protected <T> T |
getService(java.lang.Class<T> clazz,
java.lang.String filter)
Gets the service with default wait delay.
|
protected <T> T |
getService(java.lang.Class<T> clazz,
java.lang.String filter,
long timeout)
Uses a ServiceTracker to get the given DeclarativeService.
|
protected java.lang.Object |
getService(java.lang.String clazz,
long timeout)
Deprecated.
|
protected java.lang.Object |
getService(java.lang.String clazz,
java.lang.String filter,
long timeout)
Deprecated.
|
protected <T> T |
registerService(java.lang.Object service,
java.util.Dictionary<java.lang.String,?> properties,
java.lang.Class<T> clazz,
long timeout)
Registers the given service and returns it.
|
protected java.net.URL |
resolveResourceURL(java.lang.String relativePath)
Resolve resource URL.
|
static void |
setBundleContext(BundleContext bundleContext)
Sets the BundleContext.
|
protected void |
unregisterService(java.lang.Class<?> clazz)
Unregisters the given service.
|
protected static final int DEFAULT_SERVICE_MAX_WAITING
protected final Log _log
public static void setBundleContext(BundleContext bundleContext)
bundleContext - the BundleContext@Deprecated
protected java.lang.Object getService(java.lang.String clazz,
long timeout)
throws java.lang.InterruptedException
clazz - the class name of the DeclarativeService interfacetimeout - the number of milliseconds to wait for the ServiceTracker to find the servicejava.lang.InterruptedException - a InterruptedException@Deprecated
protected <T> T getService(java.lang.Class<T> clazz,
long timeout)
throws java.lang.InterruptedException
clazz - the service class of the DeclarativeService interfacetimeout - the number of milliseconds to wait for the ServiceTracker to find the servicejava.lang.InterruptedException - a InterruptedExceptionprotected <T> T getService(java.lang.Class<T> clazz)
throws java.lang.InterruptedException
clazz - the clazzjava.lang.InterruptedException - the interrupted exceptionprotected <T> T getService(java.lang.Class<T> clazz,
java.lang.String filter,
long timeout)
throws java.lang.InterruptedException
clazz - the service class of the DeclarativeService interfacefilter - the filtertimeout - the number of milliseconds to wait for the ServiceTracker to find the servicejava.lang.InterruptedException - a InterruptedExceptionprotected <T> T getService(java.lang.Class<T> clazz,
java.lang.String filter)
throws java.lang.InterruptedException
clazz - the clazzfilter - the filterjava.lang.InterruptedException - the interrupted exception@Deprecated
protected java.lang.Object getService(java.lang.String clazz,
java.lang.String filter,
long timeout)
throws java.lang.InterruptedException
clazz - the class name of the DeclarativeService interfacetimeout - the number of milliseconds to wait for the ServiceTracker to find the servicejava.lang.InterruptedException - a InterruptedExceptionprotected <T> T registerService(java.lang.Object service,
java.util.Dictionary<java.lang.String,?> properties,
java.lang.Class<T> clazz,
long timeout)
throws java.lang.InterruptedException
service - the service to registerproperties - propertiesclazz - the service class of the DeclarativeService interfacetimeout - the number of milliseconds to wait for the ServiceTracker to find the servicejava.lang.InterruptedException - a InterruptedExceptionprotected void unregisterService(java.lang.Class<?> clazz)
throws java.lang.InterruptedException
clazz - the service class to be unregisteredjava.lang.InterruptedException - a InterruptedExceptionorg.osgi.framework.BundleContext#ungetService(ServiceReference)}.protected java.net.URL resolveResourceURL(java.lang.String relativePath)
throws java.io.IOException
relativePath - the relative pathjava.io.IOException - Signals that an I/O exception has occurred.protected static void assertServiceRegistered(java.lang.Class<?> serviceInterface,
java.lang.Class<?> implementationClass)
serviceInterface - service interface classimplementationClass - implementation class