@Test public void testCloseResultSet() throws SQLException { Logger log = Mockito.mock(Logger.class); boolean succes = DBUtil.close((ResultSet)null, log); assertTrue(succes); ResultSet rs = Mockito.mock(ResultSet.class); boolean succes2 = DBUtil.close(rs, log); assertTrue(succes2); ResultSet rsFail = Mockito.mock(ResultSet.class); Exception exception = new SQLException("test"); Mockito.doThrow(exception).when(rsFail).close(); boolean succes3 = DBUtil.close(rsFail, log); assertFalse(succes3); Mockito.verify(log).error("The resultset could not be closed!", exception); }
public static boolean close(ResultSet rs, Logger log) { boolean b = false; try { if(rs!=null) rs.close(); b = true; } catch (SQLException e) { log.error("The resultset could not be closed!", e); } return b; }
DBUtil { public static boolean close(ResultSet rs, Logger log) { boolean b = false; try { if(rs!=null) rs.close(); b = true; } catch (SQLException e) { log.error("The resultset could not be closed!", e); } return b; } }
DBUtil { public static boolean close(ResultSet rs, Logger log) { boolean b = false; try { if(rs!=null) rs.close(); b = true; } catch (SQLException e) { log.error("The resultset could not be closed!", e); } return b; } private  DBUtil(); }
DBUtil { public static boolean close(ResultSet rs, Logger log) { boolean b = false; try { if(rs!=null) rs.close(); b = true; } catch (SQLException e) { log.error("The resultset could not be closed!", e); } return b; } private  DBUtil(); static boolean close(ResultSet rs, Logger log); static void close(Connection conn, Logger log); }
DBUtil { public static boolean close(ResultSet rs, Logger log) { boolean b = false; try { if(rs!=null) rs.close(); b = true; } catch (SQLException e) { log.error("The resultset could not be closed!", e); } return b; } private  DBUtil(); static boolean close(ResultSet rs, Logger log); static void close(Connection conn, Logger log);  }