public class MyModule implements ModuleActivator {
@Override
public void start(BundleContext context) throws Exception {
}
@Override
public void stop(BundleContext context) throws Exception {
}
}
Bundle bundle = context.installBundle("file:mybundle.jar");
bundle.start();
bundle.update(new FileInputStream("newbundle.jar"));
Dictionary<String, Object> properties = new Hashtable<>();
properties.put("service.name", "myService");
context.registerService(MyService.class.getName(), new MyServiceImpl(), properties);
ServiceReference<MyService> reference = context.getServiceReference(MyService.class);
MyService myService = context.getService(reference);
@Test
public void testMyModule() {
MyModule module = new MyModule();
module.start(mock(BundleContext.class));
module.stop(mock(BundleContext.class));
}