Search in sources :

Example 1 with TransactionContainer

use of org.teiid.test.framework.TransactionContainer 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 2 with TransactionContainer

use of org.teiid.test.framework.TransactionContainer in project teiid by teiid.

the class TestClient method runScenario.

private void runScenario() throws Exception {
    String scenario_file = ConfigPropertyLoader.getInstance().getProperty(TestProperties.PROP_SCENARIO_FILE);
    if (scenario_file == null) {
        throw new TransactionRuntimeException(TestProperties.PROP_SCENARIO_FILE + " property was not defined");
    }
    String scenario_name = FileUtils.getBaseFileNameWithoutExtension(scenario_file);
    TestLogger.log("Starting scenario " + scenario_name);
    Properties sc_props = PropertiesUtils.load(scenario_file);
    // 1st perform substitution on the scenario file based on the config and system properties file
    // because the next substitution is based on the scenario file
    Properties sc_updates = getSubstitutedProperties(sc_props);
    if (!sc_updates.isEmpty()) {
        sc_props.putAll(sc_updates);
        this.overrides.putAll(sc_props);
    }
    ConfigPropertyLoader.getInstance().setProperties(sc_props);
    // 2nd perform substitution on current configuration - which will be based on the config properties file
    Properties config_updates = getSubstitutedProperties(ConfigPropertyLoader.getInstance().getProperties());
    if (!config_updates.isEmpty()) {
        this.overrides.putAll(config_updates);
        ConfigPropertyLoader.getInstance().setProperties(config_updates);
    }
    // update the URL with the vdb that is to be used
    String url = ConfigPropertyLoader.getInstance().getProperty(DriverConnection.DS_URL);
    String vdb_name = ConfigPropertyLoader.getInstance().getProperty(DataSourceConnection.DS_DATABASENAME);
    Assert.assertNotNull(DataSourceConnection.DS_DATABASENAME + " property not set, need it for the vdb name", vdb_name);
    url = StringUtil.replace(url, "${vdb}", vdb_name);
    ConfigPropertyLoader.getInstance().setProperty(DriverConnection.DS_URL, url);
    QueryScenario set = ClassFactory.createQueryScenario(scenario_name);
    TransactionContainer tc = getTransactionContainter();
    runTestCase(set, tc);
    TestLogger.log("Completed scenario " + scenario_name);
}
Also used : TransactionContainer(org.teiid.test.framework.TransactionContainer) TransactionRuntimeException(org.teiid.test.framework.exception.TransactionRuntimeException) Properties(java.util.Properties)

Aggregations

TransactionContainer (org.teiid.test.framework.TransactionContainer)2 TransactionRuntimeException (org.teiid.test.framework.exception.TransactionRuntimeException)2 Properties (java.util.Properties)1 JNDITransaction (org.teiid.test.framework.transaction.JNDITransaction)1 LocalTransaction (org.teiid.test.framework.transaction.LocalTransaction)1 TxnAutoTransaction (org.teiid.test.framework.transaction.TxnAutoTransaction)1 XATransaction (org.teiid.test.framework.transaction.XATransaction)1