Search in sources :

Example 1 with ConnectionSpecConnectionFactoryAdapter

use of org.springframework.jca.cci.connection.ConnectionSpecConnectionFactoryAdapter in project spring-framework by spring-projects.

the class CciTemplateTests method testTemplateExecuteInputOutputConnectionSpec.

@Test
public void testTemplateExecuteInputOutputConnectionSpec() throws ResourceException {
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    ConnectionSpec connectionSpec = mock(ConnectionSpec.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(connectionSpec)).willReturn(connection);
    given(connection.createInteraction()).willReturn(interaction);
    given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);
    ConnectionSpecConnectionFactoryAdapter adapter = new ConnectionSpecConnectionFactoryAdapter();
    adapter.setTargetConnectionFactory(connectionFactory);
    adapter.setConnectionSpec(connectionSpec);
    CciTemplate ct = new CciTemplate(adapter);
    ct.execute(interactionSpec, inputRecord, outputRecord);
    verify(interaction).execute(interactionSpec, inputRecord, outputRecord);
    verify(interaction).close();
    verify(connection).close();
}
Also used : ConnectionFactory(javax.resource.cci.ConnectionFactory) ConnectionSpec(javax.resource.cci.ConnectionSpec) Interaction(javax.resource.cci.Interaction) InteractionSpec(javax.resource.cci.InteractionSpec) Connection(javax.resource.cci.Connection) MappedRecord(javax.resource.cci.MappedRecord) IndexedRecord(javax.resource.cci.IndexedRecord) Record(javax.resource.cci.Record) CciTemplate(org.springframework.jca.cci.core.CciTemplate) ConnectionSpecConnectionFactoryAdapter(org.springframework.jca.cci.connection.ConnectionSpecConnectionFactoryAdapter) Test(org.junit.Test)

Aggregations

Connection (javax.resource.cci.Connection)1 ConnectionFactory (javax.resource.cci.ConnectionFactory)1 ConnectionSpec (javax.resource.cci.ConnectionSpec)1 IndexedRecord (javax.resource.cci.IndexedRecord)1 Interaction (javax.resource.cci.Interaction)1 InteractionSpec (javax.resource.cci.InteractionSpec)1 MappedRecord (javax.resource.cci.MappedRecord)1 Record (javax.resource.cci.Record)1 Test (org.junit.Test)1 ConnectionSpecConnectionFactoryAdapter (org.springframework.jca.cci.connection.ConnectionSpecConnectionFactoryAdapter)1 CciTemplate (org.springframework.jca.cci.core.CciTemplate)1