Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkuppe2008-10-19 20:07:50 -0400
committermkuppe2008-10-19 20:07:50 -0400
commit33149852e98a89a43dff6f253dd9f4113d59580c (patch)
tree3159de2e7e2120398b81e1e267c1d54f36a4a054 /tests/bundles/org.eclipse.ecf.tests.provider.jslp
parent94e23bc1440e04a46abd476c9d16563ca88ab954 (diff)
downloadorg.eclipse.ecf-33149852e98a89a43dff6f253dd9f4113d59580c.tar.gz
org.eclipse.ecf-33149852e98a89a43dff6f253dd9f4113d59580c.tar.xz
org.eclipse.ecf-33149852e98a89a43dff6f253dd9f4113d59580c.zip
NEW - bug 251333: [Discovery][jSLP] Add test case for NullPatternLocator/Advertiserv20081020-0800
https://bugs.eclipse.org/bugs/show_bug.cgi?id=251333
Diffstat (limited to 'tests/bundles/org.eclipse.ecf.tests.provider.jslp')
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/JSLPDiscoveryTest.java37
1 files changed, 34 insertions, 3 deletions
diff --git a/tests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/JSLPDiscoveryTest.java b/tests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/JSLPDiscoveryTest.java
index d392b8e3f..1c93f0981 100755
--- a/tests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/JSLPDiscoveryTest.java
+++ b/tests/bundles/org.eclipse.ecf.tests.provider.jslp/src/org/eclipse/ecf/tests/provider/jslp/JSLPDiscoveryTest.java
@@ -10,8 +10,14 @@
******************************************************************************/
package org.eclipse.ecf.tests.provider.jslp;
+import org.eclipse.ecf.internal.provider.jslp.NullPatternAdvertiser;
+import org.eclipse.ecf.internal.provider.jslp.NullPatternLocator;
import org.eclipse.ecf.provider.jslp.container.JSLPDiscoveryContainer;
+import org.eclipse.ecf.tests.discovery.Activator;
import org.eclipse.ecf.tests.discovery.DiscoveryTest;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
public class JSLPDiscoveryTest extends DiscoveryTest {
@@ -39,8 +45,33 @@ public class JSLPDiscoveryTest extends DiscoveryTest {
setScope("default");
}
- public void testJSLPBundleBecomesUnavailable() {
- // dynamic OSGi!
- fail("not yet implemtend");
+ /**
+ * Test that the {@link NullPatternLocator} and {@link NullPatternAdvertiser} take
+ * over when the jSLP bundle gets stopped and that the SLP provider handles this gracefully
+ * @throws BundleException
+ */
+ public void testJSLPBundleBecomesUnavailable() throws BundleException {
+ Bundle bundle = null;
+ try {
+ // stop the bundle assuming there is only one installed
+ BundleContext context = Activator.getDefault().getContext();
+ Bundle[] bundles = context.getBundles();
+ for(int i = 0; i < bundles.length; i++) {
+ Bundle aBundle = bundles[i];
+ if(aBundle.getSymbolicName().equals("ch.ethz.iks.slp")) {
+ bundle = aBundle;
+ break;
+ }
+ }
+ assertNotNull("ch.ethz.iks.slp bundle not found", bundle);
+ assertTrue(bundle.getState() == Bundle.ACTIVE);
+ bundle.stop();
+ assertTrue(bundle.getState() == Bundle.RESOLVED);
+ assertEquals("No service should have been found since NullPatternLocator is active", discoveryContainer.getServices().length, 0);
+ } finally {
+ if(bundle != null) {
+ bundle.start();
+ }
+ }
}
}

Back to the top