org.teiid.test.framework.query
Class AbstractQueryTransactionTest

java.lang.Object
  extended by org.teiid.jdbc.AbstractQueryTest
      extended by org.teiid.test.framework.query.AbstractQueryTransactionTest
All Implemented Interfaces:
TransactionQueryTestCase
Direct Known Subclasses:
TestClientTransaction

public abstract class AbstractQueryTransactionTest
extends org.teiid.jdbc.AbstractQueryTest
implements TransactionQueryTestCase

The AbstractQueryTransactionTest is the base implementation for the TransactionQueryTestCase. This provides the default logic for perform a testcase. The only method to implement in order to perform a basic, single datasource, test is the testCase() method. AbstractQueryTransactionTest is the class that should be extended when a testcase is being created to validate certain behavior
The following methods are useful when writing validation logic because they provide a direct connection to the datasource that was used by the VDB. This enables data validation of expected behavior of Teiid.

  • getSource(String).
  • getXASource(String)

  • See Also:
    for use when direct queries to the source are used to validate the results of the testcase.

    Field Summary
    protected  ConnectionStrategy connStrategy
               
    protected  int fetchSize
               
    protected  int queryTimeout
               
    protected  java.lang.String testname
               
     
    Fields inherited from class org.teiid.jdbc.AbstractQueryTest
    DELIMITER, internalConnection, internalResultSet, internalStatement, updateCount
     
    Constructor Summary
    AbstractQueryTransactionTest()
               
    AbstractQueryTransactionTest(java.lang.String testname)
               
     
    Method Summary
     void after()
              Override after if there is behavior that needs to be performed after testCase() being called.
    protected  void assignExecutionProperties(java.sql.Statement stmt)
               
     void before()
              Override before if there is behavior that needs to be performed prior to testCase() being called.
     void cleanup()
              At end of each test, perform any cleanup that your test requires.
     boolean exceptionOccurred()
               
     java.lang.Throwable getApplicationException()
               
     ConnectionStrategy getConnectionStrategy()
              Called to get the current connection strategy being used.
     java.sql.SQLException getLastException()
               
     java.sql.Connection getSource(java.lang.String identifier)
              The source connection must be asked from the connection strategy because only here is it known which model was mapped to which datasource.
     java.lang.String getTestName()
              Returns the name of the test so that better tracing of what tests are running/completing.
     javax.sql.XAConnection getXAConnection()
               
     javax.sql.XAConnection getXASource(java.lang.String identifier)
               
     boolean rollbackAllways()
              Indicates what should be done when a failure occurs in testCase()
     void setApplicationException(java.lang.Throwable t)
               
     void setup()
              Override setupDataSource if there is different mechanism for setting up the datasources for the testcase
    protected  void setupDataStore()
               
    abstract  void testCase()
              Implement testCase(), it is the entry point to the execution of the test.
     
    Methods inherited from class org.teiid.jdbc.AbstractQueryTest
    assertReaderEquals, assertResults, assertResultsSetEquals, assertResultsSetEquals, assertResultsSetEquals, assertResultsSetEquals, assertResultsSetEquals, assertResultsSetEquals, assertResultsSetMetadataEquals, assertResultsSetMetadataEquals, assertRowCount, assertUpdateCount, cancelQuery, closeConnection, closeResultSet, closeStatement, compareCaseSensitive, compareResults, createPrepareCallStatement, createPrepareStatement, createStatement, exceptionExpected, execute, execute, executeAndAssertResults, executeBatch, executeBatch, getConnection, getRowCount, print, print, printResults, printResults, printResults, read, setConnection, tearDown, walkResults
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     
    Methods inherited from interface org.teiid.test.framework.TransactionQueryTestCase
    exceptionExpected, getConnection, setConnection
     

    Field Detail

    testname

    protected java.lang.String testname

    fetchSize

    protected int fetchSize

    queryTimeout

    protected int queryTimeout

    connStrategy

    protected ConnectionStrategy connStrategy
    Constructor Detail

    AbstractQueryTransactionTest

    public AbstractQueryTransactionTest()

    AbstractQueryTransactionTest

    public AbstractQueryTransactionTest(java.lang.String testname)
    Method Detail

    getTestName

    public java.lang.String getTestName()
    Description copied from interface: TransactionQueryTestCase
    Returns the name of the test so that better tracing of what tests are running/completing.

    Specified by:
    getTestName in interface TransactionQueryTestCase
    Returns:
    String is test name

    getConnectionStrategy

    public ConnectionStrategy getConnectionStrategy()
    Description copied from interface: TransactionQueryTestCase
    Called to get the current connection strategy being used.

    Specified by:
    getConnectionStrategy in interface TransactionQueryTestCase
    Returns:
    connStrategy

    assignExecutionProperties

    protected void assignExecutionProperties(java.sql.Statement stmt)
    Overrides:
    assignExecutionProperties in class org.teiid.jdbc.AbstractQueryTest

    setup

    public void setup()
               throws QueryTestFailedException
    Override setupDataSource if there is different mechanism for setting up the datasources for the testcase

    Specified by:
    setup in interface TransactionQueryTestCase
    Throws:
    QueryTestFailedException
    QueryTestFailedException
    Since:

    setupDataStore

    protected void setupDataStore()

    getSource

    public java.sql.Connection getSource(java.lang.String identifier)
                                  throws QueryTestFailedException
    The source connection must be asked from the connection strategy because only here is it known which model was mapped to which datasource. This is because each test could potentially use an include/exclude datasource option that could change the mappings between tests.

    Parameters:
    identifier -
    Returns:
    Connection
    Throws:
    QueryTestFailedException

    getXASource

    public javax.sql.XAConnection getXASource(java.lang.String identifier)
                                       throws QueryTestFailedException
    Throws:
    QueryTestFailedException

    testCase

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

    Specified by:
    testCase in interface TransactionQueryTestCase
    Throws:
    java.lang.Exception
    Since:

    rollbackAllways

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

    Specified by:
    rollbackAllways in interface TransactionQueryTestCase
    Returns:
    boolean
    Since:

    before

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

    Specified by:
    before in interface TransactionQueryTestCase
    Since:

    after

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

    Specified by:
    after in interface TransactionQueryTestCase
    Since:

    cleanup

    public void cleanup()
    At end of each test, perform any cleanup that your test requires. Note: Do not cleanup any connections by calling ConnectionStrategy.shutdown(). That is performed by the TransactionContainer.runTransaction(TransactionQueryTestCase) at the end of the test.

    Specified by:
    cleanup in interface TransactionQueryTestCase

    getXAConnection

    public javax.sql.XAConnection getXAConnection()
    Specified by:
    getXAConnection in interface TransactionQueryTestCase

    setApplicationException

    public void setApplicationException(java.lang.Throwable t)
    Specified by:
    setApplicationException in interface TransactionQueryTestCase

    exceptionOccurred

    public boolean exceptionOccurred()
    Specified by:
    exceptionOccurred in interface TransactionQueryTestCase
    Overrides:
    exceptionOccurred in class org.teiid.jdbc.AbstractQueryTest

    getLastException

    public java.sql.SQLException getLastException()
    Overrides:
    getLastException in class org.teiid.jdbc.AbstractQueryTest

    getApplicationException

    public java.lang.Throwable getApplicationException()
    Specified by:
    getApplicationException in interface TransactionQueryTestCase


    Copyright © 2011. All Rights Reserved.