Package javax.resource.cci

Examples of javax.resource.cci.Interaction


    MockControl connectionFactoryControl = MockControl.createControl(ConnectionFactory.class);
    ConnectionFactory connectionFactory = (ConnectionFactory) connectionFactoryControl.getMock();
    MockControl connectionControl = MockControl.createControl(Connection.class);
    Connection connection = (Connection) connectionControl.getMock();
    MockControl interactionControl = MockControl.createControl(Interaction.class);
    Interaction interaction = (Interaction) interactionControl.getMock();

    MockControl inputRecordControl = MockControl.createControl(Record.class);
    Record inputRecord = (Record) inputRecordControl.getMock();
    MockControl outputRecordControl = MockControl.createControl(Record.class);
    Record outputRecord = (Record) outputRecordControl.getMock();

    MockControl interactionSpecControl = MockControl.createControl(InteractionSpec.class);
    InteractionSpec interactionSpec = (InteractionSpec) interactionSpecControl.getMock();

    SimpleRecordOperation operation = new SimpleRecordOperation(connectionFactory, interactionSpec);

    connectionFactory.getConnection();
    connectionFactoryControl.setReturnValue(connection, 1);

    connection.createInteraction();
    connectionControl.setReturnValue(interaction, 1);

    interaction.execute(interactionSpec, inputRecord, outputRecord);
    interactionControl.setReturnValue(true, 1);

    interaction.close();
    interactionControl.setVoidCallable(1);

    connection.close();
    connectionControl.setVoidCallable(1);
View Full Code Here


    MockControl connectionFactoryControl = MockControl.createControl(ConnectionFactory.class);
    final ConnectionFactory connectionFactory = (ConnectionFactory) connectionFactoryControl.getMock();
    MockControl connectionControl = MockControl.createControl(Connection.class);
    Connection connection = (Connection) connectionControl.getMock();
    MockControl interactionControl = MockControl.createControl(Interaction.class);
    Interaction interaction = (Interaction) interactionControl.getMock();

    MockControl inputOutputRecordControl = MockControl.createControl(Record.class);
    Record inputOutputRecord = (Record) inputOutputRecordControl.getMock();

    MockControl interactionSpecControl = MockControl.createControl(InteractionSpec.class);
    InteractionSpec interactionSpec = (InteractionSpec) interactionSpecControl.getMock();

    SimpleRecordOperation query = new SimpleRecordOperation(connectionFactory, interactionSpec);

    connectionFactory.getConnection();
    connectionFactoryControl.setReturnValue(connection);

    connection.createInteraction();
    connectionControl.setReturnValue(interaction);

    interaction.execute(interactionSpec, inputOutputRecord, inputOutputRecord);
    interactionControl.setReturnValue(true, 1);

    interaction.close();
    interactionControl.setVoidCallable(1);

    connection.close();
    connectionControl.setVoidCallable(1);
View Full Code Here

    MockControl recordFactoryControl = MockControl.createStrictControl(RecordFactory.class);
    RecordFactory recordFactory = (RecordFactory) recordFactoryControl.getMock();
    MockControl connectionControl = MockControl.createControl(Connection.class);
    Connection connection = (Connection) connectionControl.getMock();
    MockControl interactionControl = MockControl.createControl(Interaction.class);
    Interaction interaction = (Interaction) interactionControl.getMock();

    MockControl inputRecordControl = MockControl.createControl(Record.class);
    Record inputRecord = (Record) inputRecordControl.getMock();
    MockControl outputRecordControl = MockControl.createControl(Record.class);
    Record outputRecord = (Record) outputRecordControl.getMock();

    MockControl interactionSpecControl = MockControl.createControl(InteractionSpec.class);
    InteractionSpec interactionSpec = (InteractionSpec) interactionSpecControl.getMock();

    MockControl callDetectorControl = MockControl.createControl(QueryCallDetector.class);
    QueryCallDetector callDetector = (QueryCallDetector) callDetectorControl.getMock();

    MappingRecordOperationImpl query = new MappingRecordOperationImpl(connectionFactory, interactionSpec);
    query.setCallDetector(callDetector);

    Object inObj = new Object();
    Object outObj = new Object();

    connectionFactory.getRecordFactory();
    connectionFactoryControl.setReturnValue(recordFactory, 1);

    callDetector.callCreateInputRecord(recordFactory, inObj);
    callDetectorControl.setReturnValue(inputRecord, 1);

    connectionFactory.getConnection();
    connectionFactoryControl.setReturnValue(connection, 1);

    connection.createInteraction();
    connectionControl.setReturnValue(interaction, 1);

    interaction.execute(interactionSpec, inputRecord);
    interactionControl.setReturnValue(outputRecord, 1);

    callDetector.callExtractOutputData(outputRecord);
    callDetectorControl.setReturnValue(outObj, 1);

    interaction.close();
    interactionControl.setVoidCallable(1);

    connection.close();
    connectionControl.setVoidCallable(1);
View Full Code Here

    MockControl recordFactoryControl = MockControl.createStrictControl(RecordFactory.class);
    RecordFactory recordFactory = (RecordFactory) recordFactoryControl.getMock();
    MockControl connectionControl = MockControl.createControl(Connection.class);
    Connection connection = (Connection) connectionControl.getMock();
    MockControl interactionControl = MockControl.createControl(Interaction.class);
    Interaction interaction = (Interaction) interactionControl.getMock();

    MockControl inputRecordControl = MockControl.createControl(Record.class);
    Record inputRecord = (Record) inputRecordControl.getMock();
    MockControl outputRecordControl = MockControl.createControl(Record.class);
    Record outputRecord = (Record) outputRecordControl.getMock();
    MockControl outputCreatorControl = MockControl.createControl(RecordCreator.class);
    RecordCreator outputCreator = (RecordCreator) outputCreatorControl.getMock();

    MockControl interactionSpecControl = MockControl.createControl(InteractionSpec.class);
    InteractionSpec interactionSpec = (InteractionSpec) interactionSpecControl.getMock();

    MockControl callDetectorControl = MockControl.createControl(QueryCallDetector.class);
    QueryCallDetector callDetector = (QueryCallDetector) callDetectorControl.getMock();

    MappingRecordOperationImpl query = new MappingRecordOperationImpl(connectionFactory, interactionSpec);
    query.setOutputRecordCreator(outputCreator);
    query.setCallDetector(callDetector);

    Object inObj = new Object();
    Object outObj = new Object();

    connectionFactory.getRecordFactory();
    connectionFactoryControl.setReturnValue(recordFactory, 1);

    callDetector.callCreateInputRecord(recordFactory, inObj);
    callDetectorControl.setReturnValue(inputRecord, 1);

    connectionFactory.getConnection();
    connectionFactoryControl.setReturnValue(connection, 1);

    connection.createInteraction();
    connectionControl.setReturnValue(interaction, 1);

    connectionFactory.getRecordFactory();
    connectionFactoryControl.setReturnValue(recordFactory, 1);

    outputCreator.createRecord(recordFactory);
    outputCreatorControl.setReturnValue(outputRecord, 1);

    interaction.execute(interactionSpec, inputRecord, outputRecord);
    interactionControl.setReturnValue(true, 1);

    callDetector.callExtractOutputData(outputRecord);
    callDetectorControl.setReturnValue(outObj, 1);

    interaction.close();
    interactionControl.setVoidCallable(1);

    connection.close();
    connectionControl.setVoidCallable(1);
View Full Code Here

    }

    @Override
    public Message process(Exchange exchange) throws HandlerException {
        Connection connection = null;
        Interaction interaction = null;
        try {
            if (_connectionSpec != null) {
                connection = _connectionFactory.getConnection(_connectionSpec);
            } else {
                connection = _connectionFactory.getConnection();
            }
            interaction = connection.createInteraction();
            return _recordHandler.handle(exchange, connection, interaction);
        } catch (Exception e) {
            throw JCAMessages.MESSAGES.failedToProcessCCIOutboundInteraction(e);
        } finally {
            try {
                if (interaction != null) {
                    interaction.close();
                }
                if (connection != null) {
                    connection.close();
                }
            } catch (ResourceException e) {
View Full Code Here

  @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);
View Full Code Here

  @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) {
View Full Code Here

  public void testTemplateExecuteInputTrueWithCreator2()
      throws ResourceException {
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    RecordFactory recordFactory = mock(RecordFactory.class);
    Connection connection = mock(Connection.class);
    Interaction interaction = mock(Interaction.class);
    RecordCreator creator = mock(RecordCreator.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()).willReturn(recordFactory);
    given(connection.createInteraction()).willReturn(interaction);
    given(creator.createRecord(recordFactory)).willReturn(outputRecord);
    given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);

    CciTemplate ct = new CciTemplate(connectionFactory);
    ct.setOutputRecordCreator(creator);
    ct.execute(interactionSpec, inputRecord);
View Full Code Here

  @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);
View Full Code Here

  public void testTemplateExecuteInputExtractorTrueWithCreator()
      throws ResourceException, SQLException {
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    RecordFactory recordFactory = mock(RecordFactory.class);
    Connection connection = mock(Connection.class);
    Interaction interaction = mock(Interaction.class);
    RecordExtractor<Object> extractor = mock(RecordExtractor.class);
    RecordCreator creator = mock(RecordCreator.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(connectionFactory.getRecordFactory()).willReturn(recordFactory);
    given(creator.createRecord(recordFactory)).willReturn(outputRecord);
    given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);
    given(extractor.extractData(outputRecord)).willReturn(new Object());

    CciTemplate ct = new CciTemplate(connectionFactory);
    ct.setOutputRecordCreator(creator);
    ct.execute(interactionSpec, inputRecord, extractor);
View Full Code Here

TOP

Related Classes of javax.resource.cci.Interaction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.