org.teiid.test.framework
Interface TransactionQueryTestCase

All Known Implementing Classes:
AbstractQueryTransactionTest, TestClientTransaction

public interface TransactionQueryTestCase

The TransactionQueryTest interface represents the transaction test lifecycle of execution from which the @link TransactionContainer operates.

QueryTest lifecycle:

There are 4 phases or groupings of methods:

  • Setup
  • Test
  • Validation
  • Cleanup

  • 1. Setup phase is about setting the global environment for the testing

  • #setConnectionStrategy(ConnectionStrategy) - called first to provide the environment (i.e, type of connection, parameters, etc) that the test will be run under.
  • #hasRequiredDataSources() - called after the connection strategy is set so the determination can be made if this test has the required datasources defined and available in order to run the test. If not, then the test is bypassed.
  • setup() - called to enable the test to perform any pretest (i.e., global) setup. Example would be data source setup.
  • setConnection(Connection) - called to set the client driver (i.e., Teiid) connection that will be used to execute queries against
  • #setExecutionProperties(Properties) - called at this time so that the overriding class can obtain / initialize settings that will be assigned when
  • AbstractQueryTest.assignExecutionProperties(Statement) is called prior to sql execution. (Example: set fetch size, batch time, or timeout)

  • 2. Test phase are the methods for executing a test, including any before/after test logic to support the test

  • before() called before the execution of the test so that the transaction boundary can be set and any other pretest conditions
  • testCase() called to execute the specific test
  • after() called after the test is executed, which will commit/rollback the transaction and perform any other post conditions

  • 3. Validation phase is meant to enable data validation post transaction completion. This is especially helpful when performing XA transactions because the results are not completed and available until after the after() step is performed.

    #validateTestCase()

    4. Cleanup

    cleanup() Called to allow the testcase to perform any cleanup after execution.
    ================

    Other Notes:

    The following methods were exposed from AbstractQueryTest:

  • exceptionExpected() - when an exception is expected to occur, the underlying logic will treat the execution as if it succeeded.
  • exceptionOccurred() - this method indicates when an exception actually occurred outside of the normal expected results.
  • getConnection() and getXAConnection() - these connection methods are exposed for before() and after() methods
  • rollbackAllways() - this is exposed for the after() method as to what behavior is expected after the execution of the test

  • Author:
    vanhalbert

    Method Summary
     void after()
              Override after if there is behavior that needs to be performed after testCase() being called.
     void before()
              Override before if there is behavior that needs to be performed prior to testCase() being called.
     void cleanup()
              Called at the end of the test so that the testcase can clean itself up by releasing any resources, closing any open connections, etc.
     boolean exceptionExpected()
               
     boolean exceptionOccurred()
               
     java.lang.Throwable getApplicationException()
               
     java.sql.Connection getConnection()
              Returns the connection being used in the test.
     ConnectionStrategy getConnectionStrategy()
              Called to get the current connection strategy being used.
     java.lang.String getTestName()
              Returns the name of the test so that better tracing of what tests are running/completing.
     javax.sql.XAConnection getXAConnection()
               
     boolean rollbackAllways()
              Indicates what should be done when a failure occurs in testCase()
     void setApplicationException(java.lang.Throwable t)
               
     void setConnection(java.sql.Connection conn)
              Called by the @link TransactionContainer to set the Teiid connection to be used in the test.
     void setup()
              Called by the TransactionContainer prior to testcase processing so that the responsibility for performing an setup duties (ie.., datasource setup) can be done
     void testCase()
              Implement testCase(), it is the entry point to the execution of the test.
     

    Method Detail

    getTestName

    java.lang.String getTestName()
    Returns the name of the test so that better tracing of what tests are running/completing.

    Returns:
    String is test name

    getConnectionStrategy

    ConnectionStrategy getConnectionStrategy()
    Called to get the current connection strategy being used.

    Returns:
    connStrategy
    Since:

    setup

    void setup()
               throws QueryTestFailedException
    Called by the TransactionContainer prior to testcase processing so that the responsibility for performing an setup duties (ie.., datasource setup) can be done

    Throws:
    QueryTestFailedException
    Since:

    setConnection

    void setConnection(java.sql.Connection conn)
    Called by the @link TransactionContainer to set the Teiid connection to be used in the test.

    Parameters:
    conn -
    Since:

    before

    void before()
    Override before if there is behavior that needs to be performed prior to testCase() being called.

    Since:

    testCase

    void testCase()
                  throws java.lang.Exception
    Implement testCase(), it is the entry point to the execution of the test.

    Throws:
    java.lang.Exception
    Since:

    after

    void after()
    Override after if there is behavior that needs to be performed after testCase() being called.

    Since:

    rollbackAllways

    boolean rollbackAllways()
    Indicates what should be done when a failure occurs in testCase()

    Returns:
    Since:

    cleanup

    void cleanup()
    Called at the end of the test so that the testcase can clean itself up by releasing any resources, closing any open connections, etc.

    Since:

    getConnection

    java.sql.Connection getConnection()
    Returns the connection being used in the test.

    Returns:
    Since:

    getXAConnection

    javax.sql.XAConnection getXAConnection()

    exceptionExpected

    boolean exceptionExpected()

    exceptionOccurred

    boolean exceptionOccurred()

    setApplicationException

    void setApplicationException(java.lang.Throwable t)

    getApplicationException

    java.lang.Throwable getApplicationException()


    Copyright © 2010. All Rights Reserved.