Activator implements BundleActivator { public void stop(BundleContext bundleContext) throws Exception { providerResolver.removeOsgiProviderResolver(); if (logger.isDebugEnabled()) { logger.debug("Removed OSGiPersistenceProvider from CompositePersistenceProviderResolver created"); } }  void start(BundleContext bundleContext); void stop(BundleContext bundleContext);  }
@Test public void testStop() throws Exception { BundleContext context = EasyMock.createMock(BundleContext.class); Activator activator = new Activator(); activator.start(context); PersistenceProviderResolver providerResolver = PersistenceProviderResolverHolder.getPersistenceProviderResolver(); Assert.assertNotNull("PersistenceProviderResolver not set", providerResolver); Assert.assertTrue("PersistenceProviderResolver not of the correct type. Expected com.sap.core.services.accessor.javax.persistence.extension.CompositePersistenceProviderResolver, but actually is [" + providerResolver.getClass().getName() + "]", (providerResolver instanceof CompositePersistenceProviderResolver)); activator.stop(context); List<PersistenceProvider> providers = providerResolver.getPersistenceProviders(); Assert.assertEquals("There should be no persistence providers", 0, providers.size()); }