SMILA (incubation) API documentation

org.eclipse.smila.test
Class DeclarativeServiceTestCase

java.lang.Object
  extended by TestCase
      extended by org.eclipse.smila.test.DeclarativeServiceTestCase
Direct Known Subclasses:
JmxTestCase

public abstract class DeclarativeServiceTestCase
extends TestCase

Abstract base class for JUnit tests dealing with DeclarativeServices.


Field Summary
protected  Log _log
          The log.
protected static int DEFAULT_SERVICE_MAX_WAITING
          The Constant DEFAULT_SERVICE_MAX_WAITING.
 
Constructor Summary
DeclarativeServiceTestCase()
           
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SERVICE_MAX_WAITING

protected static final int DEFAULT_SERVICE_MAX_WAITING
The Constant DEFAULT_SERVICE_MAX_WAITING.

See Also:
Constant Field Values

_log

protected final Log _log
The log.

Constructor Detail

DeclarativeServiceTestCase

public DeclarativeServiceTestCase()
Method Detail

setBundleContext

public static void setBundleContext(BundleContext bundleContext)
Sets the BundleContext.

Parameters:
bundleContext - the BundleContext

getService

@Deprecated
protected java.lang.Object getService(java.lang.String clazz,
                                                 long timeout)
                               throws java.lang.InterruptedException
Deprecated. 

Uses a ServiceTracker to get the given DeclarativeService.

Parameters:
clazz - the class name of the DeclarativeService interface
timeout - the number of milliseconds to wait for the ServiceTracker to find the service
Returns:
the DeclarativeService as Object. You have to do a type cast.
Throws:
java.lang.InterruptedException - a InterruptedException

getService

@Deprecated
protected <T> T getService(java.lang.Class<T> clazz,
                                      long timeout)
                throws java.lang.InterruptedException
Deprecated. 

Uses a ServiceTracker to get the given DeclarativeService.

Parameters:
clazz - the service class of the DeclarativeService interface
timeout - the number of milliseconds to wait for the ServiceTracker to find the service
Returns:
the DeclarativeService.
Throws:
java.lang.InterruptedException - a InterruptedException

getService

protected <T> T getService(java.lang.Class<T> clazz)
                throws java.lang.InterruptedException
Gets the service with default wait delay.

Parameters:
clazz - the clazz
Returns:
the service
Throws:
java.lang.InterruptedException - the interrupted exception

getService

protected <T> T getService(java.lang.Class<T> clazz,
                           java.lang.String filter,
                           long timeout)
                throws java.lang.InterruptedException
Uses a ServiceTracker to get the given DeclarativeService.

Parameters:
clazz - the service class of the DeclarativeService interface
filter - the filter
timeout - the number of milliseconds to wait for the ServiceTracker to find the service
Returns:
the DeclarativeService.
Throws:
java.lang.InterruptedException - a InterruptedException

getService

protected <T> T getService(java.lang.Class<T> clazz,
                           java.lang.String filter)
                throws java.lang.InterruptedException
Gets the service with default wait delay.

Parameters:
clazz - the clazz
filter - the filter
Returns:
the service
Throws:
java.lang.InterruptedException - the interrupted exception

getService

@Deprecated
protected java.lang.Object getService(java.lang.String clazz,
                                                 java.lang.String filter,
                                                 long timeout)
                               throws java.lang.InterruptedException
Deprecated. 

Uses a ServiceTracker to get the given DeclarativeService.

Parameters:
clazz - the class name of the DeclarativeService interface
timeout - the number of milliseconds to wait for the ServiceTracker to find the service
Returns:
the DeclarativeService as Object. You have to do a type cast.
Throws:
java.lang.InterruptedException - a InterruptedException

registerService

protected <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
Registers the given service and returns it.

Parameters:
service - the service to register
properties - properties
clazz - the service class of the DeclarativeService interface
timeout - the number of milliseconds to wait for the ServiceTracker to find the service
Returns:
the DeclarativeService
Throws:
java.lang.InterruptedException - a InterruptedException

unregisterService

protected void unregisterService(java.lang.Class<?> clazz)
                          throws java.lang.InterruptedException
Unregisters the given service.

Parameters:
clazz - the service class to be unregistered
Throws:
java.lang.InterruptedException - a InterruptedException
See Also:
org.osgi.framework.BundleContext#ungetService(ServiceReference)}.

resolveResourceURL

protected java.net.URL resolveResourceURL(java.lang.String relativePath)
                                   throws java.io.IOException
Resolve resource URL.

Parameters:
relativePath - the relative path
Returns:
the uRL
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

assertServiceRegistered

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.

Parameters:
serviceInterface - service interface class
implementationClass - implementation class

SMILA (incubation) API documentation