Skip to content

Instantly share code, notes, and snippets.

@sebersole
Created September 23, 2019 21:57
Show Gist options
  • Save sebersole/7efa39414409e93af484c0f25edd9825 to your computer and use it in GitHub Desktop.
Save sebersole/7efa39414409e93af484c0f25edd9825 to your computer and use it in GitHub Desktop.
@Test
public void testCustomProviderPassingIntegrationOverrides() {
PersistenceProvider provider = new HibernatePersistence() {
@Override
public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info, Map properties) {
properties.putAll( ConnectionProviderBuilder.getConnectionProviderProperties() );
return super.createContainerEntityManagerFactory( info, properties );
}
};
final EntityManagerFactory emf = provider.createContainerEntityManagerFactory(
new PersistenceUnitInfoAdapter(),
new HashMap()
);
try {
final Map<String, Object> properties = emf.getProperties();
final Object jpaJdbcDriver = properties.get( AvailableSettings.JDBC_DRIVER );
assertThat( jpaJdbcDriver, notNullValue() );
final Object hibernateJdbcDriver = properties.get( org.hibernate.cfg.AvailableSettings.DRIVER );
assertThat( hibernateJdbcDriver, notNullValue() );
}
finally {
emf.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment