diff --git a/src/test/java/ut/com/davidkoudela/crucible/persistence/HibernateSessionFactoryFactoryTest.java b/src/test/java/ut/com/davidkoudela/crucible/persistence/HibernateSessionFactoryFactoryTest.java index b0f7804..7db5031 100644 --- a/src/test/java/ut/com/davidkoudela/crucible/persistence/HibernateSessionFactoryFactoryTest.java +++ b/src/test/java/ut/com/davidkoudela/crucible/persistence/HibernateSessionFactoryFactoryTest.java @@ -1,6 +1,5 @@ package ut.com.davidkoudela.crucible.persistence; -import com.cenqua.crucible.hibernate.DBType; import com.cenqua.crucible.hibernate.DatabaseConfig; import com.davidkoudela.crucible.persistence.AdvancedLdapDatabaseConfigFactory; import com.davidkoudela.crucible.persistence.HibernateSessionFactoryFactory; @@ -9,8 +8,10 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; + /** * Description: Testing {@link HibernateSessionFactoryFactory} * Copyright (C) 2015 David Koudela @@ -33,4 +34,17 @@ public void testCreateHibernateSessionFactory() throws Exception { assertNotNull(sessionFactory); } + @Test(expected = Exception.class) + public void testCreateHibernateSessionFactoryException() throws Exception { + DatabaseConfig databaseConfig2 = Mockito.mock(DatabaseConfig.class); + Mockito.when(databaseConfig2.getJdbcDriverClass()).thenThrow(Exception.class); + HibernateSessionFactoryFactory.createHibernateSessionFactory(databaseConfig2); + } + + @Test(expected = Exception.class) + public void testCreateHibernateSessionFactoryThrowable() throws Exception { + DatabaseConfig databaseConfig2 = Mockito.mock(DatabaseConfig.class); + Mockito.when(databaseConfig2.getJdbcDriverClass()).thenThrow(Error.class); + HibernateSessionFactoryFactory.createHibernateSessionFactory(databaseConfig2); + } }