MySQLDataSourceChecker extends AbstractDataSourceChecker { @Override public void checkVariable(final Collection<? extends DataSource> dataSources) { for (DataSource each : dataSources) { checkVariable(each); } }  @Override void checkPrivilege(final Collection<? extends DataSource> dataSources); @Override void checkVariable(final Collection<? extends DataSource> dataSources);  }
@Test public void assertCheckVariableSuccess() throws SQLException { when(resultSet.next()).thenReturn(true, true); when(resultSet.getString(2)).thenReturn("ON", "ROW"); dataSourceChecker.checkVariable(dataSources); verify(preparedStatement, Mockito.times(2)).executeQuery(); }
@Test(expected = PrepareFailedException.class) public void assertCheckVariableWithWrongVariable() throws SQLException { when(resultSet.next()).thenReturn(true, true); when(resultSet.getString(2)).thenReturn("OFF", "ROW"); dataSourceChecker.checkVariable(dataSources); }
@Test(expected = PrepareFailedException.class) public void assertCheckVariableFailure() throws SQLException { when(resultSet.next()).thenThrow(new SQLException("")); dataSourceChecker.checkVariable(dataSources); }