From 57dbaae999815f36eef4fda78b879256c7ce46a3 Mon Sep 17 00:00:00 2001 From: David Koudela Date: Fri, 20 Nov 2015 11:14:27 -0800 Subject: [PATCH] Added Unit Tests. --- .../HibernateSessionFactoryFactoryTest.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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); + } }