summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Liebig2008-03-12 08:54:45 (EDT)
committerStefan Liebig2008-03-12 08:54:45 (EDT)
commitdad2cd6ebd4c90446f727a99aa6ae970536655d4 (patch)
tree1a1f3881c1387450de77d1edf9c238c8dbf1bdb3
parent9da0e029ac14664ba6845d049334a066ad41a776 (diff)
downloadorg.eclipse.riena-dad2cd6ebd4c90446f727a99aa6ae970536655d4.zip
org.eclipse.riena-dad2cd6ebd4c90446f727a99aa6ae970536655d4.tar.gz
org.eclipse.riena-dad2cd6ebd4c90446f727a99aa6ae970536655d4.tar.bz2
added getContext() helper
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/tests/RienaTestCase.java19
1 files changed, 14 insertions, 5 deletions
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/tests/RienaTestCase.java b/org.eclipse.riena.tests/src/org/eclipse/riena/tests/RienaTestCase.java
index 6ca4022..e80a35e 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/tests/RienaTestCase.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/tests/RienaTestCase.java
@@ -41,6 +41,7 @@ public abstract class RienaTestCase extends TestCase {
// Keep track of services and and corresponding service references.
private Map<Object, ServiceReference> services = new HashMap<Object, ServiceReference>();
+ private BundleContext context = Activator.getContext();
/**
*
@@ -72,7 +73,7 @@ public abstract class RienaTestCase extends TestCase {
@Override
protected void tearDown() throws Exception {
for (ServiceReference reference : services.values())
- Activator.getContext().ungetService(reference);
+ context.ungetService(reference);
services.clear();
@@ -80,6 +81,15 @@ public abstract class RienaTestCase extends TestCase {
}
/**
+ * Return the bundle context.
+ *
+ * @return
+ */
+ protected BundleContext getContext() {
+ return context;
+ }
+
+ /**
* Print the current testīs name.
*/
protected void printTestName() {
@@ -138,10 +148,10 @@ public abstract class RienaTestCase extends TestCase {
*/
@SuppressWarnings("unchecked")
protected <T> T getService(Class<T> serviceClass) {
- ServiceReference reference = Activator.getContext().getServiceReference(serviceClass.getName());
+ ServiceReference reference = context.getServiceReference(serviceClass.getName());
if (reference == null)
return null;
- Object service = Activator.getContext().getService(reference);
+ Object service = context.getService(reference);
if (service == null)
return null;
services.put(service, reference);
@@ -157,7 +167,7 @@ public abstract class RienaTestCase extends TestCase {
ServiceReference reference = services.get(service);
if (reference == null)
return;
- Activator.getContext().ungetService(reference);
+ context.ungetService(reference);
}
/**
@@ -252,7 +262,6 @@ public abstract class RienaTestCase extends TestCase {
}
Pattern inlcude = Pattern.compile(includePattern);
Pattern exclude = Pattern.compile(excludePattern);
- BundleContext context = Activator.getContext();
Bundle[] bundles = context.getBundles();
for (Bundle bundle : bundles)