/** * Close the given CCI ResultSet and ignore any thrown exception. * This is useful for typical finally blocks in manual CCI code. * @param resultSet the CCI ResultSet to close * @see javax.resource.cci.ResultSet#close() */ private void closeResultSet(@Nullable ResultSet resultSet) { if (resultSet != null) { try { resultSet.close(); } catch (SQLException ex) { logger.trace("Could not close CCI ResultSet", ex); } catch (Throwable ex) { // We don't trust the CCI driver: It might throw RuntimeException or Error. logger.trace("Unexpected exception on closing CCI ResultSet", ex); } } }
/** * Close the given CCI ResultSet and ignore any thrown exception. * This is useful for typical finally blocks in manual CCI code. * @param resultSet the CCI ResultSet to close * @see javax.resource.cci.ResultSet#close() */ private void closeResultSet(@Nullable ResultSet resultSet) { if (resultSet != null) { try { resultSet.close(); } catch (SQLException ex) { logger.trace("Could not close CCI ResultSet", ex); } catch (Throwable ex) { // We don't trust the CCI driver: It might throw RuntimeException or Error. logger.trace("Unexpected exception on closing CCI ResultSet", ex); } } }
@SuppressWarnings("unchecked") @Test public void testTemplateExecuteInputOutputResultsSetFalse() throws ResourceException, SQLException { ConnectionFactory connectionFactory = mock(ConnectionFactory.class); RecordFactory recordFactory = mock(RecordFactory.class); Connection connection = mock(Connection.class); Interaction interaction = mock(Interaction.class); Record record = mock(Record.class); ResultSet resultset = mock(ResultSet.class); RecordCreator generator = mock(RecordCreator.class); RecordExtractor<Object> extractor = mock(RecordExtractor.class); InteractionSpec interactionSpec = mock(InteractionSpec.class); given(connectionFactory.getRecordFactory()).willReturn(recordFactory); given(connectionFactory.getConnection()).willReturn(connection); given(connection.createInteraction()).willReturn(interaction); given(generator.createRecord(recordFactory)).willReturn(record); given(interaction.execute(interactionSpec, record)).willReturn(resultset); given(extractor.extractData(resultset)).willReturn(new Object()); CciTemplate ct = new CciTemplate(connectionFactory); ct.execute(interactionSpec, generator, extractor); verify(extractor).extractData(resultset); verify(resultset).close(); verify(interaction).close(); verify(connection).close(); }
/** * Close the given CCI ResultSet and ignore any thrown exception. * This is useful for typical finally blocks in manual CCI code. * @param resultSet the CCI ResultSet to close * @see javax.resource.cci.ResultSet#close() */ private void closeResultSet(@Nullable ResultSet resultSet) { if (resultSet != null) { try { resultSet.close(); } catch (SQLException ex) { logger.trace("Could not close CCI ResultSet", ex); } catch (Throwable ex) { // We don't trust the CCI driver: It might throw RuntimeException or Error. logger.trace("Unexpected exception on closing CCI ResultSet", ex); } } }
/** * Close the given CCI ResultSet and ignore any thrown exception. * This is useful for typical finally blocks in manual CCI code. * @param resultSet the CCI ResultSet to close * @see javax.resource.cci.ResultSet#close() */ private void closeResultSet(@Nullable ResultSet resultSet) { if (resultSet != null) { try { resultSet.close(); } catch (SQLException ex) { logger.trace("Could not close CCI ResultSet", ex); } catch (Throwable ex) { // We don't trust the CCI driver: It might throw RuntimeException or Error. logger.trace("Unexpected exception on closing CCI ResultSet", ex); } } }