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;
}
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;
}
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();
}
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;
}
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;
}
Aggregations