CompositePersistenceProviderResolver implements
		PersistenceProviderResolver { @Override public List<PersistenceProvider> getPersistenceProviders() { List<PersistenceProvider> defaultPersistenceProviders = defaultPersistenceProviderResolver .getPersistenceProviders(); List<PersistenceProvider> persistenceProviders = new ArrayList<PersistenceProvider>(); if (osgiPersistenceProviderResolver != null) { List<PersistenceProvider> osgiPersistenceProviders = osgiPersistenceProviderResolver .getPersistenceProviders(); for (PersistenceProvider provider : osgiPersistenceProviders) { persistenceProviders.add(provider); } } else { log(Level.FINEST, "Osgi Persistence Provider Resolver does not exist, getting persistence providers only from the default resolver"); } for (PersistenceProvider provider : defaultPersistenceProviders) { persistenceProviders.add(provider); } log(Level.FINEST, "Found " + persistenceProviders.size() + " PersistenceProviders"); return persistenceProviders; } CompositePersistenceProviderResolver(BundleContext context); @Override List<PersistenceProvider> getPersistenceProviders(); @Override void clearCachedProviders(); void removeOsgiProviderResolver();  }
@Test public void testGetPersistenceProviders() throws Exception { BundleContext context = EasyMock.createMock(BundleContext.class); CompositePersistenceProviderResolver compositePersistenceProviderResolver = new CompositePersistenceProviderResolver(context); List<PersistenceProvider> persistenceProviders = compositePersistenceProviderResolver.getPersistenceProviders(); Assert.assertEquals("Found Persistence Providers are not the correct number", 2, persistenceProviders.size()); Assert.assertEquals("First provider not OSGi Persistence Provider", persistenceProviders.get(0).getClass(), OSGiProviderResolver.class); Assert.assertEquals("Second provider not Test Persistence Provider", persistenceProviders.get(1).getClass(), TestPersistenceProvider.class); }