Search in sources :

Example 1 with NotSupportedRecordFactory

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

the class CciTemplateTests method testTemplateExecuteWithCreatorAndRecordFactoryNotSupported.

@Test
public void testTemplateExecuteWithCreatorAndRecordFactoryNotSupported() throws ResourceException {
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    Connection connection = mock(Connection.class);
    Interaction interaction = mock(Interaction.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()).willThrow(new NotSupportedException("not supported"));
    given(connection.createInteraction()).willReturn(interaction);
    given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);
    CciTemplate ct = new CciTemplate(connectionFactory);
    ct.setOutputRecordCreator(new RecordCreator() {

        @Override
        public Record createRecord(RecordFactory recordFactory) {
            assertTrue(recordFactory instanceof NotSupportedRecordFactory);
            return outputRecord;
        }
    });
    ct.execute(interactionSpec, inputRecord);
    verify(interaction).execute(interactionSpec, inputRecord, outputRecord);
    verify(interaction).close();
    verify(connection).close();
}
Also used : ConnectionFactory(javax.resource.cci.ConnectionFactory) RecordFactory(javax.resource.cci.RecordFactory) NotSupportedRecordFactory(org.springframework.jca.cci.connection.NotSupportedRecordFactory) Interaction(javax.resource.cci.Interaction) InteractionSpec(javax.resource.cci.InteractionSpec) RecordCreator(org.springframework.jca.cci.core.RecordCreator) Connection(javax.resource.cci.Connection) NotSupportedRecordFactory(org.springframework.jca.cci.connection.NotSupportedRecordFactory) MappedRecord(javax.resource.cci.MappedRecord) IndexedRecord(javax.resource.cci.IndexedRecord) Record(javax.resource.cci.Record) CciTemplate(org.springframework.jca.cci.core.CciTemplate) NotSupportedException(javax.resource.NotSupportedException) Test(org.junit.Test)

Aggregations

NotSupportedException (javax.resource.NotSupportedException)1 Connection (javax.resource.cci.Connection)1 ConnectionFactory (javax.resource.cci.ConnectionFactory)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 RecordFactory (javax.resource.cci.RecordFactory)1 Test (org.junit.Test)1 NotSupportedRecordFactory (org.springframework.jca.cci.connection.NotSupportedRecordFactory)1 CciTemplate (org.springframework.jca.cci.core.CciTemplate)1 RecordCreator (org.springframework.jca.cci.core.RecordCreator)1