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();
}
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");
}
Aggregations