use of javax.resource.cci.Connection in project spring-framework by spring-projects.
the class EisOperationTests method testMappingRecordOperationWithOutputRecordCreator.
@Test
public void testMappingRecordOperationWithOutputRecordCreator() throws ResourceException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
RecordFactory recordFactory = mock(RecordFactory.class);
Record inputRecord = mock(Record.class);
Record outputRecord = mock(Record.class);
RecordCreator outputCreator = mock(RecordCreator.class);
InteractionSpec interactionSpec = mock(InteractionSpec.class);
QueryCallDetector callDetector = mock(QueryCallDetector.class);
MappingRecordOperationImpl query = new MappingRecordOperationImpl(connectionFactory, interactionSpec);
query.setOutputRecordCreator(outputCreator);
query.setCallDetector(callDetector);
Object inObj = new Object();
Object outObj = new Object();
given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
given(callDetector.callCreateInputRecord(recordFactory, inObj)).willReturn(inputRecord);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
given(outputCreator.createRecord(recordFactory)).willReturn(outputRecord);
given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);
given(callDetector.callExtractOutputData(outputRecord)).willReturn(outObj);
assertSame(outObj, query.execute(inObj));
verify(interaction).close();
verify(connection).close();
}
use of javax.resource.cci.Connection in project spring-framework by spring-projects.
the class EisOperationTests method testSimpleRecordOperationWithExplicitOutputRecord.
@Test
public void testSimpleRecordOperationWithExplicitOutputRecord() throws ResourceException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
Record inputRecord = mock(Record.class);
Record outputRecord = mock(Record.class);
InteractionSpec interactionSpec = mock(InteractionSpec.class);
SimpleRecordOperation operation = new SimpleRecordOperation(connectionFactory, interactionSpec);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);
operation.execute(inputRecord, outputRecord);
verify(interaction).execute(interactionSpec, inputRecord, outputRecord);
verify(interaction).close();
verify(connection).close();
}
use of javax.resource.cci.Connection in project spring-framework by spring-projects.
the class CciTemplateTests method testTemplateExecuteInputGeneratorTrueWithCreator.
@Test
public void testTemplateExecuteInputGeneratorTrueWithCreator() throws ResourceException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
RecordFactory recordFactory = mock(RecordFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
RecordCreator generator = mock(RecordCreator.class);
RecordCreator creator = mock(RecordCreator.class);
Record inputRecord = mock(Record.class);
Record outputRecord = mock(Record.class);
InteractionSpec interactionSpec = mock(InteractionSpec.class);
given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
given(generator.createRecord(recordFactory)).willReturn(inputRecord);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(creator.createRecord(recordFactory)).willReturn(outputRecord);
given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);
CciTemplate ct = new CciTemplate(connectionFactory);
ct.setOutputRecordCreator(creator);
ct.execute(interactionSpec, generator);
verify(interaction).execute(interactionSpec, inputRecord, outputRecord);
verify(interaction).close();
verify(connection).close();
}
use of javax.resource.cci.Connection in project spring-framework by spring-projects.
the class CciTemplateTests method testTemplateExecuteInputOutput.
@Test
public void testTemplateExecuteInputOutput() throws ResourceException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.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, outputRecord)).willReturn(true);
CciTemplate ct = new CciTemplate(connectionFactory);
ct.execute(interactionSpec, inputRecord, outputRecord);
verify(interaction).execute(interactionSpec, inputRecord, outputRecord);
verify(interaction).close();
verify(connection).close();
}
use of javax.resource.cci.Connection in project spring-framework by spring-projects.
the class CciTemplateTests method testTemplateExecuteInputTrueWithCreator2.
@Test
public void testTemplateExecuteInputTrueWithCreator2() throws ResourceException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
RecordFactory recordFactory = mock(RecordFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
RecordCreator creator = mock(RecordCreator.class);
Record inputRecord = mock(Record.class);
final Record outputRecord = mock(Record.class);
InteractionSpec interactionSpec = mock(InteractionSpec.class);
given(connectionFactory.getConnection()).willReturn(connection);
given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
given(connection.createInteraction()).willReturn(interaction);
given(creator.createRecord(recordFactory)).willReturn(outputRecord);
given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);
CciTemplate ct = new CciTemplate(connectionFactory);
ct.setOutputRecordCreator(creator);
ct.execute(interactionSpec, inputRecord);
verify(interaction).execute(interactionSpec, inputRecord, outputRecord);
verify(interaction).close();
verify(connection).close();
}
Aggregations