Package javax.resource.cci

Examples of javax.resource.cci.Interaction


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


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

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

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

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

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

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

  public <T> T execute(final InteractionCallback<T> action) throws DataAccessException {
    Assert.notNull(action, "Callback object must not be null");
    return execute(new ConnectionCallback<T>() {
      public T doInConnection(Connection connection, ConnectionFactory connectionFactory)
          throws ResourceException, SQLException, DataAccessException {
        Interaction interaction = connection.createInteraction();
        try {
          return action.doInInteraction(interaction, connectionFactory);
        }
        finally {
          closeInteraction(interaction);
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.