Search in sources :

Example 1 with RecordFactory

use of javax.resource.cci.RecordFactory in project spring-framework by spring-projects.

the class CciTemplateTests method testTemplateExecuteInputExtractorTrueWithCreator.

@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputExtractorTrueWithCreator() throws ResourceException, SQLException {
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    RecordFactory recordFactory = mock(RecordFactory.class);
    Connection connection = mock(Connection.class);
    Interaction interaction = mock(Interaction.class);
    RecordExtractor<Object> extractor = mock(RecordExtractor.class);
    RecordCreator creator = mock(RecordCreator.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(connectionFactory.getRecordFactory()).willReturn(recordFactory);
    given(creator.createRecord(recordFactory)).willReturn(outputRecord);
    given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);
    given(extractor.extractData(outputRecord)).willReturn(new Object());
    CciTemplate ct = new CciTemplate(connectionFactory);
    ct.setOutputRecordCreator(creator);
    ct.execute(interactionSpec, inputRecord, extractor);
    verify(extractor).extractData(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) RecordCreator(org.springframework.jca.cci.core.RecordCreator) 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) Test(org.junit.Test)

Example 2 with RecordFactory

use of javax.resource.cci.RecordFactory 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)

Example 3 with RecordFactory

use of javax.resource.cci.RecordFactory in project spring-framework by spring-projects.

the class CciTemplateTests method testTemplateExecuteInputGeneratorExtractorTrueWithCreator.

@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputGeneratorExtractorTrueWithCreator() throws ResourceException, SQLException {
    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);
    RecordExtractor<Object> extractor = mock(RecordExtractor.class);
    RecordCreator creator = mock(RecordCreator.class);
    Record inputRecord = mock(Record.class);
    Record outputRecord = mock(Record.class);
    Object obj = new Object();
    InteractionSpec interactionSpec = mock(InteractionSpec.class);
    given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
    given(connectionFactory.getConnection()).willReturn(connection);
    given(connection.createInteraction()).willReturn(interaction);
    given(creator.createRecord(recordFactory)).willReturn(outputRecord);
    given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
    given(generator.createRecord(recordFactory)).willReturn(inputRecord);
    given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);
    given(extractor.extractData(outputRecord)).willReturn(obj);
    CciTemplate ct = new CciTemplate(connectionFactory);
    ct.setOutputRecordCreator(creator);
    assertEquals(obj, ct.execute(interactionSpec, generator, extractor));
    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) RecordCreator(org.springframework.jca.cci.core.RecordCreator) 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) Test(org.junit.Test)

Example 4 with RecordFactory

use of javax.resource.cci.RecordFactory in project spring-framework by spring-projects.

the class CciTemplateTests method testCreateIndexedRecord.

@Test
public void testCreateIndexedRecord() throws ResourceException {
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    RecordFactory recordFactory = mock(RecordFactory.class);
    IndexedRecord indexedRecord = mock(IndexedRecord.class);
    given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
    given(recordFactory.createIndexedRecord("name")).willReturn(indexedRecord);
    CciTemplate ct = new CciTemplate(connectionFactory);
    ct.createIndexedRecord("name");
    verify(recordFactory).createIndexedRecord("name");
}
Also used : ConnectionFactory(javax.resource.cci.ConnectionFactory) RecordFactory(javax.resource.cci.RecordFactory) NotSupportedRecordFactory(org.springframework.jca.cci.connection.NotSupportedRecordFactory) IndexedRecord(javax.resource.cci.IndexedRecord) CciTemplate(org.springframework.jca.cci.core.CciTemplate) Test(org.junit.Test)

Example 5 with RecordFactory

use of javax.resource.cci.RecordFactory in project spring-framework by spring-projects.

the class CciTemplateTests method testTemplateExecuteInputGeneratorExtractorFalse.

@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputGeneratorExtractorFalse() throws ResourceException, SQLException {
    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);
    RecordExtractor<Object> extractor = mock(RecordExtractor.class);
    Record inputRecord = mock(Record.class);
    Record outputRecord = mock(Record.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(inputRecord);
    given(interaction.execute(interactionSpec, inputRecord)).willReturn(outputRecord);
    given(extractor.extractData(outputRecord)).willReturn(new Object());
    CciTemplate ct = new CciTemplate(connectionFactory);
    ct.execute(interactionSpec, generator, extractor);
    verify(extractor).extractData(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) RecordCreator(org.springframework.jca.cci.core.RecordCreator) 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) Test(org.junit.Test)

Aggregations

ConnectionFactory (javax.resource.cci.ConnectionFactory)12 RecordFactory (javax.resource.cci.RecordFactory)12 Test (org.junit.Test)12 Connection (javax.resource.cci.Connection)10 Interaction (javax.resource.cci.Interaction)10 InteractionSpec (javax.resource.cci.InteractionSpec)10 Record (javax.resource.cci.Record)10 NotSupportedRecordFactory (org.springframework.jca.cci.connection.NotSupportedRecordFactory)10 CciTemplate (org.springframework.jca.cci.core.CciTemplate)10 IndexedRecord (javax.resource.cci.IndexedRecord)9 MappedRecord (javax.resource.cci.MappedRecord)9 RecordCreator (org.springframework.jca.cci.core.RecordCreator)9 NotSupportedException (javax.resource.NotSupportedException)1 ResultSet (javax.resource.cci.ResultSet)1