use of javax.resource.cci.Record in project spring-framework by spring-projects.
the class CciTemplateTests method testTemplateExecuteInputTrueTrue.
@Test
public void testTemplateExecuteInputTrueTrue() throws ResourceException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
Record inputOutputRecord = mock(Record.class);
InteractionSpec interactionSpec = mock(InteractionSpec.class);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(interaction.execute(interactionSpec, inputOutputRecord, inputOutputRecord)).willReturn(true);
CciTemplate ct = new CciTemplate(connectionFactory);
ct.execute(interactionSpec, inputOutputRecord, inputOutputRecord);
verify(interaction).execute(interactionSpec, inputOutputRecord, inputOutputRecord);
verify(interaction).close();
verify(connection).close();
}
use of javax.resource.cci.Record in project spring-framework by spring-projects.
the class CciTemplateTests method testTemplateExecuteInputExtractorFalse.
@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputExtractorFalse() throws ResourceException, SQLException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
RecordExtractor<Object> extractor = mock(RecordExtractor.class);
Record inputRecord = mock(Record.class);
Record outputRecord = mock(Record.class);
InteractionSpec interactionSpec = mock(InteractionSpec.class);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(interaction.execute(interactionSpec, inputRecord)).willReturn(outputRecord);
given(extractor.extractData(outputRecord)).willReturn(new Object());
CciTemplate ct = new CciTemplate(connectionFactory);
ct.execute(interactionSpec, inputRecord, extractor);
verify(extractor).extractData(outputRecord);
verify(interaction).close();
verify(connection).close();
}
Aggregations