OSGI学习笔记(六)
?
?
public class SimpleServiceBundleTest extends AbstractConfigurableBundleCreatorTests {protected String[] getTestBundlesNames() {return new String[] {"org.springframework.osgi.samples, simple-service-bundle,1.2.1"};} public Resource getTestingFrameworkBundlesConfiguration() {return new InputStreamResource(AbstractDependencyManagerTests.class.getResourceAsStream("/boot-bundles.properties"));}public void testOSGiStartedOk() {assertNotNull(bundleContext); } public void testSimpleServiceExported() { ServiceReference ref = bundleContext.getServiceReference(MyService.class.getName()); assertNotNull("Service Reference is null", ref); try { MyService simpleService = (MyService) bundleContext.getService(ref); assertNotNull("Cannot find the service", simpleService); assertEquals("simple service at your service", simpleService.stringValue()); } finally { bundleContext.ungetService(ref); }}}
?
?可以尝试输入stop 10和start10试试看效果。
?