RepositoryManager { @Deactivate public void deactivate() { if (registration != null) { registration.unregister(); registration = null; } if (repository != null) { repository.shutdown(); repository = null; } initializers.stop(); indexProvider.stop(); indexEditorProvider.stop(); editorProvider.stop(); }  @Activate void activate(BundleContext bundleContext, Map<String, ?> config); @Deactivate void deactivate();  }
@Test public void repositoryShutdown() throws Exception{ registerRequiredServices(); RepositoryManager mgr = context.registerInjectActivateService(new RepositoryManager()); assertNotNull("MBean should be registered", context.getService(RepositoryManagementMBean.class)); mgr.deactivate(); assertNull("MBean should have been removed upon repository shutdown", context.getService(RepositoryManagementMBean.class)); }