Search in sources :

Example 26 with ConnectionFactory

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

the class CciTemplateTests method testTemplateExecuteConnectionCallback.

@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteConnectionCallback() throws ResourceException, SQLException {
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    Connection connection = mock(Connection.class);
    ConnectionCallback<Object> connectionCallback = mock(ConnectionCallback.class);
    given(connectionFactory.getConnection()).willReturn(connection);
    given(connectionCallback.doInConnection(connection, connectionFactory)).willReturn(new Object());
    CciTemplate ct = new CciTemplate(connectionFactory);
    ct.execute(connectionCallback);
    verify(connectionCallback).doInConnection(connection, connectionFactory);
    verify(connection).close();
}
Also used : ConnectionFactory(javax.resource.cci.ConnectionFactory) Connection(javax.resource.cci.Connection) CciTemplate(org.springframework.jca.cci.core.CciTemplate) Test(org.junit.Test)

Example 27 with ConnectionFactory

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

the class CciTemplateTests method testCreateMappedRecord.

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

Aggregations

ConnectionFactory (javax.resource.cci.ConnectionFactory)27 Test (org.junit.Test)26 Connection (javax.resource.cci.Connection)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)21 IndexedRecord (javax.resource.cci.IndexedRecord)16 MappedRecord (javax.resource.cci.MappedRecord)16 RecordFactory (javax.resource.cci.RecordFactory)12 NotSupportedRecordFactory (org.springframework.jca.cci.connection.NotSupportedRecordFactory)10 RecordCreator (org.springframework.jca.cci.core.RecordCreator)10 SimpleRecordOperation (org.springframework.jca.cci.object.SimpleRecordOperation)3 LocalTransaction (javax.resource.cci.LocalTransaction)2 CciLocalTransactionManager (org.springframework.jca.cci.connection.CciLocalTransactionManager)2 TransactionStatus (org.springframework.transaction.TransactionStatus)2 TransactionTemplate (org.springframework.transaction.support.TransactionTemplate)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1