assertEquals(jpaEntityManager, jpaEntityManagerProvider.get());
}
@Test
public void testGetWithoutEntityManager() throws Exception {
final ConfigFile config = new ConfigFile(false);
config.getPersistenceProperties().put("javax.persistence.jdbc.driver", "org.apache.derby.jdbc.EmbeddedDriver");
config.getPersistenceProperties().put("javax.persistence.jdbc.url", "jdbc:derby:cmf;create=true");
new NonStrictExpectations() {{
CmfContext.getInstance(); result = cmfContext;
cmfContext.getConfigFile(); result = config;
Persistence.createEntityManagerFactory(EntityManagerProvider.PERSISTENCE_UNIT_NAME,
config.getPersistenceProperties()); result = entityManagerFactory;
entityManagerFactory.createEntityManager(); result = jpaEntityManager;
}};
JpaEntityManagerProvider jpaEntityManagerProvider = new JpaEntityManagerProvider();
assertEquals(jpaEntityManager, jpaEntityManagerProvider.get());