HHH-8897 : Corrected DataSourceInjectionTest

This commit is contained in:
Gail Badner 2014-01-30 13:35:40 -08:00
parent fdc3b3b009
commit 62631f7a58
1 changed files with 13 additions and 4 deletions

View File

@ -24,10 +24,15 @@ package org.hibernate.jpa.test.connection;
import java.io.File; import java.io.File;
import org.junit.Assert; import javax.persistence.EntityManagerFactory;
import org.junit.Test; import org.junit.Test;
import org.hibernate.ejb.HibernatePersistence; import org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.jpa.HibernatePersistenceProvider;
import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
@ -40,8 +45,12 @@ public class DataSourceInjectionTest {
sub.mkdir(); sub.mkdir();
PersistenceUnitInfoImpl info = new PersistenceUnitInfoImpl( sub.toURI().toURL(), new String[]{} ); PersistenceUnitInfoImpl info = new PersistenceUnitInfoImpl( sub.toURI().toURL(), new String[]{} );
try { try {
new HibernatePersistence().createContainerEntityManagerFactory( info, null ); EntityManagerFactory emf = new HibernatePersistenceProvider().createContainerEntityManagerFactory( info, null );
Assert.fail( "FakeDatasource should have been used" ); DatasourceConnectionProviderImpl cp = assertTyping(
DatasourceConnectionProviderImpl.class,
emf.unwrap( SessionFactoryImplementor.class ).getConnectionProvider()
);
assertTyping( FakeDataSource.class, cp.getDataSource() );
} }
catch (FakeDataSourceException fde) { catch (FakeDataSourceException fde) {
//success //success