Skip to content

Commit

Permalink
Added Unit Tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoudela committed Nov 20, 2015
1 parent f5fbe2d commit 57dbaae
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand All @@ -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);
}
}

0 comments on commit 57dbaae

Please # to comment.