use of org.teiid.test.framework.exception.TransactionRuntimeException in project teiid by teiid.
the class TransactionContainer method runTransaction.
public void runTransaction(TransactionQueryTestCase test) {
this.testClassName = StringUtil.getLastToken(test.getClass().getName(), ".");
try {
debug("Start transaction test: " + test.getTestName());
try {
test.setup();
} catch (TransactionRuntimeException tre) {
if (!test.exceptionExpected()) {
tre.printStackTrace();
}
throw tre;
} catch (Throwable e) {
if (!test.exceptionExpected()) {
e.printStackTrace();
}
throw new TransactionRuntimeException(e.getMessage());
}
runTest(test);
debug("Completed transaction test: " + test.getTestName());
} finally {
debug(" test.cleanup");
test.cleanup();
}
}
use of org.teiid.test.framework.exception.TransactionRuntimeException in project teiid by teiid.
the class ConnectionStrategy method createDataSourceConnection.
public synchronized XAConnection createDataSourceConnection(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);
}
XAConnection conn = ds.getXAConnection();
if (conn != null)
return conn;
ConnectionStrategy cs = null;
if (identifier == null) {
cs = new DataSourceConnection(ds.getProperties());
} else {
cs = new DataSourceConnection(ds.getProperties());
}
// conn = cs.getXAConnection();
//
// conn = (XAConnection) Proxy.newProxyInstance(Thread.currentThread()
// .getContextClassLoader(),
// new Class[] { javax.sql.XAConnection.class },
// new CloseInterceptor(conn));
ds.setXAConnection(cs.getXAConnection());
return ds.getXAConnection();
}
use of org.teiid.test.framework.exception.TransactionRuntimeException in project teiid by teiid.
the class ConnectionStrategyFactory method createConnectionStrategy.
public static ConnectionStrategy createConnectionStrategy() {
ConfigPropertyLoader configLoader = ConfigPropertyLoader.getInstance();
ConnectionStrategy strategy = null;
Properties props = configLoader.getProperties();
String type = props.getProperty(ConfigPropertyNames.CONNECTION_TYPE, ConfigPropertyNames.CONNECTION_TYPES.DRIVER_CONNECTION);
if (type == null) {
throw new TransactionRuntimeException("Property " + ConfigPropertyNames.CONNECTION_TYPE + " was specified");
}
try {
if (type.equalsIgnoreCase(ConfigPropertyNames.CONNECTION_TYPES.DRIVER_CONNECTION)) {
// pass in null to create new strategy
strategy = new DriverConnection(props);
TestLogger.logDebug("Created Driver Strategy");
} else if (type.equalsIgnoreCase(ConfigPropertyNames.CONNECTION_TYPES.DATASOURCE_CONNECTION)) {
strategy = new DataSourceConnection(props);
TestLogger.logDebug("Created DataSource Strategy");
} else if (type.equalsIgnoreCase(ConfigPropertyNames.CONNECTION_TYPES.JNDI_CONNECTION)) {
strategy = new JEEConnection(props);
TestLogger.logDebug("Created JEE Strategy");
}
if (strategy == null) {
new TransactionRuntimeException("Invalid property value for " + ConfigPropertyNames.CONNECTION_TYPE + " is " + type);
}
// call configure here because this is creating the connection to Teiid
// direct connections to the datasource use the static call directly to create strategy and don't need to configure
strategy.configure();
return strategy;
} catch (Exception e) {
throw new TransactionRuntimeException(e);
}
}
use of org.teiid.test.framework.exception.TransactionRuntimeException in project teiid by teiid.
the class DriverConnection method validate.
public void validate() {
String urlProp = this.getEnvironment().getProperty(DS_URL);
if (urlProp == null || urlProp.length() == 0) {
throw new TransactionRuntimeException("Property " + DS_URL + " was not specified");
}
StringBuffer urlSB = new StringBuffer(urlProp);
String appl = this.getEnvironment().getProperty(DS_APPLICATION_NAME);
if (appl != null) {
urlSB.append(";");
urlSB.append("ApplicationName").append("=").append(appl);
}
url = urlSB.toString();
driver = this.getEnvironment().getProperty(DS_DRIVER);
if (driver == null || driver.length() == 0) {
throw new TransactionRuntimeException("Property " + DS_DRIVER + " was not specified");
}
// need both user variables because Teiid uses 'user' and connectors use
// 'username'
this.username = this.getEnvironment().getProperty(DS_USER);
if (username == null) {
this.username = this.getEnvironment().getProperty(DS_USERNAME);
}
this.pwd = this.getEnvironment().getProperty(DS_PASSWORD);
try {
// Load jdbc driver
Class.forName(driver);
} catch (ClassNotFoundException e) {
throw new TransactionRuntimeException(e);
}
}
use of org.teiid.test.framework.exception.TransactionRuntimeException in project teiid by teiid.
the class DataSourceMgr method getDataSource.
@SuppressWarnings("deprecation")
public DataSource getDataSource(String modelname) {
if (modelToDatasourceMap.containsKey(modelname)) {
return modelToDatasourceMap.get(modelname);
}
try {
DataSource ds = dsfactory.getDatasource(modelname);
if (ds == null) {
printAllDatasources();
try {
Thread.sleep(100000);
} catch (InterruptedException e) {
}
Thread.currentThread().getThreadGroup().stop();
// throw new QueryTestFailedException(
// "Unable to assign a datasource for model "
// + modelname );
}
modelToDatasourceMap.put(modelname, ds);
return ds;
} catch (QueryTestFailedException e) {
throw new TransactionRuntimeException(e);
}
}
Aggregations