Search in sources :

Example 16 with Connection

use of javax.resource.cci.Connection 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 17 with Connection

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

Example 18 with Connection

use of javax.resource.cci.Connection 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 19 with Connection

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

the class EisOperationTests method testSimpleRecordOperationWithInputOutputRecord.

@Test
public void testSimpleRecordOperationWithInputOutputRecord() throws ResourceException {
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    Connection connection = mock(Connection.class);
    Interaction interaction = mock(Interaction.class);
    Record inputOutputRecord = mock(Record.class);
    InteractionSpec interactionSpec = mock(InteractionSpec.class);
    SimpleRecordOperation query = new SimpleRecordOperation(connectionFactory, interactionSpec);
    given(connectionFactory.getConnection()).willReturn(connection);
    given(connection.createInteraction()).willReturn(interaction);
    given(interaction.execute(interactionSpec, inputOutputRecord, inputOutputRecord)).willReturn(true);
    query.execute(inputOutputRecord, inputOutputRecord);
    verify(interaction).execute(interactionSpec, inputOutputRecord, inputOutputRecord);
    verify(interaction).close();
    verify(connection).close();
}
Also used : ConnectionFactory(javax.resource.cci.ConnectionFactory) Interaction(javax.resource.cci.Interaction) InteractionSpec(javax.resource.cci.InteractionSpec) Connection(javax.resource.cci.Connection) SimpleRecordOperation(org.springframework.jca.cci.object.SimpleRecordOperation) Record(javax.resource.cci.Record) Test(org.junit.Test)

Example 20 with Connection

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

the class EisOperationTests method testSimpleRecordOperation.

@Test
public void testSimpleRecordOperation() 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 query = new SimpleRecordOperation(connectionFactory, interactionSpec);
    given(connectionFactory.getConnection()).willReturn(connection);
    given(connection.createInteraction()).willReturn(interaction);
    given(interaction.execute(interactionSpec, inputRecord)).willReturn(outputRecord);
    query.execute(inputRecord);
    verify(interaction).execute(interactionSpec, inputRecord);
    verify(interaction).close();
    verify(connection).close();
}
Also used : ConnectionFactory(javax.resource.cci.ConnectionFactory) Interaction(javax.resource.cci.Interaction) InteractionSpec(javax.resource.cci.InteractionSpec) Connection(javax.resource.cci.Connection) SimpleRecordOperation(org.springframework.jca.cci.object.SimpleRecordOperation) Record(javax.resource.cci.Record) Test(org.junit.Test)

Aggregations

Connection (javax.resource.cci.Connection)36 Test (org.junit.Test)28 ConnectionFactory (javax.resource.cci.ConnectionFactory)25 Interaction (javax.resource.cci.Interaction)23 InteractionSpec (javax.resource.cci.InteractionSpec)22 Record (javax.resource.cci.Record)22 CciTemplate (org.springframework.jca.cci.core.CciTemplate)19 IndexedRecord (javax.resource.cci.IndexedRecord)15 MappedRecord (javax.resource.cci.MappedRecord)15 RecordFactory (javax.resource.cci.RecordFactory)10 RecordCreator (org.springframework.jca.cci.core.RecordCreator)10 NotSupportedRecordFactory (org.springframework.jca.cci.connection.NotSupportedRecordFactory)8 ResourceException (javax.resource.ResourceException)4 NotSupportedException (javax.resource.NotSupportedException)3 LocalTransactionException (javax.resource.spi.LocalTransactionException)3 SimpleRecordOperation (org.springframework.jca.cci.object.SimpleRecordOperation)3 TransactionSystemException (org.springframework.transaction.TransactionSystemException)3 LocalTransaction (javax.resource.cci.LocalTransaction)2 ManagedConnection (javax.resource.spi.ManagedConnection)2 ContainerSystem (org.apache.openejb.spi.ContainerSystem)2