本文整理汇总了Java中javax.resource.cci.InteractionSpec类的典型用法代码示例。如果您正苦于以下问题:Java InteractionSpec类的具体用法?Java InteractionSpec怎么用?Java InteractionSpec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InteractionSpec类属于javax.resource.cci包,在下文中一共展示了InteractionSpec类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSimpleRecordOperation
import javax.resource.cci.InteractionSpec; //导入依赖的package包/类
@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();
}
示例2: testSimpleRecordOperationWithExplicitOutputRecord
import javax.resource.cci.InteractionSpec; //导入依赖的package包/类
@Test
public void testSimpleRecordOperationWithExplicitOutputRecord() 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 operation = new SimpleRecordOperation(connectionFactory, interactionSpec);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);
operation.execute(inputRecord, outputRecord);
verify(interaction).execute(interactionSpec, inputRecord, outputRecord);
verify(interaction).close();
verify(connection).close();
}
示例3: testSimpleRecordOperationWithInputOutputRecord
import javax.resource.cci.InteractionSpec; //导入依赖的package包/类
@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();
}
示例4: testTemplateExecuteInputOutput
import javax.resource.cci.InteractionSpec; //导入依赖的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();
}
示例5: testTemplateExecuteInputFalse
import javax.resource.cci.InteractionSpec; //导入依赖的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();
}
示例6: testTemplateExecuteInputExtractorFalse
import javax.resource.cci.InteractionSpec; //导入依赖的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();
}
示例7: testTemplateExecuteInputOutputConnectionSpec
import javax.resource.cci.InteractionSpec; //导入依赖的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();
}
示例8: testTemplateExecuteInputTrueTrueWithCreator
import javax.resource.cci.InteractionSpec; //导入依赖的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();
}
示例9: testTemplateExecuteInputTrueTrue
import javax.resource.cci.InteractionSpec; //导入依赖的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();
}
示例10: testTemplateExecuteInputFalseTrue
import javax.resource.cci.InteractionSpec; //导入依赖的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();
}
示例11: execute
import javax.resource.cci.InteractionSpec; //导入依赖的package包/类
@Override
public boolean execute(InteractionSpec spec, Record inputRec, Record searchRec) throws ResourceException {
if (!(spec instanceof DemoInteractionSpec)) {
throw EISException.invalidInteractionSpecType();
}
if (!(inputRec instanceof DemoMappedRecord) || !(searchRec instanceof DemoMappedRecord)) {
throw EISException.invalidRecordType();
}
DemoInteractionSpec iSpec = (DemoInteractionSpec) spec;
DemoMappedRecord mappedInputRec = (DemoMappedRecord) inputRec;
DemoMappedRecord mappedSearchRec = (DemoMappedRecord) searchRec;
DemoOperation operation = iSpec.getOperation();
String tableName = iSpec.getTable();
if (operation == null) {
throw new ResourceException("operation must be set");
}
if (tableName == null) {
throw new ResourceException("DB name must be set");
}
if (operation != DemoOperation.UPDATE) {
throw new ResourceException("Invalid operation: " + operation);
}
connection.update(iSpec, tableName, mappedSearchRec, mappedInputRec);
return true;
}
示例12: doExecute
import javax.resource.cci.InteractionSpec; //导入依赖的package包/类
/**
* Execute the specified interaction on an EIS with CCI.
* All other interaction execution methods go through this.
* @param spec the CCI InteractionSpec instance that defines
* the interaction (connector-specific)
* @param inputRecord the input record
* @param outputRecord output record (can be {@code null})
* @param outputExtractor object to convert the output record to a result object
* @return the output data extracted with the RecordExtractor object
* @throws DataAccessException if there is any problem
*/
protected <T> T doExecute(
final InteractionSpec spec, final Record inputRecord, final Record outputRecord,
final RecordExtractor<T> outputExtractor) throws DataAccessException {
return execute(new InteractionCallback<T>() {
@Override
public T doInInteraction(Interaction interaction, ConnectionFactory connectionFactory)
throws ResourceException, SQLException, DataAccessException {
Record outputRecordToUse = outputRecord;
try {
if (outputRecord != null || getOutputRecordCreator() != null) {
// Use the CCI execute method with output record as parameter.
if (outputRecord == null) {
RecordFactory recordFactory = getRecordFactory(connectionFactory);
outputRecordToUse = getOutputRecordCreator().createRecord(recordFactory);
}
interaction.execute(spec, inputRecord, outputRecordToUse);
}
else {
outputRecordToUse = interaction.execute(spec, inputRecord);
}
return (outputExtractor != null ? outputExtractor.extractData(outputRecordToUse) : null);
}
finally {
if (outputRecordToUse instanceof ResultSet) {
closeResultSet((ResultSet) outputRecordToUse);
}
}
}
});
}
示例13: testMappingRecordOperation
import javax.resource.cci.InteractionSpec; //导入依赖的package包/类
@Test
public void testMappingRecordOperation() 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);
InteractionSpec interactionSpec = mock(InteractionSpec.class);
QueryCallDetector callDetector = mock(QueryCallDetector.class);
MappingRecordOperationImpl query = new MappingRecordOperationImpl(connectionFactory, interactionSpec);
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(interaction.execute(interactionSpec, inputRecord)).willReturn(outputRecord);
given(callDetector.callExtractOutputData(outputRecord)).willReturn(outObj);
assertSame(outObj, query.execute(inObj));
verify(interaction).close();
verify(connection).close();
}
示例14: testMappingRecordOperationWithOutputRecordCreator
import javax.resource.cci.InteractionSpec; //导入依赖的package包/类
@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();
}
示例15: testLocalTransactionCommit
import javax.resource.cci.InteractionSpec; //导入依赖的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();
}