Search in sources :

Example 6 with TransactionRuntimeException

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

the class XMLQueryVisitationStrategy method getParms.

private Object[] getParms(Element parent) {
    List<Element> parmChildren = parent.getChildren(TagNames.Elements.PARM);
    if (parmChildren == null) {
        return null;
    }
    Object[] parms = new Object[parmChildren.size()];
    int i = 0;
    final Iterator<Element> iter = parmChildren.iterator();
    while (iter.hasNext()) {
        final Element parmElement = (Element) iter.next();
        try {
            Object parm = createParmType(parmElement);
            parms[i] = parm;
            i++;
        } catch (JDOMException e) {
            throw new TransactionRuntimeException(e);
        }
    }
    return parms;
}
Also used : Element(org.jdom.Element) TransactionRuntimeException(org.teiid.test.framework.exception.TransactionRuntimeException) JDOMException(org.jdom.JDOMException)

Example 7 with TransactionRuntimeException

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

the class TransactionFactory method create.

public static TransactionContainer create(ConfigPropertyLoader config) throws QueryTestFailedException {
    TransactionContainer transacton = null;
    String type = config.getProperty(TRANSACTION_TYPE);
    if (type == null) {
        throw new TransactionRuntimeException(TRANSACTION_TYPE + " property was not specified");
    }
    TestLogger.logDebug("====  Create Transaction-Option: " + type);
    if (type.equalsIgnoreCase(TRANSACTION_TYPES.LOCAL_TRANSACTION)) {
        transacton = new LocalTransaction();
    } else if (type.equalsIgnoreCase(TRANSACTION_TYPES.XATRANSACTION)) {
        transacton = new XATransaction();
    } else if (type.equalsIgnoreCase(TRANSACTION_TYPES.JNDI_TRANSACTION)) {
        transacton = new JNDITransaction();
    } else if (type.equalsIgnoreCase(TRANSACTION_TYPES.OFFWRAP_TRANSACTION)) {
        transacton = new TxnAutoTransaction(TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_OFF);
    } else if (type.equalsIgnoreCase(TRANSACTION_TYPES.ONWRAP_TRANSACTION)) {
        transacton = new TxnAutoTransaction(TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_ON);
    } else if (type.equalsIgnoreCase(TRANSACTION_TYPES.AUTOWRAP_TRANSACTION)) {
        transacton = new TxnAutoTransaction(TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_AUTO);
    } else {
        throw new TransactionRuntimeException("Invalid property value of " + type + " for " + TRANSACTION_TYPE);
    }
    TestLogger.log("====  TransactionContainer: " + transacton.getClass().getName() + " option:" + type);
    return transacton;
}
Also used : LocalTransaction(org.teiid.test.framework.transaction.LocalTransaction) JNDITransaction(org.teiid.test.framework.transaction.JNDITransaction) TransactionContainer(org.teiid.test.framework.TransactionContainer) TransactionRuntimeException(org.teiid.test.framework.exception.TransactionRuntimeException) XATransaction(org.teiid.test.framework.transaction.XATransaction) TxnAutoTransaction(org.teiid.test.framework.transaction.TxnAutoTransaction)

Example 8 with TransactionRuntimeException

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

the class ConnectionStrategy method createDriverConnection.

// protected void setupVDBConnectorBindings(Admin api) throws
// QueryTestFailedException {
// 
// try {
// 
// VDB vdb = null;
// Set<VDB> vdbs = api.getVDBs();
// if (vdbs == null || vdbs.isEmpty()) {
// throw new QueryTestFailedException(
// "AdminApi.GetVDBS returned no vdbs available");
// }
// 
// String urlString = this.env.getProperty(DriverConnection.DS_URL);
// JDBCURL url = new JDBCURL(urlString);
// TestLogger.logDebug("Trying to match VDB : " + url.getVDBName());
// 
// for (Iterator<VDB> iterator = vdbs.iterator(); iterator.hasNext();) {
// VDB v = (VDB) iterator.next();
// if (v.getName().equalsIgnoreCase(url.getVDBName())) {
// vdb = v;
// }
// 
// }
// if (vdbs == null) {
// throw new QueryTestFailedException(
// "GetVDBS did not return a vdb that matched "
// + url.getVDBName());
// }
// 
// List<Model> models = vdb.getModels();
// Iterator<Model> modelIt = models.iterator();
// while (modelIt.hasNext()) {
// Model m = modelIt.next();
// 
// if (!m.isSource())
// continue;
// 
// // get the mapping, if defined
// String mappedName = this.env.getProperty(m.getName());
// 
// String useName = m.getName();
// if (mappedName != null) {
// useName = mappedName;
// }
// 
// org.teiid.test.framework.datasource.DataSource ds =
// this.dsFactory.getDatasource(useName, m.getName());
// 
// if (ds != null) {
// 
// TestLogger.logInfo("Set up Connector Binding (model:mapping:type): " + m.getName() + ":" + useName + ":" + ds.getConnectorType()); //$NON-NLS-1$
// 
// api.addConnectorBinding(ds.getName(),ds.getConnectorType(),
// ds.getProperties());
// 
// api.assignBindingToModel(vdb.getName(), vdb.getVersion(), m.getName(),
// ds.getName(), ds.getProperty("jndi-name"));
// 
// api.startConnectorBinding(api.getConnectorBinding(ds.getName()));
// } else {
// throw new QueryTestFailedException(
// "Error: Unable to create binding to map to model : "
// + m.getName() + ", the mapped name "
// + useName
// + " had no datasource properties defined");
// }
// 
// }
// 
// } catch (QueryTestFailedException qt) {
// throw qt;
// } catch (Exception t) {
// t.printStackTrace();
// throw new QueryTestFailedException(t);
// }
// 
// 
// }
public synchronized Connection createDriverConnection(String identifier) throws QueryTestFailedException {
    DataSource ds = null;
    if (identifier != null) {
        ds = DataSourceMgr.getInstance().getDataSource(identifier);
    }
    if (ds == null) {
        throw new TransactionRuntimeException("Program Error: DataSource is not mapped to Identifier " + identifier);
    }
    Connection conn = ds.getConnection();
    if (conn != null)
        return conn;
    ConnectionStrategy cs = null;
    if (identifier == null) {
        cs = new DriverConnection(ds.getProperties());
    } else {
        cs = new DriverConnection(ds.getProperties());
    }
    // conn = cs.getConnection();
    // 
    // conn = (Connection) Proxy.newProxyInstance(Thread.currentThread()
    // .getContextClassLoader(),
    // new Class[] { java.sql.Connection.class },
    // new CloseInterceptor(conn));
    ds.setConnection(cs.getConnection());
    return ds.getConnection();
}
Also used : TransactionRuntimeException(org.teiid.test.framework.exception.TransactionRuntimeException) Connection(java.sql.Connection) XAConnection(javax.sql.XAConnection) DataSource(org.teiid.test.framework.datasource.DataSource)

Example 9 with TransactionRuntimeException

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

the class ClassFactory method createExpectedResults.

public static ExpectedResults createExpectedResults(Collection<?> args) {
    String clzzname = ConfigPropertyLoader.getInstance().getProperty(EXPECTED_RESULTS_CLASSNAME);
    if (clzzname == null) {
        clzzname = EXPECTED_RESULTS_DEFAULT_CLASSNAME;
    }
    ExpectedResults expResults;
    try {
        expResults = (ExpectedResults) ReflectionHelper.create(clzzname, args, null);
    } catch (Exception e) {
        throw new TransactionRuntimeException(e.getMessage());
    }
    return expResults;
}
Also used : TransactionRuntimeException(org.teiid.test.framework.exception.TransactionRuntimeException) TransactionRuntimeException(org.teiid.test.framework.exception.TransactionRuntimeException)

Example 10 with TransactionRuntimeException

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

the class ClassFactory method createQueryScenario.

public static QueryScenario createQueryScenario(String scenarioName) {
    String clzzname = ConfigPropertyLoader.getInstance().getProperty(QUERY_SCENARIO_CLASSNAME);
    if (clzzname == null || clzzname.startsWith("${")) {
        clzzname = QUERY_SCENARIO_DEFAULT_CLASSNAME;
    }
    Collection<Object> args = new ArrayList<Object>(2);
    args.add(scenarioName);
    args.add(ConfigPropertyLoader.getInstance().getProperties());
    QueryScenario scenario;
    try {
        scenario = (QueryScenario) ReflectionHelper.create(clzzname, args, null);
    } catch (Exception e) {
        e.printStackTrace();
        throw new TransactionRuntimeException(e);
    }
    return scenario;
}
Also used : ArrayList(java.util.ArrayList) TransactionRuntimeException(org.teiid.test.framework.exception.TransactionRuntimeException) TransactionRuntimeException(org.teiid.test.framework.exception.TransactionRuntimeException)

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