Write testcase for improved exception handling.

This commit is contained in:
baztian
2015-04-09 22:47:24 +02:00
parent 8f155ec318
commit a2ba0fb2b1
2 changed files with 16 additions and 0 deletions
@@ -13,6 +13,12 @@ public abstract class MockConnection implements Connection {
ResultSet mockResultSet;
public final void mockExceptionOnExecute(String exceptionMessage) throws SQLException {
PreparedStatement mockPreparedStatement = Mockito.mock(PreparedStatement.class);
Mockito.when(mockPreparedStatement.execute()).thenThrow(new SQLException(exceptionMessage));
Mockito.when(this.prepareStatement(Mockito.anyString())).thenReturn(mockPreparedStatement);
}
public final void mockType(String sqlTypesName) throws SQLException {
PreparedStatement mockPreparedStatement = Mockito.mock(PreparedStatement.class);
Mockito.when(mockPreparedStatement.execute()).thenReturn(true);