本文整理汇总了Java中org.springframework.jca.cci.core.CciTemplate类的典型用法代码示例。如果您正苦于以下问题:Java CciTemplate类的具体用法?Java CciTemplate怎么用?Java CciTemplate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CciTemplate类属于org.springframework.jca.cci.core包,在下文中一共展示了CciTemplate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTemplateExecuteInputOutput
import org.springframework.jca.cci.core.CciTemplate; //导入依赖的package包/类
@Test
public void testTemplateExecuteInputOutput() 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);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);
CciTemplate ct = new CciTemplate(connectionFactory);
ct.execute(interactionSpec, inputRecord, outputRecord);
verify(interaction).execute(interactionSpec, inputRecord, outputRecord);
verify(interaction).close();
verify(connection).close();
}
示例2: testTemplateExecuteInputFalse
import org.springframework.jca.cci.core.CciTemplate; //导入依赖的package包/类
@Test
public void testTemplateExecuteInputFalse() 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);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(interaction.execute(interactionSpec, inputRecord)).willReturn(outputRecord);
CciTemplate ct = new CciTemplate(connectionFactory);
ct.execute(interactionSpec, inputRecord);
verify(interaction).execute(interactionSpec, inputRecord);
verify(interaction).close();
verify(connection).close();
}
示例3: testTemplateExecuteInputExtractorFalse
import org.springframework.jca.cci.core.CciTemplate; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputExtractorFalse()
throws ResourceException, SQLException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
RecordExtractor<Object> extractor = mock(RecordExtractor.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(interaction.execute(interactionSpec, inputRecord)).willReturn(outputRecord);
given(extractor.extractData(outputRecord)).willReturn(new Object());
CciTemplate ct = new CciTemplate(connectionFactory);
ct.execute(interactionSpec, inputRecord, extractor);
verify(extractor).extractData(outputRecord);
verify(interaction).close();
verify(connection).close();
}
示例4: testTemplateExecuteInputOutputConnectionSpec
import org.springframework.jca.cci.core.CciTemplate; //导入依赖的package包/类
@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();
}
示例5: testTemplateExecuteConnectionCallback
import org.springframework.jca.cci.core.CciTemplate; //导入依赖的package包/类
@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();
}
示例6: testTemplateExecuteInteractionCallback
import org.springframework.jca.cci.core.CciTemplate; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInteractionCallback()
throws ResourceException, SQLException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
InteractionCallback<Object> interactionCallback = mock(InteractionCallback.class);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(interactionCallback.doInInteraction(interaction,connectionFactory)).willReturn(new Object());
CciTemplate ct = new CciTemplate(connectionFactory);
ct.execute(interactionCallback);
verify(interactionCallback).doInInteraction(interaction,connectionFactory);
verify(interaction).close();
verify(connection).close();
}
示例7: testTemplateExecuteInputTrueTrueWithCreator
import org.springframework.jca.cci.core.CciTemplate; //导入依赖的package包/类
@Test
public void testTemplateExecuteInputTrueTrueWithCreator()
throws ResourceException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
RecordCreator creator = mock(RecordCreator.class);
Record inputOutputRecord = mock(Record.class);
InteractionSpec interactionSpec = mock(InteractionSpec.class);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(interaction.execute(interactionSpec, inputOutputRecord, inputOutputRecord)).willReturn(true);
CciTemplate ct = new CciTemplate(connectionFactory);
ct.setOutputRecordCreator(creator);
ct.execute(interactionSpec, inputOutputRecord, inputOutputRecord);
verify(interaction).execute(interactionSpec, inputOutputRecord, inputOutputRecord);
verify(interaction).close();
verify(connection).close();
}
示例8: testTemplateExecuteInputTrueTrue
import org.springframework.jca.cci.core.CciTemplate; //导入依赖的package包/类
@Test
public void testTemplateExecuteInputTrueTrue() 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);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(interaction.execute(interactionSpec, inputOutputRecord, inputOutputRecord)).willReturn(true);
CciTemplate ct = new CciTemplate(connectionFactory);
ct.execute(interactionSpec, inputOutputRecord, inputOutputRecord);
verify(interaction).execute(interactionSpec, inputOutputRecord, inputOutputRecord);
verify(interaction).close();
verify(connection).close();
}
示例9: testTemplateExecuteInputFalseTrue
import org.springframework.jca.cci.core.CciTemplate; //导入依赖的package包/类
@Test
public void testTemplateExecuteInputFalseTrue() 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);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(interaction.execute(interactionSpec, inputOutputRecord)).willReturn(null);
CciTemplate ct = new CciTemplate(connectionFactory);
Record tmpOutputRecord = ct.execute(interactionSpec,
inputOutputRecord);
assertNull(tmpOutputRecord);
verify(interaction).execute(interactionSpec, inputOutputRecord);
verify(interaction).close();
verify(connection).close();
}
示例10: setCciTemplate
import org.springframework.jca.cci.core.CciTemplate; //导入依赖的package包/类
/**
* Set the CciTemplate to be used by this operation.
* Alternatively, specify a CCI ConnectionFactory.
* @see #setConnectionFactory
*/
public void setCciTemplate(CciTemplate cciTemplate) {
if (cciTemplate == null) {
throw new IllegalArgumentException("cciTemplate must not be null");
}
this.cciTemplate = cciTemplate;
}
示例11: testLocalTransactionCommit
import org.springframework.jca.cci.core.CciTemplate; //导入依赖的package包/类
/**
* Test if a transaction ( begin / commit ) is executed on the
* LocalTransaction when CciLocalTransactionManager is specified as
* transaction manager.
*/
@Test
public void testLocalTransactionCommit() throws ResourceException {
final ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
LocalTransaction localTransaction = mock(LocalTransaction.class);
final Record record = mock(Record.class);
final InteractionSpec interactionSpec = mock(InteractionSpec.class);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.getLocalTransaction()).willReturn(localTransaction);
given(connection.createInteraction()).willReturn(interaction);
given(interaction.execute(interactionSpec, record, record)).willReturn(true);
given(connection.getLocalTransaction()).willReturn(localTransaction);
CciLocalTransactionManager tm = new CciLocalTransactionManager();
tm.setConnectionFactory(connectionFactory);
TransactionTemplate tt = new TransactionTemplate(tm);
tt.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
assertTrue("Has thread connection", TransactionSynchronizationManager.hasResource(connectionFactory));
CciTemplate ct = new CciTemplate(connectionFactory);
ct.execute(interactionSpec, record, record);
}
});
verify(localTransaction).begin();
verify(interaction).close();
verify(localTransaction).commit();
verify(connection).close();
}
示例12: testLocalTransactionRollback
import org.springframework.jca.cci.core.CciTemplate; //导入依赖的package包/类
/**
* Test if a transaction ( begin / rollback ) is executed on the
* LocalTransaction when CciLocalTransactionManager is specified as
* transaction manager and a non-checked exception is thrown.
*/
@Test
public void testLocalTransactionRollback() throws ResourceException {
final ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
LocalTransaction localTransaction = mock(LocalTransaction.class);
final Record record = mock(Record.class);
final InteractionSpec interactionSpec = mock(InteractionSpec.class);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.getLocalTransaction()).willReturn(localTransaction);
given(connection.createInteraction()).willReturn(interaction);
given(interaction.execute(interactionSpec, record, record)).willReturn(true);
given(connection.getLocalTransaction()).willReturn(localTransaction);
CciLocalTransactionManager tm = new CciLocalTransactionManager();
tm.setConnectionFactory(connectionFactory);
TransactionTemplate tt = new TransactionTemplate(tm);
try {
tt.execute(new TransactionCallback<Void>() {
@Override
public Void doInTransaction(TransactionStatus status) {
assertTrue("Has thread connection", TransactionSynchronizationManager.hasResource(connectionFactory));
CciTemplate ct = new CciTemplate(connectionFactory);
ct.execute(interactionSpec, record, record);
throw new DataRetrievalFailureException("error");
}
});
}
catch (Exception ex) {
}
verify(localTransaction).begin();
verify(interaction).close();
verify(localTransaction).rollback();
verify(connection).close();
}
示例13: testCreateIndexedRecord
import org.springframework.jca.cci.core.CciTemplate; //导入依赖的package包/类
@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");
}
示例14: testCreateMappedRecord
import org.springframework.jca.cci.core.CciTemplate; //导入依赖的package包/类
@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");
}
示例15: testTemplateExecuteWithCreatorAndRecordFactoryNotSupported
import org.springframework.jca.cci.core.CciTemplate; //导入依赖的package包/类
@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();
}