|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
org.apache.felix.ipojo.junit4osgi.OSGiTestCase
public class OSGiTestCase
OSGi Test Case. Allows the injection of the bundle context.
Field Summary | |
---|---|
protected BundleContext |
context
The bundle context. |
Constructor Summary | |
---|---|
OSGiTestCase()
|
Method Summary | |
---|---|
void |
addHelper(Helper helper)
Add an helper. |
static void |
assertContains(String message,
byte[] array,
int num)
Checks that the given integer is contained in the given array. |
static void |
assertContains(String message,
char[] array,
char character)
Checks that the given character is contained in the given array. |
static void |
assertContains(String message,
double[] array,
double num)
Checks that the given double is contained in the given array. |
static void |
assertContains(String message,
float[] array,
float num)
Checks that the given float is contained in the given array. |
static void |
assertContains(String message,
int[] array,
int num)
Checks that the given integer is contained in the given array. |
static void |
assertContains(String message,
long[] array,
long num)
Checks that the given long is contained in the given array. |
static void |
assertContains(String message,
short[] array,
int num)
Checks that the given integer is contained in the given array. |
static void |
assertContains(String message,
String[] array,
String txt)
Checks that the given string is contained in the given array. |
static void |
assertEquals(String message,
double expected,
double actual)
Asserts that two doubles are equal. |
static void |
assertNotEquals(String message,
Object o1,
Object o2)
Asserts that two objects are not equal. |
static boolean |
contains(int value,
int[] array)
Checks that the given integer is contained in the given array. |
static boolean |
contains(String string,
String[] array)
Checks that the given string is contained in the given array. |
Bundle |
getBundle(long bundleId)
Get the bundle by its id. |
Bundle |
getBundle(String name)
Gets a bundle by its symbolic name. |
BundleContext |
getBundleContext()
|
BundleContext |
getContext()
Gets the Bundle Context. |
PackageAdmin |
getPackageAdmin()
Gets the package admin exposed by the framework. |
static Object |
getServiceObject(Bundle bundle,
String itf,
String filter)
Returns the service object of a service provided by the specified bundle, offering the specified interface and matching the given filter. |
Object |
getServiceObject(ServiceReference ref)
Returns the service object associated with this service reference. |
Object |
getServiceObject(String itf,
String filter)
Returns the service object of a service provided by the local bundle, offering the specified interface and matching the given filter. |
static Object[] |
getServiceObjects(Bundle bundle,
String itf,
String filter)
Returns the service objects of the services provided by the specified bundle, offering the specified interface and matching the given filter. |
Object[] |
getServiceObjects(String itf,
String filter)
Returns the service objects of the services provided by the local bundle, offering the specified interface and matching the given filter. |
static ServiceReference |
getServiceReference(Bundle bundle,
String itf,
String filter)
Returns the service reference of a service provided by the specified bundle, offering the specified interface and matching the given filter. |
ServiceReference |
getServiceReference(String itf)
Returns the service reference of a service provided offering the specified interface. |
ServiceReference |
getServiceReference(String itf,
String filter)
Returns the service reference of a service provided by the local bundle, offering the specified interface and matching the given filter. |
static ServiceReference |
getServiceReferenceByPID(Bundle bundle,
String itf,
String pid)
Returns the service reference of the service provided by the specified bundle, offering the specified interface and having the given persistent ID. |
ServiceReference |
getServiceReferenceByPID(String itf,
String pid)
Returns the service reference of the service provided by the local bundle, offering the specified interface and having the given persistent ID. |
static ServiceReference[] |
getServiceReferences(Bundle bundle,
String itf,
String filter)
Returns the service reference of all the services provided in the specified bundle, offering the specified interface and matching the given filter. |
ServiceReference[] |
getServiceReferences(String itf,
String filter)
Returns the service reference of all the services provided in the local bundle, offering the specified interface and matching the given filter. |
Bundle |
installAndStart(String url)
Installs and starts a bundle. |
Bundle |
installAndStart(String url,
InputStream stream)
Installs and starts a bundle. |
Bundle |
installBundle(String url)
Installs a bundle. |
Bundle |
installBundle(String url,
InputStream stream)
Installs a bundle. |
boolean |
isServiceAvailable(String itf)
Checks if the service is available. |
boolean |
isServiceAvailableByPID(String itf,
String pid)
Checks if the service is available. |
void |
refresh()
Refresh the packages. |
void |
runBare()
Extends runBare to release (unget) services after the teardown. |
void |
setBundleContext(BundleContext bc)
|
void |
waitForService(String itf,
String filter,
long timeout)
Waits for a service. |
Methods inherited from class junit.framework.TestCase |
---|
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runTest, setName, setUp, tearDown, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected BundleContext context
Constructor Detail |
---|
public OSGiTestCase()
Method Detail |
---|
public BundleContext getContext()
public void addHelper(Helper helper)
Helper.Helper(OSGiTestCase)
method.
helper
- the helper object.public void runBare() throws Throwable
runBare
in class junit.framework.TestCase
Throwable
- when an error occurs.TestCase.runBare()
public void setBundleContext(BundleContext bc)
public BundleContext getBundleContext()
public static void assertContains(String message, String[] array, String txt)
message
- the assert point messagearray
- the String arraytxt
- the String to searchpublic static void assertContains(String message, byte[] array, int num)
message
- the assert point messagearray
- the byte arraynum
- the number to searchpublic static void assertContains(String message, short[] array, int num)
message
- the assert point messagearray
- the short arraynum
- the number to searchpublic static void assertContains(String message, int[] array, int num)
message
- the assert point messagearray
- the integer arraynum
- the number to searchpublic static void assertContains(String message, long[] array, long num)
message
- the assert point messagearray
- the long arraynum
- the number to searchpublic static void assertContains(String message, float[] array, float num)
message
- the assert point messagearray
- the float arraynum
- the number to searchpublic static void assertContains(String message, double[] array, double num)
message
- the assert point messagearray
- the double arraynum
- the number to searchpublic static void assertContains(String message, char[] array, char character)
message
- the assert point messagearray
- the character arraycharacter
- the character to searchpublic static void assertEquals(String message, double expected, double actual)
message
- the assert point messageexpected
- the expected doubleactual
- the received doublepublic static void assertNotEquals(String message, Object o1, Object o2)
message
- the assert point messageo1
- the unexpected objecto2
- the received objectpublic static boolean contains(String string, String[] array)
string
- the String to searcharray
- the String array
true
if the array contains the stringpublic static boolean contains(int value, int[] array)
value
- the number to searcharray
- the integer array
true
if the array contains the valuepublic static Object getServiceObject(Bundle bundle, String itf, String filter)
bundle
- the bundle from which the service is searched.itf
- the interface provided by the searched service.filter
- an additional filter (can be null
).
public static Object[] getServiceObjects(Bundle bundle, String itf, String filter)
bundle
- the bundle from which services are searched.itf
- the interface provided by the searched services.filter
- an additional filter (can be null
).
public static ServiceReference getServiceReference(Bundle bundle, String itf, String filter)
bundle
- the bundle from which the service is searched.itf
- the interface provided by the searched service.filter
- an additional filter (can be null
).
null
is returned.public boolean isServiceAvailable(String itf)
itf
- the service interface
true
if the service is available, false
otherwise.public boolean isServiceAvailableByPID(String itf, String pid)
itf
- the service interfacepid
- the service pid
true
if the service is available, false
otherwise.public static ServiceReference getServiceReferenceByPID(Bundle bundle, String itf, String pid)
bundle
- the bundle from which the service is searched.itf
- the interface provided by the searched service.pid
- the persistent ID of the searched service.
public static ServiceReference[] getServiceReferences(Bundle bundle, String itf, String filter)
bundle
- the bundle from which services are searched.itf
- the interface provided by the searched services.filter
- an additional filter (can be null
).
public Object getServiceObject(String itf, String filter)
itf
- the interface provided by the searched service.filter
- an additional filter (can be null
).
public Object getServiceObject(ServiceReference ref)
ref
- service reference
public Object[] getServiceObjects(String itf, String filter)
itf
- the interface provided by the searched services.filter
- an additional filter (can be null
).
public ServiceReference getServiceReference(String itf, String filter)
itf
- the interface provided by the searched service.filter
- an additional filter (can be null
).
null
is returned.public ServiceReference getServiceReference(String itf)
itf
- the interface provided by the searched service.
null
is returned.public ServiceReference getServiceReferenceByPID(String itf, String pid)
itf
- the interface provided by the searched service.pid
- the persistent ID of the searched service.
public ServiceReference[] getServiceReferences(String itf, String filter)
itf
- the interface provided by the searched services.filter
- an additional filter (can be null
).
public PackageAdmin getPackageAdmin()
public void refresh()
public void waitForService(String itf, String filter, long timeout)
itf
- the service interfacefilter
- the filtertimeout
- the timeoutpublic Bundle installBundle(String url)
url
- bundle url
public Bundle installBundle(String url, InputStream stream)
url
- bundle urlstream
- input stream containing the bundle
public Bundle installAndStart(String url)
url
- the bundle url
public Bundle installAndStart(String url, InputStream stream)
url
- the bundle urlstream
- input stream containing the bundle
public Bundle getBundle(long bundleId)
bundleId
- the bundle id.
public Bundle getBundle(String name)
name
- the symbolic name of the bundle
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |