Search in sources :

Example 21 with TransactionRuntimeException

use of org.teiid.test.framework.exception.TransactionRuntimeException in project teiid by teiid.

the class LocalTransaction method before.

protected void before(TransactionQueryTestCase test) {
    test.getConnectionStrategy().setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_OFF);
    try {
        debug("Autocommit: " + test.getConnectionStrategy().getAutocommit());
        test.getConnection().setAutoCommit(test.getConnectionStrategy().getAutocommit());
    } catch (SQLException e) {
        throw new TransactionRuntimeException(e);
    }
}
Also used : SQLException(java.sql.SQLException) TransactionRuntimeException(org.teiid.test.framework.exception.TransactionRuntimeException)

Example 22 with TransactionRuntimeException

use of org.teiid.test.framework.exception.TransactionRuntimeException in project teiid by teiid.

the class StandaloneGlobalTransaction method before.

@Override
protected void before(TransactionQueryTestCase test) {
    try {
        xid = createXid();
        XAResource xaResource = test.getConnectionStrategy().getXAConnection().getXAResource();
        xaResource.setTransactionTimeout(120);
        xaResource.start(xid, XAResource.TMNOFLAGS);
    } catch (Exception e) {
        throw new TransactionRuntimeException(e);
    }
}
Also used : XAResource(javax.transaction.xa.XAResource) TransactionRuntimeException(org.teiid.test.framework.exception.TransactionRuntimeException) TransactionRuntimeException(org.teiid.test.framework.exception.TransactionRuntimeException)

Example 23 with TransactionRuntimeException

use of org.teiid.test.framework.exception.TransactionRuntimeException in project teiid by teiid.

the class StandaloneGlobalTransaction method after.

@Override
protected void after(TransactionQueryTestCase test) {
    boolean delistSuccessful = false;
    boolean commit = false;
    try {
        XAResource xaResource = test.getConnectionStrategy().getXAConnection().getXAResource();
        xaResource.end(xid, XAResource.TMSUCCESS);
        if (!test.exceptionExpected() && xaResource.prepare(xid) == XAResource.XA_OK) {
            commit = true;
        }
        delistSuccessful = true;
    } catch (Exception e) {
        throw new TransactionRuntimeException(e);
    } finally {
        try {
            if (!delistSuccessful || test.rollbackAllways() || test.exceptionOccurred()) {
                test.getConnectionStrategy().getXAConnection().getXAResource().rollback(xid);
            } else if (commit) {
                test.getConnectionStrategy().getXAConnection().getXAResource().commit(xid, true);
            }
        } catch (Exception e) {
            throw new TransactionRuntimeException(e);
        }
    }
}
Also used : XAResource(javax.transaction.xa.XAResource) TransactionRuntimeException(org.teiid.test.framework.exception.TransactionRuntimeException) TransactionRuntimeException(org.teiid.test.framework.exception.TransactionRuntimeException)

Example 24 with TransactionRuntimeException

use of org.teiid.test.framework.exception.TransactionRuntimeException in project teiid by teiid.

the class XATransaction method after.

protected void after(TransactionQueryTestCase test) {
    boolean delistSuccessful = false;
    boolean commit = false;
    XAResource xaResource = null;
    boolean exception = false;
    try {
        xaResource = test.getConnectionStrategy().getXAConnection().getXAResource();
        xaResource.end(xid, XAResource.TMSUCCESS);
        if (!test.exceptionExpected() && xaResource.prepare(xid) == XAResource.XA_OK) {
            commit = true;
        }
        delistSuccessful = true;
    } catch (Exception e) {
        exception = true;
        throw new TransactionRuntimeException(e);
    } finally {
        try {
            if (!delistSuccessful || test.rollbackAllways() || test.exceptionOccurred()) {
                xaResource.rollback(xid);
            } else if (commit) {
                xaResource.commit(xid, true);
            }
        } catch (Exception e) {
            if (!exception) {
                throw new TransactionRuntimeException(e);
            }
        }
    }
}
Also used : XAResource(javax.transaction.xa.XAResource) TransactionRuntimeException(org.teiid.test.framework.exception.TransactionRuntimeException) TransactionRuntimeException(org.teiid.test.framework.exception.TransactionRuntimeException)

Example 25 with TransactionRuntimeException

use of org.teiid.test.framework.exception.TransactionRuntimeException in project teiid by teiid.

the class QueryScenario method setUp.

protected void setUp() {
    Collection args = new ArrayList(1);
    args.add(scenarioName);
    args.add(props);
    reader = ClassFactory.createQueryReader(args);
    args = new ArrayList(2);
    args.add(this.scenarioName);
    args.add(this.props);
    resultsGen = ClassFactory.createResultsGenerator(args);
    if (reader.getQuerySetIDs() == null || reader.getQuerySetIDs().isEmpty()) {
        throw new TransactionRuntimeException("The queryreader did not return any queryset ID's to process");
    }
    validateResultsMode(this.props);
// TODO:  deployprops.loc not needed in remote testing
// try {
// setupVDBs(this.getProperties());
// } catch (IOException e) {
// throw new TransactionRuntimeException(e.getMessage());
// }
}
Also used : ArrayList(java.util.ArrayList) TransactionRuntimeException(org.teiid.test.framework.exception.TransactionRuntimeException) Collection(java.util.Collection)

Aggregations

TransactionRuntimeException (org.teiid.test.framework.exception.TransactionRuntimeException)26 QueryTestFailedException (org.teiid.test.framework.exception.QueryTestFailedException)5 XAResource (javax.transaction.xa.XAResource)4 File (java.io.File)3 Properties (java.util.Properties)3 ConfigPropertyLoader (org.teiid.test.framework.ConfigPropertyLoader)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 XAConnection (javax.sql.XAConnection)2 TransactionContainer (org.teiid.test.framework.TransactionContainer)2 DataSource (org.teiid.test.framework.datasource.DataSource)2 InputStream (java.io.InputStream)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 Collection (java.util.Collection)1 InitialContext (javax.naming.InitialContext)1 Element (org.jdom.Element)1 JDOMException (org.jdom.JDOMException)1 JNDITransaction (org.teiid.test.framework.transaction.JNDITransaction)1 LocalTransaction (org.teiid.test.framework.transaction.LocalTransaction)1