Search in sources :

Example 11 with TransactionRuntimeException

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

the class ClassFactory method createQueryReader.

public static QueryReader createQueryReader(Collection<?> args) {
    String clzzname = ConfigPropertyLoader.getInstance().getProperty(QUERY_READER_CLASSNAME);
    if (clzzname == null) {
        clzzname = QUERY_READER_DEFAULT_CLASSNAME;
    }
    QueryReader reader;
    try {
        reader = (QueryReader) ReflectionHelper.create(clzzname, args, null);
    } catch (Exception e) {
        e.printStackTrace();
        throw new TransactionRuntimeException(e);
    }
    return reader;
}
Also used : TransactionRuntimeException(org.teiid.test.framework.exception.TransactionRuntimeException) TransactionRuntimeException(org.teiid.test.framework.exception.TransactionRuntimeException)

Example 12 with TransactionRuntimeException

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

the class ClassFactory method createResultsGenerator.

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

Example 13 with TransactionRuntimeException

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

the class XMLQueryReader method loadQueries.

private List<QueryTest> loadQueries(String querySetID, String queryFileName) throws IOException {
    // Map<String, Object> queries = new HashMap<String, Object>();
    File queryFile = new File(queryFileName);
    if (!queryFile.exists() || !queryFile.canRead()) {
        String msg = "Query file doesn't exist or cannot be read: " + queryFileName + ", ignoring and continuing";
        TestLogger.log(msg);
        // $NON-NLS-1$ //$NON-NLS-2$
        throw new TransactionRuntimeException(msg);
    }
    // Get query set name
    // String querySet = getQuerySetName(queryFileName) ; //$NON-NLS-1$
    XMLQueryVisitationStrategy jstrat = new XMLQueryVisitationStrategy();
    try {
        return jstrat.parseXMLQueryFile(this.queryScenarioIdentifier, queryFile, querySetID);
    // Iterator iter = queryMap.keySet().iterator();
    // while (iter.hasNext()) {
    // String queryID = (String) iter.next();
    // String query = (String) queryMap.get(queryID);
    // 
    // String uniqueID = querySetID + "_" + queryID;
    // queries.put(uniqueID, query);
    // }
    } catch (Exception e) {
        // $NON-NLS-1$ //$NON-NLS-2$
        String msg = "Error reading query file: " + queryFileName + ", " + e.getMessage();
        TestLogger.log(msg);
        // $NON-NLS-1$ //$NON-NLS-2$
        throw new IOException(msg);
    }
// return queries;
}
Also used : TransactionRuntimeException(org.teiid.test.framework.exception.TransactionRuntimeException) IOException(java.io.IOException) File(java.io.File) IOException(java.io.IOException) QueryTestFailedException(org.teiid.test.framework.exception.QueryTestFailedException) TransactionRuntimeException(org.teiid.test.framework.exception.TransactionRuntimeException)

Example 14 with TransactionRuntimeException

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

the class CTCQueryScenario method setUp.

protected void setUp() {
    try {
        reader = new XMLQueryReader(this.getQueryScenarioIdentifier(), this.getProperties());
    } catch (QueryTestFailedException e1) {
        throw new TransactionRuntimeException(e1);
    }
    resultsGen = new XMLGenerateResults(this.getQueryScenarioIdentifier(), this.getProperties());
    if (reader.getQuerySetIDs() == null || reader.getQuerySetIDs().isEmpty()) {
        throw new TransactionRuntimeException("The queryreader did not return any queryset ID's to process");
    }
    validateResultsMode(this.getProperties());
}
Also used : QueryTestFailedException(org.teiid.test.framework.exception.QueryTestFailedException) TransactionRuntimeException(org.teiid.test.framework.exception.TransactionRuntimeException)

Example 15 with TransactionRuntimeException

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

the class QueryScenarioImpl method handleTestResult.

/* (non-Javadoc)
     * @see org.teiid.test.client.QueryScenario#handleTestResult(org.teiid.test.client.TestResult, java.lang.String)
     */
@Override
public void handleTestResult(TestResult tr, ResultSet resultSet, int updateCnt, boolean resultFromQuery, String sql) {
    Throwable resultException = tr.getException();
    if (getResultsMode().equalsIgnoreCase(TestProperties.RESULT_MODES.COMPARE)) {
        Object results = null;
        try {
            results = this.getExpectedResults(tr.getQuerySetID()).compareResults(tr.getQueryID(), sql, resultSet, resultException, tr.getStatus(), isOrdered(sql), updateCnt, resultFromQuery);
            if (results == null) {
                tr.setStatus(TestResult.RESULT_STATE.TEST_SUCCESS);
            } else {
                tr.setStatus(TestResult.RESULT_STATE.TEST_EXCEPTION);
                tr.setExceptionMessage("Results did not compare to expected results");
            }
        } catch (QueryTestFailedException qtf) {
            resultException = (resultException != null ? resultException : qtf);
            tr.setException(resultException);
            tr.setStatus(TestResult.RESULT_STATE.TEST_EXCEPTION);
        }
        if (tr.getStatus() == TestResult.RESULT_STATE.TEST_EXCEPTION) {
            try {
                this.getResultsGenerator().generateErrorFile(tr.getQuerySetID(), tr.getQueryID(), sql, resultSet, resultException, results);
            } catch (QueryTestFailedException qtfe) {
                throw new TransactionRuntimeException(qtfe.getMessage());
            }
        }
    } else if (getResultsMode().equalsIgnoreCase(TestProperties.RESULT_MODES.GENERATE)) {
        try {
            this.getResultsGenerator().generateQueryResultFile(tr.getQuerySetID(), tr.getQueryID(), sql, resultSet, resultException, tr.getStatus());
        } catch (QueryTestFailedException qtfe) {
            throw new TransactionRuntimeException(qtfe.getMessage());
        }
    } else {
        // just create the error file for any failures
        if (tr.getException() != null) {
            tr.setStatus(TestResult.RESULT_STATE.TEST_EXCEPTION);
            try {
                this.getResultsGenerator().generateErrorFile(tr.getQuerySetID(), tr.getQueryID(), sql, resultSet, resultException, null);
            } catch (QueryTestFailedException qtfe) {
                throw new TransactionRuntimeException(qtfe.getMessage());
            }
        }
    }
}
Also used : QueryTestFailedException(org.teiid.test.framework.exception.QueryTestFailedException) 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