From 33149852e98a89a43dff6f253dd9f4113d59580c Mon Sep 17 00:00:00 2001 From: mkuppe Date: Mon, 20 Oct 2008 00:07:50 +0000 Subject: NEW - bug 251333: [Discovery][jSLP] Add test case for NullPatternLocator/Advertiser https://bugs.eclipse.org/bugs/show_bug.cgi?id=251333 --- .../ecf/tests/provider/jslp/JSLPDiscoveryTest.java | 37 ++++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'tests/bundles/org.eclipse.ecf.tests.provider.jslp') 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(); + } + } } } -- cgit v1.2.3