Search in sources :

Example 6 with RecordCreator

use of org.springframework.jca.cci.core.RecordCreator in project spring-framework by spring-projects.

the class CciTemplateTests method testTemplateExecuteInputGeneratorFalse.

@Test
public void testTemplateExecuteInputGeneratorFalse() 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);
    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);
    CciTemplate ct = new CciTemplate(connectionFactory);
    ct.execute(interactionSpec, generator);
    verify(interaction).execute(interactionSpec, inputRecord);
    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 7 with RecordCreator

use of org.springframework.jca.cci.core.RecordCreator in project spring-framework by spring-projects.

the class CciTemplateTests method testTemplateExecuteInputOutputResultsSetFalse.

@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputOutputResultsSetFalse() throws ResourceException, SQLException {
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    RecordFactory recordFactory = mock(RecordFactory.class);
    Connection connection = mock(Connection.class);
    Interaction interaction = mock(Interaction.class);
    Record record = mock(Record.class);
    ResultSet resultset = mock(ResultSet.class);
    RecordCreator generator = mock(RecordCreator.class);
    RecordExtractor<Object> extractor = mock(RecordExtractor.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(record);
    given(interaction.execute(interactionSpec, record)).willReturn(resultset);
    given(extractor.extractData(resultset)).willReturn(new Object());
    CciTemplate ct = new CciTemplate(connectionFactory);
    ct.execute(interactionSpec, generator, extractor);
    verify(extractor).extractData(resultset);
    verify(resultset).close();
    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) ResultSet(javax.resource.cci.ResultSet) 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 8 with RecordCreator

use of org.springframework.jca.cci.core.RecordCreator 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();
}
Also used : ConnectionFactory(javax.resource.cci.ConnectionFactory) RecordFactory(javax.resource.cci.RecordFactory) Interaction(javax.resource.cci.Interaction) RecordCreator(org.springframework.jca.cci.core.RecordCreator) InteractionSpec(javax.resource.cci.InteractionSpec) Connection(javax.resource.cci.Connection) Record(javax.resource.cci.Record) Test(org.junit.Test)

Example 9 with RecordCreator

use of org.springframework.jca.cci.core.RecordCreator 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();
}
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 10 with RecordCreator

use of org.springframework.jca.cci.core.RecordCreator 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();
}
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

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