import org.junit.Test; import org.junit.runner.RunWith; import org.osgi.test.common.context.CloseableBundleContext; import org.osgi.test.junit4.context.BundleContextRule; @RunWith(OsgiTestRunner.class) public class MyLibraryTest { @Rule public final BundleContextRule contextRule = new BundleContextRule(); @Test public void testHelloService() throws Exception { try (CloseableBundleContext context = contextRule.get()) { context.installBundle("path/to/my-module.jar").start(); MyService myService = context.getService(MyService.class); assertNotNull(myService); assertEquals("Hello, OSGi!", myService.getMessage()); } } }


上一篇:
下一篇:
切换中文