BundleContext context = bundle.getBundleContext();
ServiceReference sref = context.getServiceReference(SimpleService.class.getName());
assertNotNull("ServiceReference not null", sref);
// Get the service for the reference
SimpleService service = (SimpleService) context.getService(sref);
assertNotNull("Service not null", service);
// Invoke the service
int sum = service.sum(1, 2, 3);
assertEquals(6, sum);
// Stop the bundle
bundle.stop();
Assert.assertEquals(Bundle.RESOLVED, bundle.getState());