[teiid-commits] teiid SVN: r1628 - in trunk/test-integration/db/src/main/java/org/teiid/test: client/ctc and 6 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Wed Dec 9 15:17:57 EST 2009


Author: vhalbert at redhat.com
Date: 2009-12-09 15:17:56 -0500 (Wed, 09 Dec 2009)
New Revision: 1628

Added:
   trunk/test-integration/db/src/main/java/org/teiid/test/client/ExpectedResults.java
   trunk/test-integration/db/src/main/java/org/teiid/test/client/QueryReader.java
   trunk/test-integration/db/src/main/java/org/teiid/test/client/QueryScenario.java
   trunk/test-integration/db/src/main/java/org/teiid/test/client/ResultsGenerator.java
   trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java
   trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java
   trunk/test-integration/db/src/main/java/org/teiid/test/client/TestProperties.java
   trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResult.java
   trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java
   trunk/test-integration/db/src/main/java/org/teiid/test/client/TransactionFactory.java
   trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/CTCQueryScenario.java
   trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/ListNestedSortComparator.java
   trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/QueryResults.java
   trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/ResultsHolder.java
   trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/TagNames.java
   trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java
   trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java
   trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryReader.java
   trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryVisitationStrategy.java
   trunk/test-integration/db/src/main/java/org/teiid/test/client/results/TestResultStat.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/TestLogger.java
Modified:
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTestCase.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataStore.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OffWrapTransaction.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OnWrapTransaction.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/StandaloneGlobalTransaction.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java
Log:
Teiid-781 - adding the CTC framework and related changes to support it

Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/ExpectedResults.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ExpectedResults.java	                        (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ExpectedResults.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.test.client;
+
+import java.io.File;
+import java.sql.ResultSet;
+
+import org.teiid.test.framework.exception.QueryTestFailedException;
+
+/**
+ * An ExpectedResults represents one set of expected results (referred to as the queryset) identified by the {@link  #getQuerySetID}.   
+ * The <code>queryidentifier</code> identify a unique query and corresponds to the expected results file.   
+ * 
+ * 
+ * @author vanhalbert
+ *
+ */
+public interface ExpectedResults {
+	
+    /**
+     * The results location is where expected result files can be found
+     */
+    public static final String PROP_EXPECTED_RESULTS_DIR_LOC = "results.loc";
+    
+    /**
+     * {@link #PROP_EXPECTED_RESULTS_ROOT_DIR}, if specified, indicates the root directory 
+     * to be prepended to the {@link #PROP_EXPECTED_RESULTS_DIR_LOC} to create the full
+     * directory to find the expected results files.  
+     * 
+     * This property is normally used during the nightly builds so that the query files
+     * will coming from other projects.
+     */
+
+    public static final String PROP_EXPECTED_RESULTS_ROOT_DIR = "results.dir.loc";
+
+
+    
+    /**
+     * Return the unique identifier for this query set.
+     * @return
+     */
+    String getQuerySetID();
+
+
+	/**
+	 * Returns the <code>File</code> location for the actual results for the specified
+	 * query identifier. 
+	 * @param queryidentifier
+	 * @return File location for actual results for the specified query
+	 * @throws QueryTestFailedException
+	 *
+	 * @since
+	 */
+	File getResultsFile(String queryidentifier) throws QueryTestFailedException;
+	
+	
+	/**
+	 * Indicates if a query expects to have an <code>Exception</code> to be thrown when the
+	 * query is executed.
+	 * @param queryidentifier
+	 * @return boolean true if the query expects an exception to be thrown
+	 * @throws QueryTestFailedException
+	 */
+	boolean isExceptionExpected(String queryidentifier) throws QueryTestFailedException;
+	
+	
+	Object getMetaData(String queryidentifier);
+	
+	
+	/**
+	 * Called to compare the <code>ResultSet</code> from the executed query to the expected results.
+	 * @param queryIdentifier
+	 * @param sql
+	 * @param resultSet
+	 * @param actualException
+	 * @param testStatus
+	 * @param isOrdered
+	 * @param batchSize
+	 * @throws QueryTestFailedException
+	 */
+	void compareResults(final String queryIdentifier,
+			   final String sql,
+               final ResultSet resultSet,
+               final Throwable actualException,
+               final int testStatus,
+               final boolean isOrdered,
+               final int batchSize) throws QueryTestFailedException;
+
+}


Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/ExpectedResults.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/QueryReader.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/QueryReader.java	                        (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/QueryReader.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.test.client;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.teiid.test.framework.exception.QueryTestFailedException;
+
+/**
+ * The QueryReader is responsible for providing a set queries for a given <code>querySetID</code>.
+ * 
+ * The querySetID identifies a set of queries to executed.
+ * The Map structure is as follows:
+ * 
+ * Map: 	Key		-	Value
+ * 		QueryIdentifier		SQL Query
+ * 						
+ * 
+ * Where:
+ * -	QueryIdentifier uniquely identifies a sql query in the set.
+ * 	SQL Query is the query to be executed.
+ * 
+ * @author vanhalbert
+ *
+ */
+public interface QueryReader {
+    
+    /**
+     * {@link #PROP_QUERY_FILES_DIR_LOC} indicates the location to find the query files 
+     */
+    public static final String PROP_QUERY_FILES_DIR_LOC = "queryfiles.loc";
+    /**
+     * {@link #PROP_QUERY_FILES_ROOT_DIR}, if specified, indicates the root directory 
+     * to be prepended to the {@link #PROP_QUERY_FILES_DIR_LOC} to create the full
+     * directory to find the query files.  
+     * 
+     * This property is normally used during the nightly builds so that the query files
+     * will coming from other projects.
+     */
+    public static final String PROP_QUERY_FILES_ROOT_DIR = "queryfiles.root.dir";
+
+    
+    /**
+     * Return the <code>querySetID</code>s that identifies all the query sets
+     * that are available to execute during this test.
+     * 
+     * @return
+     */
+    Collection<String> getQuerySetIDs();
+
+    /**
+     * Return a <code>Map</code> containing the query identifier as the key, and
+     * the value is the query.  In most simple cases, the query will be a <code>String</code>
+     * However, complex types (i.e., to execute prepared statements or other arguments), it maybe
+     * some other type.
+     * 
+     * @return Map
+     * @throws QueryTestFailedException
+     * 
+     * @since
+     */
+    Map<String, Object> getQueries(String querySetID)
+	    throws QueryTestFailedException; // key=queryIdentifier
+																					// Map<String, String> - key = queryIdentifier
+
+}


Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/QueryReader.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/QueryScenario.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/QueryScenario.java	                        (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/QueryScenario.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.test.client;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Properties;
+
+import org.teiid.test.client.TestProperties.RESULT_MODES;
+
+/**
+ * The QueryScenario manages all the information required to run one scenario of tests.
+ * This includes the following:
+ * <li>The queryreader and its query sets to be executed as a scenario </li>
+ * <li>Provides the expected results that correspond to a query set </li>
+ * <li>The results generator that would be used when {@link RESULT_MODES#GENERATE} is specified</li>
+ * 
+ * @author vanhalbert
+ *
+ */
+public interface QueryScenario {
+    
+ 
+    /**
+     * Return the identifier for the current scenario
+     * @return String name of scenario
+     */
+    String getQueryScenarioIdentifier() ;
+    
+    /**
+     * Return the properties defined for this scenario
+     * @return Properties
+     */
+    Properties getProperties();
+    
+    /**
+     * Return a <code>Map</code> containing the query identifier as the key, and
+     * the value is the query.  In most simple cases, the query will be a <code>String</code>
+     * However, complex types (i.e., to execute prepared statements or other arguments), it maybe
+     * some other type.
+     * @param querySetID identifies a set of queries
+     * @return Map<String, Object>
+     */
+    Map<String, Object>  getQueries(String querySetID);
+    
+    /**
+     * Return a <code>Collection</code> of <code>querySetID</code>s that the {@link QueryReader} will be
+     * providing.  The <code>querySetID</code> can be used to obtain it associated set of queries by
+     * call {@link #getQueries(String)}
+     * @return Collection of querySetIDs
+     */
+    Collection<String> getQuerySetIDs();
+    
+    /**
+     * Return the result mode that was defined by the property {@link TestProperties#PROP_RESULT_MODE}
+     * @return String result mode
+     */
+    String getResultsMode();
+    
+    /**
+     * Return the {@link ExpectedResults} for the specified <code>querySetID</code>.  These expected
+     * results will be used to compare with the actual results in order to determine success or failure.
+     * @param querySetID
+     * @return ExpectedResults
+     */
+    ExpectedResults getExpectedResults(String querySetID);
+    
+    /**
+     * Return the {@link ResultsGenerator} that is to be used to create new sets of expected results.
+     * @return
+     */
+    ResultsGenerator getResultsGenerator() ;
+    
+    /**
+     * Return the root output directory where comparison reports or newly generated expected results should be located.
+     */
+    String getOutputDirectory();
+
+
+
+}


Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/QueryScenario.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/ResultsGenerator.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ResultsGenerator.java	                        (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ResultsGenerator.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.test.client;
+
+import java.io.File;
+import java.sql.ResultSet;
+
+import org.teiid.test.framework.exception.QueryTestFailedException;
+
+/**
+ * The ResultsGenerator represents how a new set of results will be written for a given <code>querySetID</code> and <code>queryIdentifier</code>.  The implementor should write out 
+ * one result file for each call that is made to {@link #generateQueryResultFile(String, String, String, ResultSet, Throwable, int)  },
+ * however, it will control the format of the content.
+ * 
+ * The testing process will only generate a new result file when the result mode is {@link TestClientTransaction.RESULT_MODES#GENERATE}
+ * 
+ * @author vanhalbert
+ *
+ */
+public interface ResultsGenerator {
+    /**
+     * The {@link #PROP_GENERATE_DIR} property indicates where newly generated results
+     * files should be written to.   The newly generated files should be written to
+     * a different location than the existing expected results.
+     */
+    public static final String PROP_GENERATE_DIR = "generatedir"; //$NON-NLS-1$
+
+    /**
+     * Return the location that output files are written to.
+     * 
+     * @return
+     * 
+     * @since
+     */
+    String getOutputDir();
+
+    /**
+     * Return the location that results will be generated to.
+     * 
+     * @return
+     * 
+     * @since
+     */
+    String getGenerateDir();
+
+    void generateQueryResultFile(String querySetID, String queryIdentfier,
+	    String query, ResultSet result, Throwable queryError, int testStatus)
+	    throws QueryTestFailedException;
+
+    String generateErrorFile(final String querySetID,
+	    final String queryIdentifier, final String sql,
+	    final ResultSet resultSet, final Throwable queryError,
+	    final File expectedResultsFile) throws QueryTestFailedException;
+
+}


Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/ResultsGenerator.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java	                        (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -0,0 +1,333 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.test.client;
+
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.junit.Assert;
+import org.teiid.test.client.ctc.CTCQueryScenario;
+import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.TestLogger;
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.connection.DataSourceConnection;
+import org.teiid.test.framework.connection.DriverConnection;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+
+import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.core.util.FileUtils;
+import com.metamatrix.core.util.StringUtil;
+
+
+/**
+ * TestClient is the starter class for running bulk sql testing against a Teiid server.
+ * The bulk testing is about testing a lot of queries against a predefined set of 
+ * expected results and providing error files when comparisons don't match.  
+ * The process 
+ * The bulk testing, in its simplicity, will do the following:
+ * <li>use a {@link QueryReader} to read the queries that it will execute</li>
+ * <li>based on the results of each query executed, the process will compare the results
+ * to the {@link ExpectedResults }.</li>
+ * <li>If the {@link TestProperties#PROP_RESULT_MODE} option is set to {@link TestProperties.RESULT_MODES#GENERATE}
+ * 	then the process will not perform a comparison, but generate a new set of expected result files that
+ * 	can in turn be used as the
+ * @author vanhalbert
+ *
+ */
+public class TestClient  {
+
+    public static final SimpleDateFormat TSFORMAT = new SimpleDateFormat(
+	    "HH:mm:ss.SSS"); //$NON-NLS-1$
+
+
+    public TestClient() {
+
+
+    }
+    
+    public static void main(String[] args) {
+
+	TestClient tc = new TestClient();
+	tc.runTest();
+	
+	
+    }
+    
+    public void runTest() {
+	
+	try {
+    
+	    testScenarios();
+	    
+	} catch (Throwable t) {
+	    t.printStackTrace();
+	}
+	
+    }
+ 
+    private void testScenarios() throws Exception {
+	
+	
+//	String teiid_home = deployProperties.getProperty("teiid.home");
+//	File f = new File(teiid_home);
+//	if (f.exists() && f.isDirectory()) {
+//	    FileUtils.removeDirectoryAndChildren(f);
+//	}
+	
+	String scenaios_dir = ConfigPropertyLoader.getInstance().getProperty(TestProperties.PROP_SCENARIO_DIR);
+	if (scenaios_dir == null) {
+	    throw new TransactionRuntimeException("scenariodir property was not defined");
+	}
+	
+	File files[] = FileUtils.findAllFilesInDirectoryHavingExtension(scenaios_dir,
+		".properties");
+	if (files == null || files.length == 0)
+	    throw new QueryTestFailedException((new StringBuilder()).append(
+		    "No scenario files found in directory ").append(scenaios_dir)
+		    .toString());
+	
+	
+	// List<String> queryFiles = new ArrayList<String>(files.length);
+	for (int i = 0; i < files.length; i++) {
+	    runTest(files[i]);
+	}
+	
+
+    }
+    
+    
+    private void runTest(File scenariofile) throws Exception {
+
+	String scenario_name = FileUtils.getBaseFileNameWithoutExtension(scenariofile.getAbsolutePath());
+	
+	TestLogger.log("Starting scenario " + scenario_name);
+	
+	Properties sc_props = PropertiesUtils.load(scenariofile.getAbsolutePath());
+//	updateProps(sc_props);
+	
+	// add the scenario props to the configuration
+	ConfigPropertyLoader.getInstance().setProperties(sc_props);
+	
+	// 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 = new CTCQueryScenario(scenario_name, ConfigPropertyLoader.getInstance().getProperties());
+	
+	TransactionContainer tc = getTransactionContainter();
+
+	runTestCase(set,  tc);
+
+	TestLogger.log("Completed scenario " + scenario_name);
+    }
+    
+    private void runTestCase(QueryScenario queryset,  TransactionContainer tc) throws Exception {
+	String querySetID = null;
+	Map<String, Object> queryTests = null;
+	
+	TestClientTransaction userTxn = new TestClientTransaction(queryset);
+	
+	Iterator<String> qsetIt = queryset.getQuerySetIDs().iterator();
+	
+	TestResultsSummary summary = new TestResultsSummary();
+
+	// iterate over the query set ID's, which there
+	// should be 1 for each file to be processed
+	while (qsetIt.hasNext()) {
+	    querySetID = qsetIt.next();
+
+	    TestLogger.logInfo("Start Query Set [" + querySetID + "]");
+
+	    queryTests = queryset.getQueries(querySetID);
+
+		 // the iterator to process the query tests
+	    Iterator<String> queryTestIt = null;
+	    queryTestIt = queryTests.keySet().iterator();
+	    
+	    List<TestResult> testResults = new ArrayList<TestResult>();
+
+	    
+	    
+	    long beginTS = System.currentTimeMillis();
+	    long endTS = 0;
+	    
+        	while (queryTestIt.hasNext()) {
+        
+        	    String queryidentifier = queryTestIt.next();
+        
+        	    Object sqlObject = queryTests.get(queryidentifier);
+                    	    
+            	    userTxn.init(querySetID, queryidentifier, sqlObject);
+            	    
+        	    // run test
+            	    
+            	    tc.runTransaction(userTxn);
+            	    
+            	    testResults.add(userTxn.getTestResult());
+	             
+        	}
+        	
+        	endTS = System.currentTimeMillis();
+        	
+        	TestLogger.logInfo("End Query Set [" + querySetID + "]");	
+        	
+        	printResultsForSet(summary, testResults, querySetID, queryset, beginTS, endTS);
+        	
+        	testResults.clear();
+	}
+	
+	
+	summary.printTotals(queryset.getResultsGenerator().getOutputDir(), queryset.getQueryScenarioIdentifier());
+	
+	// cleanup all connections created for this test.
+	userTxn.getConnectionStrategy().shutdown();
+	ConfigPropertyLoader.reset();
+
+        
+	
+    }
+
+    
+    protected TransactionContainer getTransactionContainter() {
+	try {
+	    return TransactionFactory.create(ConfigPropertyLoader.getInstance());
+	} catch (QueryTestFailedException e) {
+	    // TODO Auto-generated catch block
+	    e.printStackTrace();
+	    throw new TransactionRuntimeException(e);
+	}
+
+    }
+
+        
+    private void printResultsForSet(final TestResultsSummary summary ,final List<TestResult> testResults, final String querySetID, final QueryScenario querySet, final long beginTS, final long endTS) {
+	    TestLogger.logDebug("Print results for Query Set [" + querySetID
+		    + "]");
+	    try {
+		summary.printResults(querySet.getQueryScenarioIdentifier(), 
+			testResults, 
+			querySet.getProperties(),
+			beginTS, endTS, 1, 1, 
+			querySet.getResultsGenerator().getOutputDir(),
+			querySetID);
+	    } catch (Exception e) {
+		// TODO Auto-generated catch block
+		e.printStackTrace();
+	    }
+
+	    testResults.clear();
+
+    }
+    
+    private void updateProps(Properties props) {
+	Properties configProps = ConfigPropertyLoader.getInstance().getProperties();
+	
+	Iterator it = props.keySet().iterator();
+	while (it.hasNext()) {
+	    String key = (String) it.next();
+	    String value = props.getProperty( key );
+	    String newValue = null;
+	    int loc = value.indexOf("${");
+	    while (loc >= -1) {
+
+		String prop_name = value.substring(loc, value.indexOf("}", loc) );
+		
+		String prop_value = configProps.getProperty(prop_name);
+		if (prop_value != null) {
+		
+		    String newvalue = StringUtil.replace(value, "${" + prop_name + "}", prop_value);
+		    
+		    
+		}
+		loc = value.indexOf("${", loc + 1);
+		
+		
+	    }
+	    if (newValue != null) {
+		ConfigPropertyLoader.getInstance().setProperty(key, newValue);
+	    }
+	    		
+	}
+	
+    }
+
+    
+
+
+    /**
+     * One-time synchronization barrier that allows dynamically reducing the
+     * number of threads expected at the barrier. Captures the timestamp when
+     * all the expected threads arrive at the barrier.
+     * 
+     * @since 4.3
+     */
+//    private static final class TimestampedSynchronizationBarrier {
+//	private int expectedThreads;
+//	private int currentThreads = 0;
+//	private long leaveBarrierTimestamp = -1;
+//
+//	private TimestampedSynchronizationBarrier(int expectedThreads) {
+//	    this.expectedThreads = expectedThreads;
+//	}
+//
+//	private synchronized void barrier(final long waitTime) {
+//	    if ((++currentThreads) == expectedThreads) {
+//		// If all the expected threads have arrived at the barrier, then
+//		// wake them all.
+//		leaveBarrierTimestamp = System.currentTimeMillis();
+//		this.notifyAll();
+//	    } else {
+//		// Otherwise, wait for other threads to arrive.
+//		try {
+//		    wait(waitTime);
+//		} catch (InterruptedException e) {
+//		    System.err
+//			    .println("A thread was unexpectedly interrupted while waiting for other threads to enter the barrier. The measurements for this test will not be accurate.");
+//		    e.printStackTrace(System.err);
+//		    // Let the thread continue on its merry way
+//		}
+//	    }
+//	}
+//
+//	private synchronized void decrementExpectedThreads() {
+//	    if ((--expectedThreads) == currentThreads) {
+//		// If all the remaining threads are already waiting, then wake
+//		// them all.
+//		leaveBarrierTimestamp = System.currentTimeMillis();
+//		this.notifyAll();
+//	    }
+//	}
+//    }
+
+}


Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java	                        (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -0,0 +1,275 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.test.client;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.teiid.test.client.results.TestResultStat;
+import org.teiid.test.framework.TestLogger;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+import org.teiid.test.framework.query.AbstractQueryTransactionTest;
+
+/**
+ * TestClientTransaction
+ * 
+ * @author vanhalbert
+ * 
+ */
+public class TestClientTransaction extends AbstractQueryTransactionTest {
+
+    private QueryScenario querySet = null;
+    private ExpectedResults expectedResults = null;
+
+    // the current querySet info
+    private String querySetID = null;
+    private String queryIdentifier = null;
+    private Object queryObject = null;
+
+    private long endTS = 0;
+    private long beginTS = 0;
+
+    private int testStatus = TestResult.RESULT_STATE.TEST_SUCCESS;
+
+    private TestResult rs = null;
+
+    private boolean errorExpected = false;
+
+    private Throwable resultException = null;
+    
+    private String sql = null;
+
+    public TestClientTransaction(QueryScenario querySet) {
+	super(querySet.getQueryScenarioIdentifier());
+	this.querySet = querySet;
+
+    }
+
+    public void init(String querySetID, String queryIdentifier, Object query) {
+	this.querySetID = querySetID;
+	this.queryIdentifier = queryIdentifier;
+	this.queryObject = query;
+
+	this.expectedResults = null;
+	endTS = 0;
+	beginTS = 0;
+
+	testStatus = TestResult.RESULT_STATE.TEST_SUCCESS;
+
+	rs = null;
+
+	errorExpected = false;
+	resultException = null;
+
+    }
+
+    @Override
+    public void before() {
+	// TODO Auto-generated method stub
+	super.before();
+
+	this.expectedResults = this.querySet
+		.getExpectedResults(this.querySetID);
+
+	try {
+	    this.errorExpected = expectedResults
+		    .isExceptionExpected(this.queryIdentifier);
+	} catch (QueryTestFailedException e) {
+	    // TODO Auto-generated catch block
+	    throw new TransactionRuntimeException("ProgramError: "
+		    + e.getMessage());
+	}
+
+    }
+
+    @Override
+    public void testCase() throws Exception {
+	if (this.queryObject instanceof String) {
+	    this.sql = (String) this.queryObject;
+	    executeTest(this.querySetID, this.queryIdentifier, sql);
+	}
+	
+	// TODO:  support object types for queries (i.e., arguments for prepared statements, etc)
+
+    }
+
+    protected void executeTest(String querySetID, String queryidentifier,
+	    String sql) throws Exception {
+
+        
+	TestLogger.logDebug("execute: " + sql);
+
+	// int expectedRowCount=-1;
+	TestLogger.logDebug("expected error: " + this.errorExpected);
+
+	try {
+	    System.out.println("QueryID: " + this.querySetID + ":"
+		    + this.queryIdentifier);
+	    // need to set this so the underlying query execution handles an
+	    // error properly.
+
+	    beginTS = System.currentTimeMillis();
+	    execute(sql);
+
+	} catch (Throwable t) {
+
+	    resultException = t;
+
+	} finally {
+	    // Capture resp time
+	    endTS = System.currentTimeMillis();
+	}
+
+    }
+
+    @Override
+    public void after() {
+	// TODO Auto-generated method stub
+	super.after();
+
+	String errorfile = null;
+
+	// TODO: uncomment
+	ResultSet erResultSet = null;
+	// this.internalResultSet;
+
+	ResultsGenerator genResults = this.querySet.getResultsGenerator();
+
+	resultException = (this.getLastException() != null ? this
+		.getLastException() : resultException);
+
+	if (resultException != null) {
+	    if (this.exceptionExpected()) {
+		testStatus = TestResult.RESULT_STATE.TEST_EXPECTED_EXCEPTION;
+	    } else {
+		testStatus = TestResult.RESULT_STATE.TEST_EXCEPTION;
+	    }
+
+	}
+
+	if (this.querySet.getResultsMode().equalsIgnoreCase(
+		TestProperties.RESULT_MODES.COMPARE)) {
+	    if (testStatus != TestResult.RESULT_STATE.TEST_EXCEPTION) {
+		try {
+		    this.expectedResults.compareResults(this.queryIdentifier,
+			    sql, this.internalResultSet, resultException,
+			    testStatus, isOrdered(sql), this.fetchSize - 1);
+		} catch (QueryTestFailedException qtf) {
+		    resultException = (resultException != null ? resultException
+			    : qtf);
+		    testStatus = TestResult.RESULT_STATE.TEST_EXCEPTION;
+
+		}
+	    }
+
+	    if (testStatus == TestResult.RESULT_STATE.TEST_EXCEPTION) {
+		try {
+		    genResults.generateErrorFile(querySetID,
+			    this.queryIdentifier, sql, this.internalResultSet,
+			    resultException, expectedResults
+				    .getResultsFile(this.queryIdentifier));
+
+		} catch (QueryTestFailedException qtfe) {
+		    throw new TransactionRuntimeException(qtfe.getMessage());
+		}
+	    }
+
+	} else if (this.querySet.getResultsMode().equalsIgnoreCase(
+		TestProperties.RESULT_MODES.GENERATE)) { //$NON-NLS-1$
+
+	    try {
+		genResults.generateQueryResultFile(querySetID,
+			this.queryIdentifier, sql, erResultSet,
+			resultException, testStatus);
+	    } catch (QueryTestFailedException qtfe) {
+		throw new TransactionRuntimeException(qtfe.getMessage());
+	    }
+
+	} else {
+	    // just create the error file for any failures
+	    if (testStatus == TestResult.RESULT_STATE.TEST_EXCEPTION) {
+		try {
+		    genResults.generateErrorFile(querySetID,
+			    this.queryIdentifier, sql, this.internalResultSet,
+			    resultException, expectedResults
+				    .getResultsFile(this.queryIdentifier));
+
+		} catch (QueryTestFailedException qtfe) {
+		    throw new TransactionRuntimeException(qtfe.getMessage());
+		}
+	    }
+	}
+
+	rs = new TestResultStat(querySetID, this.queryIdentifier, sql,
+		testStatus, beginTS, endTS, resultException, errorfile);
+
+    }
+
+    public TestResult getTestResult() {
+	return this.rs;
+
+    }
+
+    @Override
+    protected Statement createStatement() throws SQLException {
+	return this.internalConnection.createStatement(
+		ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+    }
+
+    // need to override this method because the abstract logic for throwing
+    // exceptions depends on this
+    @Override
+    public boolean exceptionExpected() {
+	// TODO Auto-generated method stub
+	return this.errorExpected;
+    }
+
+    private boolean isOrdered(String sql) {
+
+	if (sql.toLowerCase().indexOf(" order by ") > 0) {
+	    return true;
+	}
+	return false;
+
+    }
+
+    /**
+     * Override the super cleanup() so that the connection to Teiid is not
+     * cleaned up at this time.
+     * 
+     * This will be handled after all queries in the set have been executed.
+     * 
+     * @see TestClient#runTest();
+     * 
+     */
+    @Override
+    public void cleanup() {
+	//	
+	// NOTE: do not cleanup TestResults because {@link #getTestResult} is called
+	// after cleanup
+
+    }
+
+}


Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestProperties.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TestProperties.java	                        (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TestProperties.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.test.client;
+
+/**
+ * @author vanhalbert
+ *
+ */
+public class TestProperties {
+    
+    /**
+     * PROP_SCENARIO_DIR indicates where to find the scenario properties files.
+     * These files must have the .properties extension.
+     */
+    public static final String PROP_SCENARIO_DIR = "scenariodir";
+    
+    /**
+     * PROP_RESULT_MODE controls what to do with the execution results.
+     * 
+     * @see ExpectedResults.RESULT_MODES for the options.
+     */
+    public static final String PROP_RESULT_MODE = "resultmode"; 
+
+    /**
+     * All test options will produce the following basic information at the end
+     * of the test process: <li>how many queries were run</li> <li>how many were
+     * successfull</li> <li>how many errored</li> <li>the execution time for
+     * each query</li> <li>total time for all the tests to run</li>
+     */
+    
+   public interface RESULT_MODES {
+        /**
+         * NONE - will provide the basic information
+         */
+        static final String NONE = "none";
+        /**
+         * COMPARE - will provide the following information, in addition to the
+         * basic information <li>compare actual results with expected results
+         * and produce error files where expected results were not accomplished</li>
+         */
+        static final String COMPARE = "compare";
+        /**
+         * GENERATE - will provide the following information, in addition to the
+         * basic information <li>will generate a new set of expected results
+         * files to the defined PROP_GENERATAE_DIR directory.
+         */
+        static final String GENERATE = "generate";
+    }
+
+    /**
+     * The {@link #PROP_OUTPUT_DIR} property indicates the root directory that output
+     * files will be written.  
+     */
+    public static final String PROP_OUTPUT_DIR = "outputdir"; //$NON-NLS-1$
+
+
+
+}


Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestProperties.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResult.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResult.java	                        (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResult.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -0,0 +1,152 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.test.client;
+
+/**
+ * The TestResult represents the results from a single query.
+ * 
+ * @author vanhalbert
+ * 
+ */
+public interface TestResult {
+
+    /**
+     * The RESULT_STATE is the value assigned based the result of the executed
+     * query test
+     * 
+     * @author vanhalbert
+     * 
+     */
+    public interface RESULT_STATE {
+
+	/**
+	 * TEST_SUCCESS - indicates the executed query performed as expected
+	 */
+	public static final int TEST_SUCCESS = 0;
+	/**
+	 * TEST_EXCEPTION - indicates an unexpected exception occurred during
+	 * the execution of the query
+	 */
+	public static final int TEST_EXCEPTION = 1;
+	/**
+	 * TEST_EXPECTED_EXCEPTION - indicates the expected result was suppose
+	 * to an exception, how, the query executed without error
+	 */
+	public static final int TEST_EXPECTED_EXCEPTION = 4;
+    }
+
+    public interface RESULT_STATE_STRING {
+	/**
+	 * The string value for when a
+	 * {@link TestResult.RESULT_STATE#TEST_SUCCESS occurs
+	 */
+	public static final String PASS = "pass";
+	/**
+	 * The string value for when a
+	 * {@link TestResult.RESULT_STATE#TEST_EXCEPTION occurs
+	 */
+	public static final String FAIL = "fail";
+	/**
+	 * The string value for when a
+	 * {@link TestResult.RESULT_STATE#TEST_EXPECTED_EXCEPTION occurs
+	 */
+	public static final String FAIL_EXPECTED_EXCEPTION = "fail-expected_exception";
+
+	/**
+	 * The string value for when a status occurs that hasn't been defined
+	 */
+	public static final String UNKNOWN = "unknown";
+
+    }
+
+    /**
+     * Return the id the uniquely identifies the query set.
+     * 
+     * @return String is the query set id
+     */
+    String getQuerySetID();
+
+    /**
+     * Return the id that uniquely identifies the query within the query set
+     * {@link #getQuerySetID()}.
+     * 
+     * @return
+     * 
+     * @since
+     */
+    String getQueryID();
+
+    /**
+     * Return the query that was executed in order to produce this result.
+     * 
+     * @return
+     * 
+     * @since
+     */
+    String getQuery();
+
+    /**
+    * Return the status of the execution of this query {@link #getQuery();
+    * @see TestResult.RESULT_STATE
+    * @return
+    *
+    * @since
+    */
+    int getStatus();
+
+    String getResultStatusString();
+
+    /**
+     * If the result from this query produced an exception, then this method
+     * should return the <code>String</code> representation of the exception.
+     * 
+     * @return
+     * 
+     * @since
+     */
+    String getExceptionMsg();
+
+    /**
+     * Return the time (in a long value) that this query started.
+     * 
+     * @return long representation of begin time
+     * 
+     * @since
+     */
+    long getBeginTS();
+
+    /**
+     * Return the time (in a long value) that this query ended
+     * 
+     * @return long representation of end time
+     * 
+     * @since
+     */
+    long getEndTS();
+
+    /**
+     * @return Returns the name of errorfile where the error results were
+     *         written.
+     */
+    String getErrorfile();
+}


Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResult.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java	                        (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -0,0 +1,527 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.test.client;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.text.SimpleDateFormat;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+public class TestResultsSummary  {
+    private static final SimpleDateFormat FILE_NAME_DATE_FORMATER = new SimpleDateFormat(
+	    "yyyyMMdd_HHmmss"); //$NON-NLS-1$
+
+    private static final String NL = System.getProperty("line.separator"); //$NON-NLS-1$
+    
+    // totals for scenario
+    private int total_queries = 0;
+    private int total_pass = 0;
+    private int total_fail = 0;
+    private int total_scenarios = 0;
+ 
+    private static PrintStream getSummaryStream(String outputDir,
+	    String summaryName) throws IOException {
+	File summaryFile = createSummaryFile(outputDir, summaryName);
+	OutputStream os = new FileOutputStream(summaryFile);
+	os = new BufferedOutputStream(os);
+	return new PrintStream(os);
+    }
+
+    /**
+     * Overloaded to overwrite the already existing files
+     */
+    private static PrintStream getSummaryStream(String outputDir,
+	    String summaryName, boolean overwrite) throws IOException {
+
+	// Check Extension is already specified for the file, if not add the
+	// .txt
+	if (summaryName.indexOf(".") == -1) { //$NON-NLS-1$
+	    summaryName = summaryName + ".txt"; //$NON-NLS-1$
+	}
+
+	File summaryFile = new File(outputDir, summaryName);
+	if (summaryFile.exists() && !overwrite) {
+	    throw new IOException(
+		    "Summary file already exists: " + summaryFile.getName()); //$NON-NLS-1$
+	}
+	summaryFile.createNewFile();
+	OutputStream os = new FileOutputStream(summaryFile);
+	os = new BufferedOutputStream(os);
+	return new PrintStream(os);
+    }
+
+    private static File createSummaryFile(String outputDir, String summaryName)
+	    throws IOException {
+	File summaryFile = new File(outputDir, summaryName + ".txt"); //$NON-NLS-1$
+	if (summaryFile.exists()) {
+	    System.err
+		    .println("Summary file already exists: " + summaryFile.getName()); //$NON-NLS-1$
+	    throw new IOException(
+		    "Summary file already exists: " + summaryFile.getName()); //$NON-NLS-1$
+	}
+
+	try {
+	    summaryFile.createNewFile();
+	} catch (IOException e) {
+	    System.err
+		    .println("Failed to create summary file at: " + summaryFile.getAbsolutePath()); //$NON-NLS-1$
+	    throw new IOException(
+		    "Failed to create summary file at: " + summaryFile.getAbsolutePath() + ": " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+	}
+	return summaryFile;
+    }
+
+    private static void printQueryTestResults(PrintStream outputStream,
+	    long testStartTS, long endTS, int numberOfClients,
+	    SimpleDateFormat formatter, Collection results) {
+	outputStream.println("Query Test Results"); //$NON-NLS-1$
+	outputStream.println("=================="); //$NON-NLS-1$
+	outputStream.println("Start        Time: " + new Date(testStartTS)); //$NON-NLS-1$
+	outputStream.println("End          Time: " + new Date(endTS)); //$NON-NLS-1$
+	outputStream
+		.println("Elapsed      Time: " + ((endTS - testStartTS) / 1000) + " seconds"); //$NON-NLS-1$ //$NON-NLS-2$
+	outputStream.println("Number of Clients: " + numberOfClients); //$NON-NLS-1$
+
+	Map passFailGenMap = getPassFailGen(results);
+	outputStream
+		.println("Number of Queries: " + passFailGenMap.get("queries")); //$NON-NLS-1$ //$NON-NLS-2$
+	outputStream
+		.println("Number Passed    : " + passFailGenMap.get("pass")); //$NON-NLS-1$ //$NON-NLS-2$
+	outputStream
+		.println("Number Failed    : " + passFailGenMap.get("fail")); //$NON-NLS-1$ //$NON-NLS-2$
+	outputStream.println("Number Generated : " + passFailGenMap.get("gen")); //$NON-NLS-1$ //$NON-NLS-2$
+
+	ResponseTimes responseTimes = calcQueryResponseTimes(results);
+	outputStream.println("QPS              : " + responseTimes.qps); //$NON-NLS-1$
+
+	outputStream.println("Ave First Resp   : " + responseTimes.first); //$NON-NLS-1$
+
+	outputStream.println("Ave Full Resp    : " + responseTimes.full); //$NON-NLS-1$
+
+	Iterator resultItr = results.iterator();
+	while (resultItr.hasNext()) {
+	    TestResult stat = (TestResult) resultItr.next();
+	    writeQueryResult(outputStream, formatter, stat);
+	}
+
+    }
+
+    private static Map getPassFailGen(Collection results) {
+	Map passFailGenMap = new HashMap();
+	int queries = 0;
+	int pass = 0;
+	int fail = 0;
+	int gen = 0;
+
+	for (Iterator resultsItr = results.iterator(); resultsItr.hasNext();) {
+	    TestResult stat = (TestResult) resultsItr.next();
+	    ++queries;
+	    switch (stat.getStatus()) {
+	    case TestResult.RESULT_STATE.TEST_EXCEPTION:
+		++fail;
+		break;
+	    case TestResult.RESULT_STATE.TEST_SUCCESS:
+		++pass;
+		break;
+	    case TestResult.RESULT_STATE.TEST_EXPECTED_EXCEPTION:
+		++pass;
+		break;
+	    }
+	}
+	passFailGenMap.put("queries", Integer.toString(queries)); //$NON-NLS-1$
+	passFailGenMap.put("pass", Integer.toString(pass)); //$NON-NLS-1$
+	passFailGenMap.put("fail", Integer.toString(fail)); //$NON-NLS-1$
+	//       passFailGenMap.put("gen", Integer.toString(gen)); //$NON-NLS-1$
+	return passFailGenMap;
+    }
+    
+    private void addTotalPassFailGen(Collection results) {
+
+	total_scenarios++;
+	for (Iterator resultsItr = results.iterator(); resultsItr.hasNext();) {
+	    TestResult stat = (TestResult) resultsItr.next();
+	    ++total_queries;
+	    switch (stat.getStatus()) {
+	    case TestResult.RESULT_STATE.TEST_EXCEPTION:
+		++total_fail;
+		break;
+	    case TestResult.RESULT_STATE.TEST_SUCCESS:
+		++total_pass;
+		break;
+	    case TestResult.RESULT_STATE.TEST_EXPECTED_EXCEPTION:
+		++total_pass;
+		break;
+	    }
+	}
+
+    }
+
+    /**
+     * Print test results.
+     * 
+     * @param testStartTS
+     *            The test start time.
+     * @param endTS
+     *            The test end time.
+     * @throws Exception
+     */
+    public void printResults(String testname,
+	    List<TestResult> testResults, Properties props, long testStartTS,
+	    long endTS, int numberOfClients, int runNumber, String outputDir,
+	    String querySetID) throws Exception {
+	//       CombinedTestClient.log("Calculating and printing result statistics"); //$NON-NLS-1$
+	if (testResults.size() > 0) {
+	    // Create output file
+	    String outputFileName = generateFileName(querySetID, System
+		    .currentTimeMillis(), runNumber);
+	    //           CombinedTestClient.log("Creating output file: " + outputFileName); //$NON-NLS-1$
+	    PrintStream outputStream = null;
+	    PrintStream overwriteStream = null;
+	    try {
+		outputStream = getSummaryStream(outputDir, outputFileName);
+		overwriteStream = getSummaryStream(outputDir, querySetID, true); //$NON-NLS-1$
+	    } catch (IOException e) {
+		//              logError("Unable to get output stream for file: " + outputFileName); //$NON-NLS-1$
+		throw e;
+	    }
+	    addTotalPassFailGen(testResults);
+	    // Text File output
+	    printQueryTestResults(outputStream, testStartTS, endTS,
+		    numberOfClients, TestClient.TSFORMAT, testResults);
+	    printQueryTestResults(overwriteStream, testStartTS, endTS,
+		    numberOfClients, TestClient.TSFORMAT, testResults);
+
+	    // HTML Vesion of output
+	    PrintStream htmlStream = getSummaryStream(outputDir, querySetID
+		    + ".html", true); //$NON-NLS-1$
+	    printHtmlQueryTestResults(htmlStream, testStartTS, endTS,
+		    numberOfClients, TestClient.TSFORMAT, testResults);
+	    htmlStream.close();
+
+	    // Wiki Update
+	    //       	CombinedTestUtil.publishResultsToWiki(props, outputDir+File.separator+querySetID+".html", testStartTS, endTS, numberOfClients, testResults); //$NON-NLS-1$ //$NON-NLS-2$
+
+	    // Print results according to test type
+	    // switch (CombinedTestClient.TEST_TYPE) {
+	    // case CombinedTestClient.TEST_TYPE_QUERY:
+	    // // Text File output
+	    // printQueryTestResults(outputStream, testStartTS, endTS,
+	    // numberOfClients, TestClientTransaction.TSFORMAT, testResults);
+	    // printQueryTestResults(overwriteStream, testStartTS, endTS,
+	    // numberOfClients, TestClientTransaction.TSFORMAT, testResults);
+	    //                	
+	    // // HTML Vesion of output
+	    //                	PrintStream htmlStream = getSummaryStream(outputDir, CONFIG_ID+".html", true); //$NON-NLS-1$
+	    // CombinedTestUtil.printHtmlQueryTestResults(htmlStream,
+	    // testStartTS, endTS, numberOfClients,
+	    // TestClientTransaction.TSFORMAT, testResults);
+	    // htmlStream.close();
+	    //                	
+	    // // Wiki Update
+	    //                	CombinedTestUtil.publishResultsToWiki(props, outputDir+File.separator+CONFIG_ID+".html", testStartTS, endTS, numberOfClients, testResults); //$NON-NLS-1$ //$NON-NLS-2$
+	    // break;
+	    // case CombinedTestClient.TEST_TYPE_LOAD:
+	    // CombinedTestUtil.printLoadTestResults(outputStream, testStartTS,
+	    // endTS, numberOfClients, TestClientTransaction.TSFORMAT,
+	    // testResults);
+	    // CombinedTestUtil.printLoadTestResults(overwriteStream,
+	    // testStartTS, endTS, numberOfClients,
+	    // TestClientTransaction.TSFORMAT, testResults);
+	    // break;
+	    // case CombinedTestClient.TEST_TYPE_PERF:
+	    // CombinedTestUtil.printPerfTestResults(outputStream, testStartTS,
+	    // endTS, numberOfClients, CONF_LVL, TestClientTransaction.TSFORMAT,
+	    // testResults);
+	    // CombinedTestUtil.printPerfTestResults(overwriteStream,
+	    // testStartTS, endTS, numberOfClients, CONF_LVL,
+	    // TestClientTransaction.TSFORMAT, testResults);
+	    // break;
+	    // case CombinedTestClient.TEST_TYPE_PROF:
+	    // CombinedTestUtil.printProfTestResults();
+	    // break;
+	    // default:
+	    // break;
+	    // }
+
+	    //        CombinedTestClient.log("Closing output stream"); //$NON-NLS-1$
+	    outputStream.close();
+	    overwriteStream.close();
+	} else {
+	    //          logError("No results to print."); //$NON-NLS-1$
+	}
+    }
+    
+    public void printTotals(String outputDir, String scenario_name) throws Exception {
+
+	    PrintStream outputStream = null;
+	    try {
+		outputStream = getSummaryStream(outputDir, "TotalSummary_" + scenario_name, true); //$NON-NLS-1$
+	    } catch (IOException e) {
+		//              logError("Unable to get output stream for file: " + outputFileName); //$NON-NLS-1$
+		throw e;
+	    }
+	    
+		outputStream.println("Scenario " + scenario_name + " Total Results"); //$NON-NLS-1$
+		outputStream.println("=================="); //$NON-NLS-1$
+		
+		outputStream
+		.println("Number of Scenarios: " + total_scenarios); //$NON-NLS-1$ //$NON-NLS-2$
+		outputStream
+			.println("Number of Queries: " + total_queries); //$NON-NLS-1$ //$NON-NLS-2$
+		outputStream
+			.println("Number Passed    : " + total_pass); //$NON-NLS-1$ //$NON-NLS-2$
+		outputStream
+			.println("Number Failed    : " + total_fail); //$NON-NLS-1$ //$NON-NLS-2$
+
+		    outputStream.close();
+
+	
+    }
+
+    private static String generateFileName(String configName, long timestamp,
+	    int runNumber) {
+	return configName
+		+ "_" + FILE_NAME_DATE_FORMATER.format(new Date(timestamp)) + "_Run-" + runNumber; //$NON-NLS-1$ //$NON-NLS-2$
+    }
+
+    private static void printHtmlQueryTestResults(PrintStream outputStream,
+	    long testStartTS, long endTS, int numberOfClients,
+	    SimpleDateFormat formatter, Collection results) {
+
+	StringBuffer htmlCode = new StringBuffer("<html>").append(NL); //$NON-NLS-1$
+	htmlCode.append("<HEAD>").append(NL); //$NON-NLS-1$
+	htmlCode.append("<TITLE>Query Test Results</TITLE>").append(NL); //$NON-NLS-1$
+	htmlCode.append("<STYLE TYPE=\"text/css\">").append(NL); //$NON-NLS-1$
+	htmlCode
+		.append(
+			"td { font-family: \"New Century Schoolbook\", Times, serif  }").append(NL); //$NON-NLS-1$
+	htmlCode.append("td { font-size: 8pt }").append(NL); //$NON-NLS-1$
+	htmlCode.append("</STYLE>").append(NL); //$NON-NLS-1$
+	htmlCode.append("<SCRIPT type=\"text/javascript\">").append(NL); //$NON-NLS-1$
+	htmlCode.append("var scriptWin = null;").append(NL); //$NON-NLS-1$
+	htmlCode.append("function show(msg){").append(NL); //$NON-NLS-1$
+	//htmlCode.append("alert(msg);").append(nl);       //$NON-NLS-1$
+	htmlCode
+		.append("if (scriptWin == null || scriptWin.closed){").append(NL); //$NON-NLS-1$
+	htmlCode
+		.append(
+			"scriptWin = window.open(\"\", \"script\", \"width=800,height=50,resizable\");").append(NL); //$NON-NLS-1$
+	htmlCode.append("scriptWin.document.open(\"text/plain\");").append(NL); //$NON-NLS-1$
+	htmlCode.append("}").append(NL); //$NON-NLS-1$
+	htmlCode.append("scriptWin.focus();").append(NL); //$NON-NLS-1$
+	htmlCode.append("msg = msg.replace(/#/g, '\"');").append(NL); //$NON-NLS-1$
+	htmlCode.append("scriptWin.document.writeln(msg);").append(NL); //$NON-NLS-1$        
+	htmlCode.append("}").append(NL); //$NON-NLS-1$        
+	htmlCode.append("</SCRIPT>").append(NL); //$NON-NLS-1$        
+	htmlCode.append("</HEAD>").append(NL); //$NON-NLS-1$
+	htmlCode.append("<body>").append(NL); //$NON-NLS-1$
+	htmlCode.append("<h1>Query Test Results</h1>").append(NL); //$NON-NLS-1$
+	htmlCode.append("<table border=\"1\">").append(NL); //$NON-NLS-1$
+
+	addTableRow(htmlCode, "StartTime", new Date(testStartTS).toString()); //$NON-NLS-1$
+	addTableRow(htmlCode, "EndTime", new Date(endTS).toString()); //$NON-NLS-1$
+	addTableRow(htmlCode,
+		"Elapsed Time", ((endTS - testStartTS) / 1000) + " seconds"); //$NON-NLS-1$ //$NON-NLS-2$
+	addTableRow(htmlCode,
+		"Number Of Clients", String.valueOf(numberOfClients)); //$NON-NLS-1$
+
+	Map passFailGenMap = getPassFailGen(results);
+	addTableRow(htmlCode,
+		"Number of Queries:", passFailGenMap.get("queries")); //$NON-NLS-1$ //$NON-NLS-2$
+	addTableRow(htmlCode, "Number Passed    :", passFailGenMap.get("pass")); //$NON-NLS-1$ //$NON-NLS-2$
+	addTableRow(htmlCode, "Number Failed    :", passFailGenMap.get("fail")); //$NON-NLS-1$ //$NON-NLS-2$
+	//       addTableRow(htmlCode, "Number Generated :", passFailGenMap.get("gen")); //$NON-NLS-1$ //$NON-NLS-2$
+
+	ResponseTimes responseTimes = calcQueryResponseTimes(results);
+	addTableRow(htmlCode, "QPS :", Double.toString(responseTimes.qps)); //$NON-NLS-1$ 
+	//        addTableRow(htmlCode, "Ave First Resp   :", Double.toString(responseTimes.first)); //$NON-NLS-1$ 
+	//        addTableRow(htmlCode, "Ave Full Resp    :", Double.toString(responseTimes.full)); //$NON-NLS-1$ 
+
+	htmlCode.append("</table> <p>").append(NL); //$NON-NLS-1$
+	htmlCode.append("<table border=\"1\">").append(NL); //$NON-NLS-1$
+
+	// Add table headers
+	htmlCode.append("<tr style=\"background: #C0C0C0 \">"); //$NON-NLS-1$
+
+	addTableData(htmlCode, "QueryId"); //$NON-NLS-1$
+	addTableData(htmlCode, "Result"); //$NON-NLS-1$
+	addTableData(htmlCode, "First Response"); //$NON-NLS-1$
+	addTableData(htmlCode, "Total Time"); //$NON-NLS-1$
+	addTableData(htmlCode, "Exception"); //$NON-NLS-1$
+	addTableData(htmlCode, "Error File (if any)"); //$NON-NLS-1$
+	htmlCode.append("</tr>").append(NL); //$NON-NLS-1$
+
+	Iterator resultItr = results.iterator();
+	while (resultItr.hasNext()) {
+	    TestResult stat = (TestResult) resultItr.next();
+	    htmlCode.append("<tr>").append(NL); //$NON-NLS-1$            
+	    addTableDataLink(htmlCode, stat.getQueryID(),
+		    "show('" + scrub(stat.getQuery()) + "')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+	    addTableData(htmlCode, stat.getResultStatusString(),
+		    "fail".equalsIgnoreCase(stat.getResultStatusString())); //$NON-NLS-1$
+	    addTableData(htmlCode, Long.toString(stat.getBeginTS()));
+	    addTableData(htmlCode, Long.toString(stat.getEndTS()));
+	    if (stat.getStatus() == TestResult.RESULT_STATE.TEST_EXCEPTION) {
+		addTableData(htmlCode, stat.getExceptionMsg());
+		if (stat.getErrorfile() != null
+			&& !stat.getErrorfile().equals("null")) { //$NON-NLS-1$
+		    addTableDataLink(htmlCode, stat.getErrorfile(), ""); //$NON-NLS-1$ 
+		} else {
+		    addTableData(htmlCode, ""); //$NON-NLS-1$
+		}
+	    } else {
+		addTableData(htmlCode, ""); //$NON-NLS-1$
+		addTableData(htmlCode, ""); //$NON-NLS-1$                                
+	    }
+	    htmlCode.append("</tr>").append(NL); //$NON-NLS-1$
+	}
+	htmlCode.append("</table>").append(NL); //$NON-NLS-1$
+	outputStream.print(htmlCode.toString());
+    }
+
+    private static void addTableRow(StringBuffer table, String column,
+	    Object msg) {
+	table.append("<tr>").append(NL); //$NON-NLS-1$        
+	addTableData(table, column); //$NON-NLS-1$
+	addTableData(table, msg.toString());
+	table.append("</tr>").append(NL); //$NON-NLS-1$        
+    }
+
+    private static void addTableData(StringBuffer table, String msg) {
+	addTableData(table, msg, false);
+    }
+
+    private static void addTableDataLink(StringBuffer table, String link,
+	    String jsEvent) {
+	if (link.indexOf(".") == -1) //$NON-NLS-1$
+	    table
+		    .append("<td>").append("<a href=\"#" + link + "\" onclick=\"" + jsEvent + "\">" + link + "</a>").append("</td>").append(NL); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+	else
+	    table
+		    .append("<td>").append("<a href=\"" + link + "\" onclick=\"" + jsEvent + "\">" + link + "</a>").append("</td>").append(NL); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$         
+    }
+
+    private static void addTableData(StringBuffer table, String msg,
+	    boolean error) {
+	if (error)
+	    table
+		    .append("<td style=\"background: #ffccff \">").append(msg).append("</td>").append(NL); //$NON-NLS-1$ //$NON-NLS-2$
+	else
+	    table.append("<td>").append(msg).append("</td>").append(NL); //$NON-NLS-1$ //$NON-NLS-2$
+    }
+
+    /**
+     * @param results
+     * @return
+     * @since 4.2
+     */
+    private static ResponseTimes calcQueryResponseTimes(Collection queryResults) {
+	ResponseTimes responseTimes = new ResponseTimes();
+	int nQueries = 0;
+	double startTS;
+	// double firstResponseTimeStamp;
+	double fullResponseTimeStamp;
+	double totalSecs = 0.0;
+	double totalFullMilliSecs = 0.0;
+	// double totalFirstMilliSecs = 0.0;
+
+	for (Iterator resultItr = queryResults.iterator(); resultItr.hasNext();) {
+	    TestResult result = (TestResult) resultItr.next();
+	    ++nQueries;
+
+	    startTS = result.getBeginTS();
+	    // firstResponseTimeStamp = result.getBeginTS();
+	    fullResponseTimeStamp = result.getEndTS();
+	    totalSecs += ((fullResponseTimeStamp - startTS) / 1000);
+
+	    // totalFirstMilliSecs += (firstResponseTimeStamp - startTS);
+	    totalFullMilliSecs += (fullResponseTimeStamp - startTS);
+	}
+
+	responseTimes.qps = (totalSecs > 0 ? nQueries / totalSecs : -1.0);
+	// responseTimes.first = (nQueries > 0 ? totalFirstMilliSecs / nQueries
+	// : -1.0);
+	responseTimes.full = (nQueries > 0 ? totalFullMilliSecs / nQueries
+		: -1.0);
+	return responseTimes;
+    }
+
+    private static String scrub(String str) {
+	// Scrub the query
+	if (str != null) {
+	    str = str.replace('"', '#');
+	    str = str.replace('\'', '#');
+	}
+	return str;
+    }
+
+    /**
+     * @param outputStream
+     * @param formatter
+     * @param stat
+     */
+    private static void writeQueryResult(PrintStream outputStream,
+	    SimpleDateFormat formatter, TestResult stat) {
+	outputStream.print(stat.getQueryID());
+	outputStream.print(","); //$NON-NLS-1$
+	outputStream.print(stat.getResultStatusString());
+	outputStream.print(","); //$NON-NLS-1$
+	outputStream.print(stat.getBeginTS());
+	outputStream.print(","); //$NON-NLS-1$
+	outputStream.print(stat.getEndTS());
+	outputStream.print(","); //$NON-NLS-1$
+	outputStream.print(getFormattedTimestamp(formatter, stat.getBeginTS()));
+	//        outputStream.print(","); //$NON-NLS-1$
+	// outputStream.print(getFormattedTimestamp(formatter,
+	// stat.getFirstRepsonseTimeStamp()));
+	outputStream.print(","); //$NON-NLS-1$
+	outputStream.print(getFormattedTimestamp(formatter, stat.getEndTS()));
+	outputStream.print(","); //$NON-NLS-1$
+	outputStream
+		.println((stat.getStatus() != TestResult.RESULT_STATE.TEST_SUCCESS ? stat
+			.getExceptionMsg()
+			: "")); //$NON-NLS-1$
+    }
+
+    private static String getFormattedTimestamp(SimpleDateFormat format,
+	    long millis) {
+	return format.format(new Date(millis));
+    }
+
+    private static class ResponseTimes {
+	double first; // millis
+	double full; // millis
+	double qps; // secs
+    }
+
+}


Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/TransactionFactory.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TransactionFactory.java	                        (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TransactionFactory.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.test.client;
+
+import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+import org.teiid.test.framework.transaction.JNDITransaction;
+import org.teiid.test.framework.transaction.LocalTransaction;
+import org.teiid.test.framework.transaction.OffWrapTransaction;
+import org.teiid.test.framework.transaction.OnWrapTransaction;
+import org.teiid.test.framework.transaction.OptimisticWrapTransaction;
+import org.teiid.test.framework.transaction.PessimisticWrapTransaction;
+import org.teiid.test.framework.transaction.XATransaction;
+
+
+/**
+ * TransactionFactory is used so that the type of {@link TransactionContainer } can be dynamically loaded
+ * based on a property.
+ * 
+ * Specify the property {@link #TRANSACTION_TYPE} in order to set the transaction type to use.
+ * 
+ * @author vanhalbert
+ *
+ */
+public class TransactionFactory {
+    
+
+	/**
+	 * Transaction Type indicates the type of transaction container to use
+	 * @see TransactionFactory
+	 */
+    public static final String TRANSACTION_TYPE = "transaction-type"; //$NON-NLS-1$
+
+    public interface TRANSACTION_TYPES {
+		public static final String LOCAL_TRANSACTION = "local";     //$NON-NLS-1$
+		public static final String XATRANSACTION = "xa"; //$NON-NLS-1$
+		public static final String JNDI_TRANSACTION = "jndi"; //$NON-NLS-1$
+		public static final String OFFWRAP_TRANSACTION = "offwrap"; //$NON-NLS-1$
+		public static final String ONWRAP_TRANSACTION = "onwrap"; //$NON-NLS-1$
+		public static final String OPTIMISTICWRAP_TRANSACTION = "optwrap"; //$NON-NLS-1$
+		public static final String PESSIMISTICWRAP_TRANSACTION = "pesswrap"; //$NON-NLS-1$
+   }
+	
+
+        
+    private TransactionFactory(){}
+        
+    
+    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" );
+        } 
+        
+        System.out.println("Create TransactionContainer: " + 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 OffWrapTransaction();
+        }
+        else if (type.equalsIgnoreCase(TRANSACTION_TYPES.ONWRAP_TRANSACTION)) {
+        	transacton = new OnWrapTransaction();
+        }
+            else if (type.equalsIgnoreCase(TRANSACTION_TYPES.OPTIMISTICWRAP_TRANSACTION)) {
+        	transacton = new OptimisticWrapTransaction();
+        }
+        else if (type.equalsIgnoreCase(TRANSACTION_TYPES.PESSIMISTICWRAP_TRANSACTION)) {
+        	transacton = new PessimisticWrapTransaction();
+
+
+        } else {
+        	throw new TransactionRuntimeException("Invalid property value of " + type + " for " + TRANSACTION_TYPE );
+        }
+
+        return transacton;
+    }
+    
+}


Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/TransactionFactory.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/CTCQueryScenario.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/CTCQueryScenario.java	                        (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/CTCQueryScenario.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -0,0 +1,200 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.test.client.ctc;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Properties;
+
+import org.junit.Assert;
+import org.teiid.test.client.ExpectedResults;
+import org.teiid.test.client.QueryReader;
+import org.teiid.test.client.QueryScenario;
+import org.teiid.test.client.ResultsGenerator;
+import org.teiid.test.client.TestProperties;
+import org.teiid.test.client.TestProperties.RESULT_MODES;
+import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.TestLogger;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+
+import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.core.util.FileUtils;
+
+/**
+ * The TestQuerySet contains all the information required to run one set of tests.
+ * This includes the following:
+ * <li>The queryreader and its query sets to be executed as a scenario </li>
+ * <li>Provides the expected results that correspond to a query set </li>
+ * <li>The results generator that would be used when {@link RESULT_MODES#GENERATE} is specified</li>
+ * 
+ * @author vanhalbert
+ *
+ */
+public class CTCQueryScenario implements QueryScenario {
+    
+    private String resultMode = TestProperties.RESULT_MODES.NONE;
+
+    private QueryReader reader = null;
+    private ResultsGenerator genResults = null;    
+    private Properties props;
+    private String outputDir = null;
+    
+    private String scenario_test_name;
+    
+    public CTCQueryScenario(String scenarioName, Properties querySetProperties) {
+	this.props = querySetProperties;
+	this.scenario_test_name = scenarioName;
+	setup();
+    }
+    
+
+
+    public String getQueryScenarioIdentifier() {
+	return this.scenario_test_name;
+    }
+
+
+    private void setup() {
+	
+	TestLogger.logDebug("Perform TestClient Setup");
+	Properties props = ConfigPropertyLoader.getInstance().getProperties();
+	
+	outputDir = props.getProperty(TestProperties.PROP_OUTPUT_DIR, ".");
+
+	Assert.assertNotNull("Property " + TestProperties.PROP_OUTPUT_DIR
+		+ " was not specified", outputDir);
+	
+	outputDir = outputDir + "/" + scenario_test_name;
+
+	
+	try {
+	    
+	    
+	    validateResultsMode(props);
+	    
+	    setupVDBs(props);
+	    
+	    reader = new XMLQueryReader(props);
+	} catch (Exception e) {
+	    // TODO Auto-generated catch block
+	    throw new TransactionRuntimeException(e.getMessage());
+	}
+	
+       genResults = new XMLGenerateResults(this.props, scenario_test_name, outputDir);
+
+
+	if (reader.getQuerySetIDs() == null || reader.getQuerySetIDs().isEmpty()) {
+	    throw new TransactionRuntimeException("No query set ID's were returned");
+	}
+
+    }
+    
+    private void setupVDBs(Properties props) throws IOException {
+	// NOTE: this is probably a hack, because the only way I could get all
+	// the vdb's available when running multiple scenarions
+	// was to update the deploy.properties by setting the vdb.definition
+	// property containing the location of
+	// all the vdbs
+
+	String deployPropLoc = props.getProperty("deployprops.loc");
+	Properties deployProperties = PropertiesUtils.load(deployPropLoc);
+
+	// set the vdb.definition property that contains all the vdbs
+	String vdb_loc = props.getProperty("vdb.loc");
+	File vdbfiles[] = FileUtils.findAllFilesInDirectoryHavingExtension(vdb_loc, ".vdb");
+	if (vdbfiles == null || vdbfiles.length == 0) {
+	    throw new TransactionRuntimeException((new StringBuilder()).append(
+		    "No vdbs found in directory ").append(vdb_loc).toString());
+	}
+	StringBuffer vdbdef = new StringBuffer();
+
+	for (int i = 0; i < vdbfiles.length; i++) {
+	    vdbdef.append(vdbfiles[i].getAbsolutePath() + ";");
+	}
+
+	deployProperties.setProperty("vdb.definition", vdbdef.toString());
+	PropertiesUtils.print(deployPropLoc, deployProperties,"Updated for vdb.definition");
+
+    }
+    
+
+
+    private void validateResultsMode(Properties props) {
+	// Determine from property what to do with query results
+	String resultModeStr = props.getProperty(TestProperties.PROP_RESULT_MODE, "");
+	// No need to check for null prop here since we've just checked for this
+	// required property
+
+	if (resultModeStr.equalsIgnoreCase(TestProperties.RESULT_MODES.NONE) ||
+		resultModeStr.equalsIgnoreCase(TestProperties.RESULT_MODES.COMPARE) ||
+		resultModeStr.equalsIgnoreCase(TestProperties.RESULT_MODES.GENERATE)) { //$NON-NLS-1$
+	    resultMode = resultModeStr;
+	} 
+	// otherwise use default of NONE
+
+	TestLogger.log("\nResults mode: " + resultMode); //$NON-NLS-1$
+
+    }
+    
+    public Properties getProperties() {
+	return this.props;
+    }
+    
+    public Map<String, Object>  getQueries(String querySetID) {
+	try {
+	    return reader.getQueries(querySetID);
+	} catch (QueryTestFailedException e) {
+		throw new TransactionRuntimeException(e);
+	}
+    }
+    
+    public Collection<String> getQuerySetIDs() {
+	return reader.getQuerySetIDs();
+    }
+    
+    public String getResultsMode() {
+	return this.resultMode;
+    }
+    
+    public ExpectedResults getExpectedResults(String querySetID) {    
+	XMLExpectedResults expectedResults = new XMLExpectedResults(this.props, querySetID);
+	return expectedResults;
+    }
+    
+    
+    public ResultsGenerator getResultsGenerator() {
+	return this.genResults;
+    }
+
+
+
+    @Override
+    public String getOutputDirectory() {
+	return outputDir;
+    }
+
+
+
+}


Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/CTCQueryScenario.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/ListNestedSortComparator.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/ListNestedSortComparator.java	                        (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/ListNestedSortComparator.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -0,0 +1,169 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.test.client.ctc;
+
+import java.util.List;
+
+import com.metamatrix.core.util.ArgCheck;
+
+
+
+/**
+ * This class can be used for comparing lists of elements, when the fields to
+ * be sorted on and the comparison mechanism are dynamically specified. <p>
+ *
+ * Typically, the lists are records in a collection that is to be sorted. <p>
+ *
+ * <h3>Example</h3>
+ * <pre>
+ *    Records...
+ *      { "a1", "b1", "c1" } 
+ *      { "a1", "b1", "c2" }
+ *      { "a1", "b2", "c1" }
+ *      { "a1", "b2", "c2" }
+ *      { "a2", "b1", "c1" } 
+ *      { "a2", "b1", "c2" } 
+ *      { "a2", "b2", "c1" } 
+ *      { "a2", "b2", "c2" }
+ *
+ *    Records sorted in ascending order on columns 0, 2...
+ *      { "a1", "b1", "c1" } 
+ *      { "a1", "b2", "c1" }
+ *      { "a1", "b2", "c2" }
+ *      { "a1", "b1", "c2" }
+ *      { "a2", "b1", "c1" } 
+ *      { "a2", "b2", "c1" } 
+ *      { "a2", "b1", "c2" } 
+ *      { "a2", "b2", "c2" } 
+ * </pre>
+ */
+public class ListNestedSortComparator implements java.util.Comparator, java.io.Serializable {
+
+    /**
+     * Specifies which fields to sort on.
+     */
+    private int[] sortParameters;
+
+    /**
+     * Indicates whether comparison should be based on ascending or descending
+     * order.
+     */
+    private boolean ascendingOrder = false;
+
+    /**
+     * List of booleans indicating the order in which each column should be sorted
+     */
+    private List orderTypes = null;
+    
+    private boolean isDistinct = true;
+    private int distinctIndex;
+
+    /**
+     * Constructs an instance of this class given the indicies of the parameters
+     * to sort on, and whether the sort should be in ascending or descending
+     * order.
+     */
+    public ListNestedSortComparator( int[] sortParameters ) {
+        this( sortParameters, false );
+    }
+
+    /**
+     * Constructs an instance of this class given the indicies of the parameters
+     * to sort on, and whether the sort should be in ascending or descending
+     * order.
+     */
+    public ListNestedSortComparator( int[] sortParameters, boolean ascending ) {
+        this.sortParameters = sortParameters;
+        this.ascendingOrder = ascending;
+    }
+
+    /**
+     * Constructs an instance of this class given the indicies of the parameters
+     * to sort on, and orderList used to determine the order in which each column
+     * is sorted.
+     */
+    public ListNestedSortComparator( int[] sortParameters, List orderTypes ) {
+        this.sortParameters = sortParameters;
+        this.orderTypes = orderTypes;
+    }
+    
+    public boolean isDistinct() {
+		return isDistinct;
+	}
+    
+    public void setDistinctIndex(int distinctIndex) {
+		this.distinctIndex = distinctIndex;
+	}
+
+    /**
+     * Compares its two arguments for order.  Returns a negative integer,
+     * zero, or a positive integer as the first argument is less than,
+     * equal to, or greater than the second. <p>
+     *
+     * The <code>compare</code> method returns <p>
+     * <ul>
+     *      <li>-1 if object1 less than object 2 </li>
+     *      <li> 0 if object1 equal to object 2 </li>
+     *      <li>+1 if object1 greater than object 2 </li>
+     * </ul>
+     *
+     * @param o1 The first object being compared
+     * @param o2 The second object being compared
+     */
+    public int compare( Object o1, Object o2 ) {
+        List list1 = (List)o1;
+        List list2 = (List)o2;
+
+        int compare = 0;
+        for (int k = 0; k < sortParameters.length; k++) {
+            Object param1 = list1.get(sortParameters[k]);
+            Object param2 = list2.get(sortParameters[k]);
+
+            if( param1 == null ) {
+				if(param2 == null ) {
+					// Both are null
+					compare = 0;
+				} else {
+					// param1 = null, so is less than a non-null
+					compare = -1;
+				}
+			} else if( param2 == null ) {
+				// param1 != null, param2 == null
+				compare = 1;
+			} else if ( param1 instanceof Comparable ) {
+                compare = ((Comparable)param1).compareTo(param2);
+            } else {
+            	ArgCheck.isTrue(false, "Expected comparable types");
+            }
+            if (compare != 0) {
+            	boolean asc = orderTypes != null?((Boolean)orderTypes.get(k)).booleanValue():this.ascendingOrder;
+                return asc ? compare : -compare;
+            } else if (k == distinctIndex) {
+        		isDistinct = false;
+        	}
+        }
+    	return 0;
+    }
+    
+} // END CLASS    
+


Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/ListNestedSortComparator.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/QueryResults.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/QueryResults.java	                        (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/QueryResults.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -0,0 +1,745 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.test.client.ctc;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import com.metamatrix.common.buffer.TupleBatch;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.query.sql.symbol.AliasSymbol;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
+import com.metamatrix.query.sql.symbol.GroupSymbol;
+import com.metamatrix.query.sql.symbol.SingleElementSymbol;
+
+/**
+ * This class encapsulates results associated with a query.
+ * <p>
+ * Results are conceptually organized as a table of columns and rows, where the columns are the data fields that were specified in
+ * the query select statement, and the rows are individual records returned from the data set. The data values are arbitrary Java
+ * objects in each field/record cell.
+ * <p>
+ * 
+ * <pre>
+ * 
+ *  
+ *            Record # |  Field1    Field2    Field3   ...    FieldN
+ *           ----------|---------------------------------------------
+ *              1      |  Value11   Value12   Value13         Value1N
+ *              2      |  Value21   Value22   Value23         Value2N
+ *              :      |     :         :         :               :
+ *              M      |  ValueM1   ValueM2   ValueM3         ValueMN
+ *   
+ *  
+ * </pre>
+ * 
+ * <p>
+ * Methods are provided to access data by:
+ * <p>
+ * <ul>
+ * <li>Cell value - specify field identifier and record number</li>
+ * <li>Field values - specify field identifier</li>
+ * <li>Record values - specify record number</li>
+ * <li>Record - specify record number; returns field idents mapped to values</li>
+ * </ul>
+ * <p>
+ * Results can be specified to be sorted based on a user-provided ordering. The ordering is a List of ElementSymbols, which should
+ * match the identifiers for the results fields. This list will typically be in the order that the parameters were specified in
+ * the query select statement. If no ordering list is specified, the order is the same as results fields are added to this object.
+ * <p>
+ */
+public class QueryResults implements
+                         Externalizable {
+
+    /**
+     * Serialization ID - this must be changed if this class is no longer serialization-compatible with old versions.
+     */
+    static final long serialVersionUID = 5397138282301824378L;
+
+    /**
+     * The fields in the results object: List of String
+     */
+    private List fields;
+
+    /**
+     * The column info for each field: Map of String --> ColumnInfo
+     */
+    private Map columnInfos;
+
+    /**
+     * The set of results. Each result is keyed off the variable identifier that was defined in the query's select clause. This
+     * field will never be null.
+     */
+    private List records; // Rows of columns: List<List<Object>>
+
+    // =========================================================================
+    //                         C O N S T R U C T O R S
+    // =========================================================================
+
+    /**
+     * Construct a default instance of this class.
+     * <p>
+     * The number of fields returned by the {@link #getFieldCount}method will be 0 after this constructor has completed. The
+     * number of records returned by the {@link #getRecordCount}method will be 0 after this constructor has completed.
+     * <p>
+     */
+    public QueryResults() {
+    }
+
+    /**
+     * Construct an instance of this class, specifying the order that the elements should be inserted into the map. The number of
+     * fields returned by the {@link #getFieldCount}method will be the same as the number of <code>fields</code> passed in
+     * after this constructor has completed. The number of records returned by the {@link #getRecordCount}method will be 0 after
+     * this constructor has completed.
+     * <p>
+     * 
+     * @param fields
+     *            The set of field identifiers that will be in the result set
+     */
+    public QueryResults(List fields) {
+        this(fields, 0);
+    }
+
+    /**
+     * Construct an instance of this class, specifying the fields and the number of records that the result set should hold. The
+     * fields and number of records are used to pre-allocate memory for all the values that are expected to be indested into the
+     * results set.
+     * <p>
+     * The number of records returned by the {@link #getRecordCount}method will be <code>numberOfRecords</code> after this
+     * constructor has completed. The number of fields returned by the {@link #getFieldCount}will be the same as the size of the
+     * list of fields passed in after this constructor has completed.
+     * <p>
+     * 
+     * @param fields
+     *            The ordered list of variables in select statement
+     * @param numberOfRecords
+     *            The number of blank records to create; records will all contain <code>null</code> values for all the fields
+     * @see #addField
+     */
+    public QueryResults(List fields,
+                        int numberOfRecords) {
+        if (fields != null) {
+            Iterator fieldIter = fields.iterator();
+            while (fieldIter.hasNext()) {
+                ColumnInfo info = (ColumnInfo)fieldIter.next();
+                addField(info);
+            }
+            for (int k = 0; k < numberOfRecords; k++) {
+                addRecord();
+            }
+        }
+    }
+
+    /**
+     * Construct a QueryResults from a TupleBatch. Take all rows from the QueryBatch and put them into the QueryResults.
+     * 
+     * @param elements
+     *            List of SingleElementSymbols
+     * @param tupleBatch
+     *            Batch of rows
+     */
+    public QueryResults(List elements,
+                        TupleBatch tupleBatch) {
+        // Add fields
+        List columnInfos = createColumnInfos(elements);
+        for (int i = 0; i < columnInfos.size(); i++) {
+            ColumnInfo info = (ColumnInfo)columnInfos.get(i);
+            addField(info);
+        }
+
+        // Add records in bulk -
+        this.records = Arrays.asList(tupleBatch.getAllTuples());
+    }
+
+    // =========================================================================
+    //                D A T A A C C E S S M E T H O D S
+    // =========================================================================
+
+    /**
+     * Returns all the field identifiers. If the parameters in the query select statement have been provided, then the set of
+     * field identifiers should be a subset of them, and ordered the same.
+     * <p>
+     * This method will never return <code>null</code>. The list of identifiers returned is not mutable -- changes made to this
+     * list will not affect the QueryResults object.
+     * 
+     * @return The field identifiers
+     */
+    public List getFieldIdents() {
+        return (fields != null) ? fields : new ArrayList();
+    }
+
+    /**
+     * Get the column information given the column name.
+     * 
+     * @param columnName
+     *            The name of the column.
+     * @return Column information
+     */
+    public ColumnInfo getColumnInfo(String columnName) {
+        if (columnInfos != null) {
+            return (ColumnInfo)columnInfos.get(columnName);
+        }
+        return null;
+    }
+
+    /**
+     * Returns the number of fields in the result set.
+     * 
+     * @return The number of fields
+     */
+    public int getFieldCount() {
+        return (fields != null) ? fields.size() : 0;
+    }
+
+    /**
+     * Returns the number of records in the result set.
+     * <p>
+     * 
+     * @return The number of records
+     */
+    public int getRecordCount() {
+        return (records != null) ? records.size() : 0;
+    }
+
+    /**
+     * Get the value for the specified field and record.
+     * <p>
+     * The value returned is not mutable -- changes made to this value will not affect the QueryResults object.
+     * <p>
+     * <b>Note that results must be retrieved with the same type of data node identifier that was specified in the select
+     * statement. </b>
+     * <p>
+     * 
+     * @param columnName
+     *            The unique data element identifier for the field
+     * @param recordNumber
+     *            The record number
+     * @return The data value at the specified field and record
+     * @exception IllegalArgumentException
+     *                If field is not in result set
+     * @exception IndexOutOfBoundsException
+     *                If record is not in result set
+     */
+    public Object getValue(String columnName,
+                           int recordNumber) throws IllegalArgumentException,
+                                            IndexOutOfBoundsException {
+
+        // This throws an IllegalArgumentException if field not in result set
+        int columnNumber = getIndexOfField(columnName);
+
+        return (records != null) ? ((List)records.get(recordNumber)).get(columnNumber) : null;
+    }
+
+    /**
+     * Returns the values for the specified record. The values are ordered the same as the field identifiers in the result set,
+     * which will be the same as the order of the query select parameters if they have been provided.
+     * <p>
+     * The list of values returned is not mutable -- changes made to this list will not affect the QueryResults object.
+     * <p>
+     * 
+     * @param recordNumber
+     *            The record number
+     * @return A list containing the field values for the specified record, ordered according to the original select parameters,
+     *         if defined
+     */
+    public List getRecordValues(int recordNumber) throws IndexOutOfBoundsException {
+
+        if (records != null) {
+            return (List)records.get(recordNumber);
+        }
+        throw new IndexOutOfBoundsException("Record number " + recordNumber + " is not valid.");
+    }
+
+    /**
+     * Get the records contained in this result. The records are returned as a list of field values (a list of lists).
+     * 
+     * @return A list of lists contains the field values for each row.
+     */
+    public List getRecords() {
+        return records;
+    }
+
+    /**
+     * Returns true if the specified field is in the result set.
+     * 
+     * @param field
+     *            Unique identifier for a data element specified in result set
+     */
+    public boolean containsField(String field) {
+        if (fields != null && field != null) {
+            Iterator iter = fields.iterator();
+            while (iter.hasNext()) {
+                if (((String)iter.next()).equalsIgnoreCase(field)) {
+                    return true;
+                }
+            }
+        }
+
+        return false;
+    }
+
+    public List getTypes() {
+        List typeNames = new ArrayList();
+
+        int nFields = getFieldCount();
+        for (int i = 0; i < nFields; i++) {
+            String aField = (String)fields.get(i);
+            typeNames.add(((ColumnInfo)columnInfos.get(aField)).getDataType());
+        }
+        return typeNames;
+    }
+
+    // =========================================================================
+    //           D A T A M A N I P U L A T I O N M E T H O D S
+    // =========================================================================
+
+    /**
+     * Add a new field into this result set. The field will be inserted in the order of the parameters in the select statement if
+     * those parameters were specified upon construction of the result set; otherwise, the field will be appended to the result
+     * set.
+     * <p>
+     * 
+     * @param info
+     *            The column information.
+     */
+    public void addField(ColumnInfo info) {
+        // Add to ordered list of fields
+        if (fields == null) {
+            fields = new ArrayList();
+        }
+        fields.add(info.getName());
+
+        // Save column information
+        if (columnInfos == null) {
+            columnInfos = new HashMap();
+        }
+        columnInfos.put(info.getName(), info);
+
+        // Add new field to each record
+        if (records != null) {
+            for (int i = 0; i < records.size(); i++) {
+                List record = (List)records.get(i);
+                record.add(null);
+            }
+        }
+    }
+
+    /**
+     * Add a set of fields into this result set. The fields will be inserted in the order of the parameters in the select
+     * statement if those parameters were specified upon construction of the result set; otherwise, the field will be appended to
+     * the result set.
+     * <p>
+     * 
+     * @param fields
+     *            The field identifiers.
+     */
+    public void addFields(Collection fields) {
+        Iterator idents = fields.iterator();
+        while (idents.hasNext()) {
+            ColumnInfo ident = (ColumnInfo)idents.next();
+            addField(ident);
+        }
+    }
+
+    /**
+     * Add a new record for all fields. The record is populated with all null values, which act as placeholders for subsequent
+     * <code>setValue
+     * </code> calls.
+     * <p>
+     * Before this method is called, the fields must already be defined.
+     * <p>
+     * 
+     * @return The updated number of records
+     */
+    public int addRecord() {
+        // Create a place-holder record
+        int nField = getFieldCount();
+        if (nField == 0) {
+            throw new IllegalArgumentException("Cannot add record; no fields have been defined");
+        }
+        // Create a record with all null values, one for each field
+        List record = new ArrayList(nField);
+        for (int j = 0; j < nField; j++) {
+            record.add(null);
+        }
+        return addRecord(record);
+    }
+
+    /**
+     * Add a new record for all fields. The record must contain the same number of values as there are fields.
+     * <p>
+     * Before this method is called, the fields must already be defined.
+     * <p>
+     * 
+     * @return The updated number of records
+     */
+    public int addRecord(List record) {
+        if (record == null) {
+            throw new IllegalArgumentException("Attempt to add null record.");
+        }
+        if (record.size() != getFieldCount()) {
+            throw new IllegalArgumentException("Attempt to add record with " + record.size() + " values when " + getFieldCount() + " fields are defined.");
+        }
+        if (records == null) {
+            records = new ArrayList();
+        }
+        records.add(record);
+        return records.size();
+    }
+
+    /**
+     * Set the value at a particular record for a field.
+     * <p>
+     * The specified field and record must already exist in the data set, or an exception will be thrown. The
+     * {@link #addField(ColumnInfo)}method can be used to append values or new records for fields.
+     * 
+     * @param field
+     *            The unique data element identifier for the field
+     * @param recordNumber
+     *            The record number
+     * @exception IndexOutOfBoundsException
+     *                If the specified record does not exist
+     */
+    public void setValue(String field,
+                         int recordNumber,
+                         Object value) throws IllegalArgumentException,
+                                      IndexOutOfBoundsException {
+
+        List record = (List)records.get(recordNumber);
+        int fieldIndex = getIndexOfField(field);
+        record.set(fieldIndex, value);
+    }
+
+    // =========================================================================
+    //                     H E L P E R M E T H O D S
+    // =========================================================================
+
+    /**
+     * Returns the index of the specified field is in the result set. An exception is thrown if the field is not in the set.
+     * 
+     * @param field
+     *            Unique identifier for a data element specified in result set
+     * @return The index of the field in the set of fields
+     * @exception IllegalArgumentException
+     *                If field is not in result set
+     */
+    public int getIndexOfField(String field) throws IllegalArgumentException {
+
+        int index = -1;
+        if (fields != null && field != null) {
+            Iterator iter = fields.iterator();
+            for (int i = 0; iter.hasNext(); i++) {
+                if (field.equalsIgnoreCase((String)iter.next())) {
+                    index = i;
+                    break;
+                }
+            }
+        }
+
+        if (index == -1) {
+            throw new IllegalArgumentException("Field with identifier " + field + " is not in result set");
+        }
+        return index;
+    }
+
+    /**
+     * Convert a list of SingleElementSymbols to a List of ColumnInfo objects.
+     * 
+     * @param symbols
+     *            List of SingleElementSymbols
+     * @return List of ColumnInfos
+     */
+    public static List createColumnInfos(List symbols) {
+        List infos = new ArrayList(symbols.size());
+        Iterator iter = symbols.iterator();
+        while (iter.hasNext()) {
+            SingleElementSymbol symbol = (SingleElementSymbol)iter.next();
+            String name = symbol.getName();
+            if (symbol instanceof AliasSymbol) {
+                AliasSymbol alias = (AliasSymbol)symbol;
+                symbol = alias.getSymbol();
+            }
+            if (symbol instanceof ElementSymbol) {
+                ElementSymbol element = (ElementSymbol)symbol;
+                GroupSymbol group = element.getGroupSymbol();
+                Object groupID = null;
+                if (group != null) {
+                    groupID = group.getMetadataID();
+                }
+                infos.add(new ColumnInfo(name, DataTypeManager.getDataTypeName(element.getType()), element.getType(), groupID,
+                                         element.getMetadataID()));
+            } else { // ExpressionSymbol or AggregateSymbol
+                // Expressions don't map to a single element or group, so don't save that info
+                infos.add(new ColumnInfo(name, DataTypeManager.getDataTypeName(symbol.getType()), symbol.getType()));
+            }
+        }
+
+        return infos;
+    }
+
+    // =========================================================================
+    //          O V E R R I D D E N O B J E C T M E T H O D S
+    // =========================================================================
+
+    /** Compares with another result set */
+    public boolean equals(Object object) {
+        if (this == object) {
+            return true;
+        }
+
+        if (!this.getClass().isInstance(object)) {
+            return false;
+        }
+
+        QueryResults other = (QueryResults)object;
+
+        // First compare fields
+        if (!this.getFieldIdents().equals(other.getFieldIdents())) {
+            return false;
+        }
+
+        List thisRecords = this.getRecords();
+        List otherRecords = other.getRecords();
+
+        if (thisRecords == null) {
+            if (otherRecords == null) {
+                return true;
+            }
+            return false;
+        }
+        if (otherRecords == null) {
+            return false;
+        }
+        return thisRecords.equals(otherRecords);
+    }
+
+    /** Returns a string representation of an instance of this class. */
+    public String toString() {
+        StringBuffer buffer = new StringBuffer("Query Results...\n"); //$NON-NLS-1$
+        buffer.append(printFieldIdentsAndTypes(this.getFieldIdents(), this.columnInfos));
+        buffer.append("\n"); //$NON-NLS-1$
+        for (int r = 0; r < this.getRecordCount(); r++) {
+            buffer.append(r);
+            buffer.append(": "); //$NON-NLS-1$
+
+            List record = this.getRecordValues(r);
+            for (int c = 0; c < this.getFieldCount(); c++) {
+                buffer.append(record.get(c));
+                if (c < this.getFieldCount() - 1) {
+                    buffer.append(", "); //$NON-NLS-1$
+                }
+            }
+            buffer.append("\n"); //$NON-NLS-1$
+        }
+        return buffer.toString();
+    }
+
+    private static String printFieldIdentsAndTypes(List fieldIdents,
+                                                   Map columnInfos) {
+        StringBuffer buf = new StringBuffer();
+        Iterator fieldItr = fieldIdents.iterator();
+        while (fieldItr.hasNext()) {
+            String aField = (String)fieldItr.next();
+            if (aField != null) {
+                buf.append("["); //$NON-NLS-1$
+                buf.append(aField);
+                buf.append(" - ["); //$NON-NLS-1$
+                ColumnInfo colInfo = (ColumnInfo)columnInfos.get(aField);
+                buf.append(colInfo.getDataType());
+                buf.append(", "); //$NON-NLS-1$
+                buf.append(colInfo.getJavaClass());
+                buf.append("]"); //$NON-NLS-1$
+            }
+            buf.append("] "); //$NON-NLS-1$
+        }
+
+        return buf.toString();
+    }
+
+    // =========================================================================
+    //                      S E R I A L I Z A T I O N
+    // =========================================================================
+
+    /**
+     * Implements Externalizable interface to read serialized form
+     * 
+     * @param s
+     *            Input stream to serialize from
+     */
+    public void readExternal(java.io.ObjectInput s) throws ClassNotFoundException,
+                                                   IOException {
+        int numFields = s.readInt();
+        if (numFields > 0) {
+            fields = new ArrayList(numFields);
+            columnInfos = new HashMap();
+            for (int i = 0; i < numFields; i++) {
+                String fieldName = s.readUTF();
+                fields.add(fieldName);
+
+                Object colInfo = s.readObject();
+                columnInfos.put(fieldName, colInfo);
+            }
+        }
+
+        int numRows = s.readInt();
+        if (numRows > 0) {
+            records = new ArrayList(numRows);
+            for (int row = 0; row < numRows; row++) {
+                List record = new ArrayList(numFields);
+                for (int col = 0; col < numFields; col++) {
+                    record.add(s.readObject());
+                }
+                records.add(record);
+            }
+        }
+    }
+
+    /**
+     * Implements Externalizable interface to write serialized form
+     * 
+     * @param s
+     *            Output stream to serialize to
+     */
+    public void writeExternal(java.io.ObjectOutput s) throws IOException {
+        // Write column names and column information
+        int numFields = 0;
+        if (fields == null) {
+            s.writeInt(0);
+        } else {
+            numFields = fields.size();
+            s.writeInt(numFields);
+            for (int i = 0; i < numFields; i++) {
+                String fieldName = (String)fields.get(i);
+                s.writeUTF(fieldName);
+                s.writeObject(columnInfos.get(fieldName));
+            }
+        }
+
+        // Write record data
+        if (records == null) {
+            s.writeInt(0);
+        } else {
+            int numRows = records.size();
+            s.writeInt(numRows);
+            for (int row = 0; row < numRows; row++) {
+                List record = (List)records.get(row);
+                for (int col = 0; col < numFields; col++) {
+                    s.writeObject(record.get(col));
+                }
+            }
+        }
+    }
+
+    // =========================================================================
+    //                        I N N E R C L A S S E S
+    // =========================================================================
+
+    /**
+     * Represents all information about a column.
+     */
+    public static class ColumnInfo implements
+                                  Serializable {
+
+        /**
+         * Serialization ID - this must be changed if this class is no longer serialization-compatible with old versions.
+         */
+        static final long serialVersionUID = -7131157612965891051L;
+
+        private String name;
+        private String dataType;
+        private Class javaClass;
+
+        private Object groupID; // fully qualified group name
+        private Object elementID; // short name
+
+        public ColumnInfo(String name,
+                          String dataType,
+                          Class javaClass) {
+            if (name == null) {
+                throw new IllegalArgumentException("QueryResults column cannot have name==null");
+            }
+            this.name = name;
+            this.dataType = dataType;
+            this.javaClass = javaClass;
+        }
+
+        public ColumnInfo(String name,
+                          String dataType,
+                          Class javaClass,
+                          Object groupID,
+                          Object elementID) {
+            this(name, dataType, javaClass);
+            this.groupID = groupID;
+            this.elementID = elementID;
+        }
+
+        public String getName() {
+            return this.name;
+        }
+
+        public String getDataType() {
+            return this.dataType;
+        }
+
+        public Class getJavaClass() {
+            return this.javaClass;
+        }
+
+        /**
+         * May be null
+         */
+        public Object getGroupID() {
+            return this.groupID;
+        }
+
+        /**
+         * May be null
+         */
+        public Object getElementID() {
+            return this.elementID;
+        }
+
+        public String toString() {
+            StringBuffer str = new StringBuffer("Column["); //$NON-NLS-1$
+            str.append(this.name);
+            str.append(", "); //$NON-NLS-1$
+            str.append(this.dataType);
+            if (this.groupID != null) {
+                str.append(", "); //$NON-NLS-1$
+                str.append(this.groupID);
+                str.append("."); //$NON-NLS-1$
+                str.append(this.elementID);
+            }
+            str.append("]"); //$NON-NLS-1$
+            return str.toString();
+        }
+    }
+
+} // END CLASS


Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/QueryResults.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/ResultsHolder.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/ResultsHolder.java	                        (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/ResultsHolder.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -0,0 +1,167 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.test.client.ctc;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+
+
+
+/**
+ * ResultsHolder
+ * <p>
+ * Data structure. Holder of expected resutls and metadata.
+ * </p>
+ */
+public class ResultsHolder {
+
+    // either TagNames.Elements.QUERY_RESULTS or TagNames.Elements.EXCEPTION
+    private String resultType;
+
+    // Identifier
+    private String queryID;
+    
+    // The SQl query if available.
+    private String query;
+
+    // Query Results
+    private List rows;
+    private List types;
+    private List identifiers;
+
+    // Exception
+    private String exceptionClassName;
+    private String exceptionMsg;
+
+    public ResultsHolder(final String type) {
+        this.resultType = type;
+    }
+
+    public String getQueryID() {
+        return queryID;
+    }
+
+    public void setQueryID(final String queryID) {
+        this.queryID = queryID;
+    }
+
+    /**
+     * @return Returns the query.
+     */
+    public String getQuery() {
+        return query;
+    }
+    /**
+     * @param query The query to set.
+     */
+    public void setQuery(String query) {
+        this.query = query;
+    }
+
+    public boolean isResult() {
+        return resultType.equals(TagNames.Elements.QUERY_RESULTS);
+    }
+
+    public boolean isException() {
+        return resultType.equals(TagNames.Elements.EXCEPTION);
+    }
+
+    public String getResultType() {
+        return resultType;
+    }
+
+    public void setResultType(final String resultType) {
+        this.resultType = resultType;
+    }
+
+    public List getRows() {
+        return (rows == null ? new ArrayList() : rows);
+    }
+
+    public void setRows(final List rows) {
+        this.rows = rows;
+    }
+
+    public List getTypes() {
+        return types;
+    }
+
+    public void setTypes(final List types) {
+        this.types = types;
+    }
+
+    public List getIdentifiers() {
+        return identifiers;
+    }
+
+    public void setIdentifiers(final List identifiers) {
+        this.identifiers = identifiers;
+    }
+
+    public String getExceptionClassName() {
+        return exceptionClassName;
+    }
+
+    public void setExceptionClassName(final String className) {
+        this.exceptionClassName = className;
+    }
+
+    public String getExceptionMsg() {
+        return exceptionMsg;
+    }
+
+    public void setExceptionMsg(final String msg) {
+        this.exceptionMsg = msg;
+    }
+
+    public boolean hasRows() {
+        return (rows != null && rows.size() > 0);
+    }
+
+    public String toString() {
+        StringBuffer buf = new StringBuffer();
+        buf.append("ResultsHolder... \n"); //$NON-NLS-1$
+        if (isResult()) {
+	        for (int i = 0; i < this.identifiers.size(); i++) {
+	            buf.append("["); //$NON-NLS-1$
+	            buf.append(this.identifiers.get(i));
+	            buf.append(" - "); //$NON-NLS-1$
+	            buf.append(this.types.get(i));
+	            buf.append("] "); //$NON-NLS-1$
+	        }
+	        buf.append("\n"); //$NON-NLS-1$
+	        Iterator rowItr = this.rows.iterator();
+	        int i = 1;
+	        while (rowItr.hasNext()) {
+	            buf.append(i++);
+	            buf.append(": "); //$NON-NLS-1$
+	            buf.append(rowItr.next());
+	            buf.append("\n"); //$NON-NLS-1$
+	        }
+        }
+        else {
+            buf.append(getExceptionClassName()).append(":").append(getExceptionMsg()); //$NON-NLS-1$            
+        }
+        return buf.toString();
+    }    
+}
\ No newline at end of file


Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/ResultsHolder.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/TagNames.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/TagNames.java	                        (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/TagNames.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -0,0 +1,135 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.test.client.ctc;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Constants used in XML messaging.
+ */
+public final class TagNames {
+
+  private static final String DATA_ELE_TYPE_INT = "integer"; //$NON-NLS-1$
+  private static final String DATA_ELE_TYPE_STRING = "string"; //$NON-NLS-1$
+  private static final String DATA_ELE_TYPE_FLOAT = "float"; //$NON-NLS-1$
+  private static final String DATA_ELE_TYPE_LONG = "long"; //$NON-NLS-1$
+  private static final String DATA_ELE_TYPE_DOUBLE = "double"; //$NON-NLS-1$
+  private static final String DATA_ELE_TYPE_BYTE = "byte"; //$NON-NLS-1$
+  private static final String DATA_ELE_TYPE_DATE = "date"; //$NON-NLS-1$
+  private static final String DATA_ELE_TYPE_TIME = "time"; //$NON-NLS-1$
+  private static final String DATA_ELE_TYPE_TIMESTAMP = "timestamp"; //$NON-NLS-1$
+  private static final String DATA_ELE_TYPE_BOOLEAN = "boolean"; //$NON-NLS-1$
+  private static final String DATA_ELE_TYPE_CHAR = "char"; //$NON-NLS-1$
+  private static final String DATA_ELE_TYPE_SHORT = "short"; //$NON-NLS-1$
+  private static final String DATA_ELE_TYPE_BIG_INT = "biginteger"; //$NON-NLS-1$
+  private static final String DATA_ELE_TYPE_BIG_DEC = "bigdecimal"; //$NON-NLS-1$
+  private static final String DATA_ELE_TYPE_OBJECT = "object"; //$NON-NLS-1$
+  private static final String DATA_ELE_TYPE_XML = "xml"; //$NON-NLS-1$
+  private static final String DATA_ELE_TYPE_CLOB = "clob"; //$NON-NLS-1$
+
+    public static Map TYPE_MAP;
+
+    static {
+        TYPE_MAP = new HashMap();
+
+        TYPE_MAP.put(DATA_ELE_TYPE_OBJECT,      java.lang.Object.class);
+        TYPE_MAP.put(DATA_ELE_TYPE_INT,         java.lang.Integer.class);
+        TYPE_MAP.put(DATA_ELE_TYPE_STRING,      java.lang.String.class);
+        TYPE_MAP.put(DATA_ELE_TYPE_FLOAT,       java.lang.Float.class);
+        TYPE_MAP.put(DATA_ELE_TYPE_LONG,        java.lang.Long.class);
+        TYPE_MAP.put(DATA_ELE_TYPE_DOUBLE,      java.lang.Double.class);
+        TYPE_MAP.put(DATA_ELE_TYPE_BYTE,        java.lang.Byte.class);
+        TYPE_MAP.put(DATA_ELE_TYPE_BOOLEAN,     java.lang.Boolean.class);
+        TYPE_MAP.put(DATA_ELE_TYPE_CHAR,        java.lang.Character.class);
+        TYPE_MAP.put(DATA_ELE_TYPE_SHORT,       java.lang.Short.class);
+        TYPE_MAP.put(DATA_ELE_TYPE_BIG_INT,     java.math.BigInteger.class);
+        TYPE_MAP.put(DATA_ELE_TYPE_BIG_DEC,     java.math.BigDecimal.class);
+        TYPE_MAP.put(DATA_ELE_TYPE_DATE,        java.sql.Date.class);
+        TYPE_MAP.put(DATA_ELE_TYPE_TIME,        java.sql.Time.class);
+        TYPE_MAP.put(DATA_ELE_TYPE_TIMESTAMP,   java.sql.Timestamp.class);
+        TYPE_MAP.put(DATA_ELE_TYPE_XML,         java.lang.String.class);
+        TYPE_MAP.put(DATA_ELE_TYPE_CLOB,        java.lang.String.class);
+    }
+
+
+    /**
+     * Enumeration of XML element tag constants.
+     */
+    public static final class Elements {
+        public static final String STRING = "string"; //$NON-NLS-1$
+        public static final String BOOLEAN = "boolean"; //$NON-NLS-1$
+        public static final String BYTE = "byte"; //$NON-NLS-1$
+        public static final String SHORT = "short"; //$NON-NLS-1$
+        public static final String CHAR = "char"; //$NON-NLS-1$
+        public static final String INTEGER = "integer"; //$NON-NLS-1$
+        public static final String LONG = "long"; //$NON-NLS-1$
+        public static final String BIGINTEGER = "biginteger"; //$NON-NLS-1$
+        public static final String FLOAT = "float"; //$NON-NLS-1$
+        public static final String DOUBLE = "double"; //$NON-NLS-1$
+        public static final String BIGDECIMAL = "bigdecimal"; //$NON-NLS-1$
+        public static final String DATE = "date"; //$NON-NLS-1$
+        public static final String TIME = "time"; //$NON-NLS-1$
+        public static final String TIMESTAMP = "timestamp"; //$NON-NLS-1$
+        public static final String OBJECT = "object"; //$NON-NLS-1$
+
+        public static final String CLASS = "class"; //$NON-NLS-1$
+        public static final String TABLE = "table"; //$NON-NLS-1$
+        public static final String TABLE_ROW = "tableRow"; //$NON-NLS-1$
+        public static final String TABLE_CELL = "tableCell"; //$NON-NLS-1$
+        public static final String NULL = "null"; //$NON-NLS-1$
+        public static final String EXCEPTION = "exception"; //$NON-NLS-1$
+        public static final String ACTUAL_EXCEPTION = "actual_exception"; //$NON-NLS-1$
+        public static final String EXPECTED_EXCEPTION = "expected_exception"; //$NON-NLS-1$
+        public static final String EXCEPTION_TYPE = "exceptionType"; //$NON-NLS-1$
+        public static final String MESSAGE = "message"; //$NON-NLS-1$
+        public static final String DATA_ELEMENT = "dataElement"; //$NON-NLS-1$
+        public static final String QUERY_RESULTS = "queryResults"; //$NON-NLS-1$
+        public static final String ACTUAL_QUERY_RESULTS = "actual_queryResults"; //$NON-NLS-1$
+        public static final String EXPECTED_QUERY_RESULTS = "expected_queryResults"; //$NON-NLS-1$
+        public static final String QUERY = "query"; //$NON-NLS-1$
+        public static final String SELECT = "select"; //$NON-NLS-1$
+        public static final String ROOT_ELEMENT = "root"; //$NON-NLS-1$
+    }
+
+    /**
+     * Enumeration of XML element attribute names.
+     */
+    public static final class Attributes {
+        public static final String TYPE = "type"; //$NON-NLS-1$
+        public static final String SIZE = "size"; //$NON-NLS-1$
+        public static final String TABLE_ROW_COUNT = "rowCount"; //$NON-NLS-1$
+        public static final String TABLE_COLUMN_COUNT = "columnCount"; //$NON-NLS-1$
+        public static final String NAME = "name"; //$NON-NLS-1$
+        public static final String VALUE = "value"; //$NON-NLS-1$
+        public static final String DISTINCT = "distinct"; //$NON-NLS-1$
+        public static final String STAR = "star"; //$NON-NLS-1$
+    }
+
+    /**
+     * Enumeration of XML element attribute values.
+     */
+    public static final class Values {
+        public static final String TRUE = "true"; //$NON-NLS-1$
+        public static final String FALSE = "false"; //$NON-NLS-1$
+    }
+}


Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/TagNames.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java	                        (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -0,0 +1,775 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.test.client.ctc;
+
+import java.io.File;
+import java.io.IOException;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.SQLXML;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.jdom.JDOMException;
+import org.teiid.test.client.ExpectedResults;
+import org.teiid.test.client.QueryScenario;
+import org.teiid.test.client.ResultsGenerator;
+import org.teiid.test.client.TestResult;
+import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.ConfigPropertyNames;
+import org.teiid.test.framework.TestLogger;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+
+import com.metamatrix.core.util.StringUtil;
+
+
+
+public class XMLExpectedResults implements ExpectedResults {
+     
+    protected Properties props;
+    protected int resultMode = -1;
+    protected String generateDir = null;
+    protected String querySetIdentifier = null;
+    protected String results_dir_loc = null;
+     
+    protected Map<String, ResultsHolder> loadedResults = new HashMap<String, ResultsHolder>();
+    
+    
+    public XMLExpectedResults(Properties properties, String querySetIdentifier) {
+    	this.props = properties;
+    	this.querySetIdentifier = querySetIdentifier;
+     	
+    	this.results_dir_loc = props.getProperty(
+				PROP_EXPECTED_RESULTS_DIR_LOC, ""); 
+    	
+	String expected_root_loc = this.props
+		.getProperty(PROP_EXPECTED_RESULTS_ROOT_DIR);
+
+	if (expected_root_loc != null) {
+	    File dir = new File(expected_root_loc, results_dir_loc);
+	    this.results_dir_loc = dir.getAbsolutePath();
+	}
+
+    	
+    	TestLogger.logInfo("Expected results loc: " + this.results_dir_loc);
+    }
+
+
+	@Override
+	public boolean isExceptionExpected(String queryidentifier) throws QueryTestFailedException {
+       		ResultsHolder expectedResults = (ResultsHolder) getResults(queryidentifier);
+
+		return (expectedResults.getExceptionMsg() == null ? false : true);
+	}
+
+
+
+	@Override
+	public String getQuerySetID() {
+	    return this.querySetIdentifier;
+	}
+
+
+
+	@Override
+	public synchronized File getResultsFile(String queryidentifier) throws QueryTestFailedException {
+		return findExpectedResultsFile(queryidentifier, this.querySetIdentifier);
+		
+	}
+	
+	private ResultsHolder getResults(String queryidentifier) throws QueryTestFailedException {
+		ResultsHolder rh = null;
+		
+		if (!loadedResults.containsKey(queryidentifier)) {
+			rh = loadExpectedResults( findExpectedResultsFile(queryidentifier, this.querySetIdentifier));
+		} else {
+			rh = loadedResults.get(queryidentifier);
+		}
+				
+		return rh;
+	}
+	
+	   /**
+     * Compare the results of a query with those that were expected.
+     * 
+     * @param expectedResults
+     *            The expected results.
+     * @param results
+     *            The actual results - may be null if <code>actualException</code>.
+     * @param actualException
+     *            The actual exception recieved durring query execution - may be null if <code>results</code>.
+     * @param isOrdered
+     *            Are the actual results ordered?
+     * @param batchSize
+     *            Size of the batch(es) used in determining when the first batch of results were read.
+     * @return The response time for comparing the first batch (sizes) of resutls.
+     * @throws QueryTestFailedException
+     *             If comparison fails.
+     */
+    public void compareResults(  final String queryIdentifier,
+    								  final String sql,
+                                      final ResultSet resultSet,
+                                      final Throwable actualException,
+                                      final int testStatus,
+                                      final boolean isOrdered,
+                                      final int batchSize) throws QueryTestFailedException {
+
+        final String eMsg = "CompareResults Error: "; //$NON-NLS-1$
+   	
+	   	ResultsHolder expectedResults = (ResultsHolder) getResults(queryIdentifier);
+        ResultsHolder actualResults;
+        String actualExceptionClass = null;
+
+	       
+        switch (testStatus) {
+		case TestResult.RESULT_STATE.TEST_EXCEPTION:
+			
+			
+			break;
+			
+		case TestResult.RESULT_STATE.TEST_EXPECTED_EXCEPTION:
+		    
+		           actualExceptionClass = actualException.getClass().getName();
+
+		            if (!expectedResults.isException()) {
+		                // The actual exception was expected, but the expected results was not
+		                throw new QueryTestFailedException(eMsg + "TThe actual exception was expected, but the Expected results wasn't an exception.  Actual exception: '" //$NON-NLS-1$
+		                                                   + actualException.getMessage() + "'"); //$NON-NLS-1$
+		            }
+		            // We got an exception that we expected - convert actual exception to ResultsHolder
+		            actualResults = new ResultsHolder(TagNames.Elements.EXCEPTION);
+		            actualResults.setQueryID(expectedResults.getQueryID());
+
+		            actualResults = convertException(actualException, actualResults);
+		            
+		            compareExceptions(actualResults, expectedResults, eMsg);
+
+			
+			break;
+
+			// default success
+		default:
+			
+			
+			// is an expected exception
+			if (actualException != null) {
+				
+		           actualExceptionClass = actualException.getClass().getName();
+
+		            if (!expectedResults.isException()) {
+		                // We didn't get results but there was no expected exception either
+		                throw new QueryTestFailedException(eMsg + "Actual was an exception, but expected results was not. '" //$NON-NLS-1$
+		                	 + actualException.getMessage() + "'"); //$NON-NLS-1$
+		            }
+		            // We got an exception that we expected - convert actual exception to ResultsHolder
+		            actualResults = new ResultsHolder(TagNames.Elements.EXCEPTION);
+		            actualResults.setQueryID(expectedResults.getQueryID());
+
+		            actualResults = convertException(actualException, actualResults);
+		            
+		            compareExceptions(actualResults, expectedResults, eMsg);
+
+
+				
+			} else {
+				
+		           actualResults = new ResultsHolder(TagNames.Elements.QUERY_RESULTS);
+		            actualResults.setQueryID(expectedResults.getQueryID());
+		          long firstBatchResponseTime = 
+		            	convertResults(resultSet, batchSize, actualResults);
+			
+		           compareResultSets(actualResults.getRows(),
+		        	   actualResults.getTypes(),
+		        	   actualResults.getIdentifiers(),
+		        	   expectedResults.getRows(),
+		        	   expectedResults.getTypes(),
+		        	   expectedResults.getIdentifiers(),
+		        	   eMsg);
+
+				
+			}
+			
+			break;
+		}
+
+    	
+    }
+    
+    private ResultsHolder convertException(final Throwable actualException,
+			final ResultsHolder actualResults) {
+		actualResults.setExceptionClassName(actualException.getClass()
+				.getName());
+		actualResults.setExceptionMsg(actualException.getMessage());
+		return actualResults;
+	}
+    
+    /**
+     * Helper to convert results into records and record first batch response time.
+     * 
+     * @param results
+     * @param batchSize
+     * @param resultsHolder
+     *            Modified - results added by this method.
+     * @return List of sorted results.
+     * @throws QueryTestFailedException
+     *             replaced SQLException.
+     */
+    private final long convertResults(final ResultSet results,
+                                             final int batchSize,
+                                             ResultsHolder resultsHolder) throws QueryTestFailedException {
+
+        long firstBatchResponseTime = 0;
+        final List records = new ArrayList();
+        final List columnTypeNames = new ArrayList();
+        final List columnTypes = new ArrayList();
+
+        final ResultSetMetaData rsMetadata;
+        final int colCount;
+
+        // Get column info
+        try {
+            rsMetadata = results.getMetaData();
+            colCount = rsMetadata.getColumnCount();
+            // Read types of all columns
+            for (int col = 1; col <= colCount; col++) {
+                columnTypeNames.add(rsMetadata.getColumnName(col));
+                columnTypes.add(rsMetadata.getColumnTypeName(col));
+            }
+        } catch (SQLException qre) {
+            throw new QueryTestFailedException("Can't get results metadata: " + qre.getMessage()); //$NON-NLS-1$
+        }
+
+        // Get rows
+        try {
+            // Read all the rows
+            for (int row = 0; results.next(); row++) {
+                final List currentRecord = new ArrayList(colCount);
+                // Read values for this row
+                for (int col = 1; col <= colCount; col++) {
+                    currentRecord.add(results.getObject(col));
+                }
+                records.add(currentRecord);
+                // If this row is the (fetch size - 1)th row, record first batch response time
+                if (row == batchSize) {
+                    firstBatchResponseTime = System.currentTimeMillis();
+                }
+            }
+        } catch (SQLException qre) {
+            throw new QueryTestFailedException("Can't get results: " + qre.getMessage()); //$NON-NLS-1$
+        }
+
+        // Set info on resultsHolder
+        resultsHolder.setRows(records);
+        resultsHolder.setIdentifiers(columnTypeNames);
+        resultsHolder.setTypes(columnTypes);
+
+        return firstBatchResponseTime;
+    }
+    
+    /**
+     * Added primarily for public access to the compare code for testing.
+     * 
+     * @param actualResults
+     * @param expectedResults
+     * @param eMsg
+     * @param isOrdered
+     * @throws QueryTestFailedException
+     */
+     protected void compareResults(final ResultsHolder actualResults,
+                                      final ResultsHolder expectedResults,
+                                      final String eMsg,
+                                      boolean isOrdered) throws QueryTestFailedException {
+        if (actualResults.isException() && expectedResults.isException()) {
+            // Compare exceptions
+            compareExceptions(actualResults, expectedResults, eMsg);
+        } else if (actualResults.isResult() && expectedResults.isResult()) {
+            // Compare results
+            if (isOrdered == false && actualResults.hasRows() && expectedResults.hasRows()) {
+                // If the results are not ordered, we can sort both
+                // results and expected results to compare record for record
+                // Otherwise, actual and expected results are already assumed
+                // to be in same order
+
+                //sort the sortedResults in ascending order
+                final List actualRows = actualResults.getRows();
+                sortRecords(actualRows, true);
+                actualResults.setRows(actualRows);
+
+                //sort the expectedResults with ascending order
+                final List expectedRows = expectedResults.getRows();
+                sortRecords(expectedRows, true);
+                expectedResults.setRows(expectedRows);
+            }
+
+            compareResultSets(actualResults.getRows(),
+                              actualResults.getTypes(),
+                              actualResults.getIdentifiers(),
+                              expectedResults.getRows(),
+                              expectedResults.getTypes(),
+                              expectedResults.getIdentifiers(),
+                              eMsg);
+        } else if (actualResults.isResult() && expectedResults.isException()) {
+            // Error - expected exception but got result
+        } else if (actualResults.isException() && expectedResults.isResult()) {
+            // Error - expected result but got exception
+        }
+    }
+     
+     /**
+      * sort one result that is composed of records of all columns
+      */
+     private static void sortRecords(List records,
+                                     boolean ascending) {
+         //if record's size == 0, don't need to sort
+         if (records.size() != 0) {
+             int nFields = ((List)records.get(0)).size();
+             for (int k = 0; k < nFields; k++) {
+                 for (int m = k; m < nFields; m++) {
+                     int[] params = new int[m - k + 1];
+
+                     for (int n = k, j = 0; n <= m; n++, j++) {
+                         params[j] = n;
+                     }
+
+                     Collections.sort(records, new ListNestedSortComparator(params, ascending));
+                 }
+             }
+         }
+     }
+    
+    private void compareExceptions(final ResultsHolder actualResults,
+			final ResultsHolder expectedResults, String eMsg)
+			throws QueryTestFailedException {
+
+		final String expectedExceptionClass = expectedResults
+				.getExceptionClassName();
+		final String expectedExceptionMsg = expectedResults.getExceptionMsg().toLowerCase();
+		final String actualExceptionClass = actualResults
+				.getExceptionClassName();
+		final String actualExceptionMsg = actualResults.getExceptionMsg().toLowerCase();
+
+		if (actualExceptionClass == null) {
+			// We didn't get an actual exception, we should have
+			throw new QueryTestFailedException(eMsg + "Expected exception: " //$NON-NLS-1$
+					+ expectedExceptionClass + " but got none."); //$NON-NLS-1$
+		}
+		// Compare exception classes
+		if (!expectedExceptionClass.equals(actualExceptionClass)) {
+			throw new QueryTestFailedException(eMsg
+					+ "Got wrong exception, expected \"" //$NON-NLS-1$
+					+ expectedExceptionClass + "\" but got \"" + //$NON-NLS-1$
+					actualExceptionClass + "\""); //$NON-NLS-1$
+		}
+		// Compare exception messages
+		if (!expectedExceptionMsg.equals(actualExceptionMsg)) {
+			// Give it another chance by comparing w/o line separators
+			if (!compareStrTokens(expectedExceptionMsg, actualExceptionMsg)) {
+				throw new QueryTestFailedException(
+						eMsg
+								+ "Got expected exception but with wrong message. Got " + actualExceptionMsg); //$NON-NLS-1$
+			}
+		}
+	}
+
+    private boolean compareStrTokens(String expectedStr, String gotStr) {
+		String newline = System.getProperty("line.separator"); //$NON-NLS-1$
+		List expectedTokens = StringUtil.split(expectedStr, newline);
+		List gotTokens = StringUtil.split(gotStr, newline);
+		for (int i = 0; i < expectedTokens.size(); i++) {
+			String expected = (String) expectedTokens.get(i);
+			String got = (String) gotTokens.get(i);
+			if (!expected.equals(got)) {
+				return false;
+			}
+		}
+		return true;
+	}
+    
+    /**
+     * Compare actual results, identifiers and types with expected. <br>
+     * <strong>Note </strong>: result list are expected to match element for element.</br>
+     * 
+     * @param actualResults
+     * @param actualDatatypes
+     * @param actualIdentifiers
+     * @param expectedResults
+     * @param expectedDatatypes
+     * @param expectedIdentifiers
+     * @param eMsg
+     * @throws QueryTestFailedException
+     *             If comparison fails.
+     */
+    protected void compareResultSets(final List actualResults,
+                                          final List actualDatatypes,
+                                          final List actualIdentifiers,
+                                          final List expectedResults,
+                                          final List expectedDatatypes,
+                                          final List expectedIdentifiers,
+                                          final String eMsg) throws QueryTestFailedException {
+        // Compare column names and types
+        compareIdentifiers(actualIdentifiers, expectedIdentifiers, actualDatatypes, expectedDatatypes);
+
+        // Walk through records and compare actual against expected
+        final int actualRowCount = actualResults.size();
+        final int expectedRowCount = expectedResults.size();
+        final int actualColumnCount = actualIdentifiers.size();
+
+        // Check for less records than in expected results
+        if (actualRowCount < expectedRowCount) {
+            throw new QueryTestFailedException(eMsg + "Expected " + expectedRowCount + //$NON-NLS-1$
+                                               " records but received only " + actualRowCount); //$NON-NLS-1$
+        } else if (actualRowCount > expectedRowCount) {
+            // Check also for more records than expected
+            throw new QueryTestFailedException(eMsg + "Expected " + expectedRowCount + //$NON-NLS-1$
+                                               " records but received " + actualRowCount); //$NON-NLS-1$
+        }
+
+        //      DEBUG:
+        //        debugOut.println("================== Compariing Rows ===================");
+
+        // Loop through rows
+        for (int row = 0; row < actualRowCount; row++) {
+
+            // Get actual record
+            final List actualRecord = (List)actualResults.get(row);
+
+            // Get expected record
+            final List expectedRecord = (List)expectedResults.get(row);
+
+            //          DEBUG:
+            //            debugOut.println("Row: " + (row + 1));
+            //            debugOut.println(" expectedRecord: " + expectedRecord);
+            //            debugOut.println(" actualRecord: " + actualRecord);
+            // Loop through columns
+            // Compare actual elements with expected elements column by column in this row
+            for (int col = 0; col < actualColumnCount; col++) {
+                // Get actual value
+                final Object actualValue = actualRecord.get(col);
+                // Get expected value
+                final Object expectedValue = expectedRecord.get(col);
+
+                //              DEBUG:
+                //                debugOut.println(" Col: " +(col +1) + ": expectedValue:[" + expectedValue + "] actualValue:[" + actualValue +
+                // "]");
+
+                // Compare these values
+                if (expectedValue == null) {
+                    // Compare nulls
+                    if (actualValue != null) {
+                        throw new QueryTestFailedException(eMsg + "Value mismatch at row " + (row + 1) //$NON-NLS-1$
+                                                           + " and column " + (col + 1) //$NON-NLS-1$
+                                                           + ": expected = [" //$NON-NLS-1$
+                                                           + expectedValue + "], actual = [" //$NON-NLS-1$
+                                                           + actualValue + "]"); //$NON-NLS-1$
+
+                    }
+                } else {
+                    // Compare values with equals
+                    if (!expectedValue.equals(actualValue)) {
+                        // DEBUG:
+                        //                        debugOut.println(" ExpectedType: " + expectedValue.getClass() + " ActualType: " +
+                        // actualValue.getClass());
+                        if (expectedValue instanceof String) {
+                            final String expectedString = (String)expectedValue;
+                            if (actualValue instanceof Blob || actualValue instanceof Clob || actualValue instanceof SQLXML) {
+                                // LOB types are special case - metadata says they're Object types so
+                                // expected results are of type String. Actual object type is MMBlob, MMClob.
+                                // Must compare w/ String verion of actual!
+                                if (!expectedValue.equals(actualValue.toString())) {
+                                    throw new QueryTestFailedException(eMsg + "LOB Value mismatch at row " + (row + 1) //$NON-NLS-1$
+                                                                       + " and column " + (col + 1) //$NON-NLS-1$
+                                                                       + ": expected = [" //$NON-NLS-1$
+                                                                       + expectedValue + "], actual = [" //$NON-NLS-1$
+                                                                       + actualValue + "]"); //$NON-NLS-1$
+                                }
+                            } else if (!(actualValue instanceof String)) {
+                                throw new QueryTestFailedException(eMsg + "Value mismatch at row " + (row + 1) //$NON-NLS-1$
+                                                                   + " and column " + (col + 1) //$NON-NLS-1$
+                                                                   + ": expected = [" //$NON-NLS-1$
+                                                                   + expectedValue + "], actual = [" //$NON-NLS-1$
+                                                                   + actualValue + "]"); //$NON-NLS-1$
+                            } else if (expectedString.length() > 0) {
+                                // Check for String difference
+                                assertStringsMatch(expectedString, (String)actualValue, (row + 1), (col + 1), eMsg);
+                            }
+                        }
+                    }
+                }
+            } // end loop through columns
+        } // end loop through rows
+    }
+    
+ 
+    
+    protected void compareIdentifiers(List actualIdentifiers,
+			List expectedIdentifiers, List actualDataTypes,
+			List expectedDatatypes) throws QueryTestFailedException {
+
+		// Check sizes
+		if (expectedIdentifiers.size() != actualIdentifiers.size()) {
+			throw new QueryTestFailedException(
+					"Got incorrect number of columns, expected = " + expectedIdentifiers.size() + ", actual = " //$NON-NLS-1$ //$NON-NLS-2$
+							+ actualIdentifiers.size());
+		}
+
+		// Compare identifier lists only by short name
+		for (int i = 0; i < actualIdentifiers.size(); i++) {
+			String actualIdent = (String) actualIdentifiers.get(i);
+			String expectedIdent = (String) expectedIdentifiers.get(i);
+			String actualType = (String) actualDataTypes.get(i);
+			String expectedType = (String) expectedDatatypes.get(i);
+
+			// Get short name for each identifier
+			String actualShort = getShortName(actualIdent);
+			String expectedShort = getShortName(expectedIdent);
+
+			if (!expectedShort.equalsIgnoreCase(actualShort)) {
+				throw new QueryTestFailedException(
+						"Got incorrect column name at column " + i + ", expected = " + expectedShort + " but got = " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+								+ actualShort);
+			}
+			if (actualType.equalsIgnoreCase("xml")) {//$NON-NLS-1$
+				actualType = "string";//$NON-NLS-1$
+			}
+			if (actualType.equalsIgnoreCase("clob")) {//$NON-NLS-1$
+				actualType = "string";//$NON-NLS-1$
+			}
+			if (!expectedType.equalsIgnoreCase(actualType)) {
+				throw new QueryTestFailedException(
+						"Got incorrect column type at column " + i + ", expected = " + expectedType + " but got = " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+								+ actualType);
+			}
+		}
+	}
+
+
+   protected  String getShortName(String ident) {
+        int index = ident.lastIndexOf("."); //$NON-NLS-1$
+        if (index >= 0) {
+            return ident.substring(index + 1);
+        }
+        return ident;
+    }
+    
+    private static final int MISMATCH_OFFSET = 20;
+    private static final int MAX_MESSAGE_SIZE = 50;
+
+ 
+    
+   protected void assertStringsMatch(final String expectedStr, final String actualStr,
+			final int row, final int col, final String eMsg)
+			throws QueryTestFailedException {
+		// TODO: Replace stripCR() with XMLUnit comparison for XML results.
+		// stripCR() is a workaround for comparing XML Queries
+		// that have '\r'.
+		String expected = stripCR(expectedStr);
+		String actual = stripCR(actualStr);
+
+		String locationText = ""; //$NON-NLS-1$
+		int mismatchIndex = -1;
+		if (!expected.equals(actual)) {
+			if (expected != null && actual != null) {
+				int shortestStringLength = expected.length();
+				if (actual.length() < expected.length()) {
+					shortestStringLength = actual.length();
+				}
+				for (int i = 0; i < shortestStringLength; i++) {
+					if (expected.charAt(i) != actual.charAt(i)) {
+						locationText = "  Strings do not match at character: " + (i + 1) + //$NON-NLS-1$
+								". Expected [" + expected.charAt(i)
+								+ "] but got [" + actual.charAt(i) + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+						mismatchIndex = i;
+						break;
+					}
+				}
+			}
+
+			String expectedPartOfMessage = expected;
+			String actualPartOfMessage = actual;
+			if (expected.length() + actual.length() > MAX_MESSAGE_SIZE) {
+				expectedPartOfMessage = safeSubString(expected, mismatchIndex
+						- MISMATCH_OFFSET, mismatchIndex + MISMATCH_OFFSET);
+				actualPartOfMessage = safeSubString(actual, mismatchIndex
+						- MISMATCH_OFFSET, mismatchIndex + MISMATCH_OFFSET);
+			}
+
+			String message = eMsg + "Value mismatch at row " + row + //$NON-NLS-1$
+					" and column " + col + //$NON-NLS-1$
+					". Expected: {0} but was: {1}" + locationText; //$NON-NLS-1$
+			message = MessageFormat.format(message, new Object[] {
+					expectedPartOfMessage, actualPartOfMessage });
+			throw new QueryTestFailedException(message);
+		}
+	}
+    
+    private String safeSubString(String text, int startIndex,
+			int endIndex) {
+		String prefix = "...'"; //$NON-NLS-1$
+		String suffix = "'..."; //$NON-NLS-1$
+
+		int actualStartIndex = startIndex;
+		if (actualStartIndex < 0) {
+			actualStartIndex = 0;
+			prefix = "'"; //$NON-NLS-1$
+		}
+		int actualEndIndex = endIndex;
+		if (actualEndIndex > text.length() - 1) {
+			actualEndIndex = text.length() - 1;
+			if (actualEndIndex < 0) {
+				actualEndIndex = 0;
+			}
+		}
+		if (actualEndIndex == text.length() - 1 || text.length() == 0) {
+			suffix = "'"; //$NON-NLS-1$
+		}
+
+		return prefix + text.substring(actualStartIndex, actualEndIndex)
+				+ suffix;
+	}
+
+
+    
+    private String stripCR(final String text) {
+        if (text.indexOf('\r') >= 0) {
+            StringBuffer stripped = new StringBuffer(text.length());
+            int len = text.length();
+            for (int i = 0; i < len; i++) {
+                char current = text.charAt(i);
+                if (current != '\r') {
+                    stripped.append(current);
+                }
+            }
+            return stripped.toString();
+        }
+        return text;
+    }
+
+
+	@Override
+	public Object getMetaData(String queryidentifier) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+
+	private ResultsHolder loadExpectedResults(File resultsFile) throws QueryTestFailedException {
+        XMLQueryVisitationStrategy jstrat = new XMLQueryVisitationStrategy();
+        final ResultsHolder expectedResult;
+        try {
+            expectedResult = jstrat.parseXMLResultsFile(resultsFile);
+        } catch (IOException e) {
+            throw new QueryTestFailedException("Unable to load expected results: " + e.getMessage()); //$NON-NLS-1$
+        } catch (JDOMException e) {
+            throw new QueryTestFailedException("Unable to load expected results: " + e.getMessage()); //$NON-NLS-1$
+        }
+        return expectedResult;
+    }
+	
+    private File findExpectedResultsFile(String queryIdentifier,
+			String querySetIdentifier) throws QueryTestFailedException {
+		String resultFileName = queryIdentifier + ".xml"; //$NON-NLS-1$
+		File file = new File(results_dir_loc + "/" + querySetIdentifier, resultFileName);
+		if (!file.exists()) {
+			throw new QueryTestFailedException("Query results file " + file.getAbsolutePath() + " cannot be found");
+		}
+		
+		return file;
+
+	}
+    
+	public static void main(String[] args) {
+		System.setProperty(ConfigPropertyNames.CONFIG_FILE, "ctc-bqt-test.properties");
+
+		ConfigPropertyLoader _instance = ConfigPropertyLoader.getInstance();
+		Properties p = _instance.getProperties();
+		if (p == null || p.isEmpty()) {
+			throw new RuntimeException("Failed to load config properties file");
+
+		}
+		
+		QueryScenario set = new CTCQueryScenario("testscenario", ConfigPropertyLoader.getInstance().getProperties());
+
+		
+		_instance.setProperty(XMLQueryReader.PROP_QUERY_FILES_ROOT_DIR, new File("target/classes/").getAbsolutePath() );
+		
+
+		
+
+		try {
+
+		    Iterator<String> it = set.getQuerySetIDs().iterator();
+		    while (it.hasNext()) {
+			String querySetID = it.next();
+
+			Map queries = set.getQueries(querySetID);
+			if (queries.size() == 0l) {
+				System.out.println("Failed, didn't load any queries " );
+			}
+			
+				
+				ExpectedResults er = set.getExpectedResults(querySetID);
+				    //new XMLExpectedResults(_instance.getProperties(), querySetID);
+								
+				ResultsGenerator gr = set.getResultsGenerator();
+				    //new XMLGenerateResults(_instance.getProperties(), "testname", set.getOutputDirectory());
+
+				Iterator qIt = queries.keySet().iterator();
+				while(qIt.hasNext()) {
+					String qId = (String) qIt.next();
+					String sql = (String) queries.get(qId);
+					
+//					System.out.println("SetID #: " + cnt + "  Qid: " + qId + "   sql: " + sql);
+					
+					File resultsFile = er.getResultsFile(qId);
+					if (resultsFile == null) {
+						System.out.println("Failed to get results file for queryID " + qId);
+					}
+					
+	
+					
+					
+				}
+
+		    }
+			
+			System.out.println("Completed Test");
+
+		} catch (QueryTestFailedException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+	}
+    
+    
+
+}


Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java	                        (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -0,0 +1,429 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.test.client.ctc;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Properties;
+
+import org.jdom.Attribute;
+import org.jdom.CDATA;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.output.XMLOutputter;
+import org.junit.Assert;
+import org.teiid.test.client.ResultsGenerator;
+import org.teiid.test.client.TestProperties;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+
+import com.metamatrix.core.util.FileUtils;
+import com.metamatrix.core.util.StringUtil;
+import com.metamatrix.internal.core.xml.JdomHelper;
+
+public class XMLGenerateResults implements ResultsGenerator {
+    private static final SimpleDateFormat FILE_NAME_DATE_FORMATER = new SimpleDateFormat(
+	    "yyyyMMdd_HHmmss"); //$NON-NLS-1$
+    private String outputDir = "";
+    private String generateDir = "";
+
+    public XMLGenerateResults(Properties props, String testname, String outputDirectory) {
+
+	Assert.assertNotNull("Property " + TestProperties.PROP_OUTPUT_DIR
+		+ " was not passed in", outputDirectory);
+	
+	this.outputDir = outputDirectory;
+
+	File d = new File(this.outputDir);
+	this.outputDir = d.getAbsolutePath();
+	d = new File(this.outputDir);
+	if (d.exists()) {
+	    FileUtils.removeDirectoryAndChildren(d);
+
+	}
+	if (!d.exists()) {
+	    d.mkdirs();
+	}
+
+	generateDir = props.getProperty(PROP_GENERATE_DIR, ".");
+	Assert.assertNotNull("Property " + PROP_GENERATE_DIR
+		+ " was not specified", this.outputDir);
+
+	d = new File(generateDir, testname);
+	generateDir = d.getAbsolutePath();
+	d = new File(generateDir);
+	if (d.exists()) {
+	    FileUtils.removeDirectoryAndChildren(d);
+	}
+	if (!d.exists()) {
+	    d.mkdirs();
+	}
+
+    }
+
+    @Override
+    public String getGenerateDir() {
+	// TODO Auto-generated method stub
+	return this.generateDir;
+    }
+
+    @Override
+    public String getOutputDir() {
+	// TODO Auto-generated method stub
+	return outputDir;
+    }
+
+    /**
+     * Generate query results. These are actual results from the server and may
+     * be used for comparing to results from a later test run.
+     * 
+     * @param queryID
+     * @param resultsFile
+     * @param result
+     * @param ex
+     * @throws QueryTestFailedException
+     */
+
+    public void generateQueryResultFile(String querySetID, String queryID,
+	    String query, ResultSet result, Throwable ex, int testStatus)
+	    throws QueryTestFailedException {
+
+	File resultsFile = createNewResultsFile(queryID, querySetID,
+		getGenerateDir());
+	OutputStream outputStream;
+	try {
+	    FileOutputStream fos = new FileOutputStream(resultsFile);
+	    outputStream = new BufferedOutputStream(fos);
+	} catch (IOException e) {
+	    throw new QueryTestFailedException(
+		    "Failed to open new results file: " + resultsFile.getPath() + ": " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+	}
+
+	try {
+	    XMLQueryVisitationStrategy jstrat = new XMLQueryVisitationStrategy();
+
+	    // Create root JDOM element
+	    Element rootElement = new Element(TagNames.Elements.ROOT_ELEMENT);
+
+	    // Create Query element
+	    Element queryElement = new Element(TagNames.Elements.QUERY);
+	    queryElement.addContent(new CDATA(query));
+	    rootElement.addContent(queryElement);
+
+	    // create a result attribute for the queryID
+	    Attribute resultsIDAttribute = new Attribute(
+		    TagNames.Attributes.NAME, queryID);
+
+	    if (result != null) {
+		// produce a JDOM element from the results object
+		Element resultsElement = jstrat.produceResults(result);
+		// set the resultsIDAttribute on the results element
+		resultsElement.setAttribute(resultsIDAttribute);
+		// add the results elements to the root element
+		rootElement.addContent(resultsElement);
+		// debug:
+		// System.out.println("\n Result: " + printResultSet(result));
+	    } else {
+		// create a JDOM element from the exception object with the
+		// results tag
+		Element exceptionElement = new Element(
+			TagNames.Elements.QUERY_RESULTS);
+		// produce xml for the actualException and this to the
+		// exceptionElement
+		if (ex != null) {
+		    exceptionElement.addContent(jstrat.produceMsg(ex, null));
+		}
+		// set the resultsIDAttribute on the exception element
+		exceptionElement.setAttribute(resultsIDAttribute);
+		// add the results elements to the root element
+		rootElement.addContent(exceptionElement);
+
+	    }
+
+	    // Output xml
+	    XMLOutputter outputter = new XMLOutputter(JdomHelper.getFormat(
+		    "  ", true)); //$NON-NLS-1$
+	    outputter.output(new Document(rootElement), outputStream);
+
+	} catch (SQLException e) {
+	    throw new QueryTestFailedException(
+		    "Failed to convert results to JDOM: " + e.getMessage()); //$NON-NLS-1$
+	} catch (JDOMException e) {
+	    throw new QueryTestFailedException(
+		    "Failed to convert results to JDOM: " + e.getMessage()); //$NON-NLS-1$
+	} catch (IOException e) {
+	    throw new QueryTestFailedException(
+		    "Failed to output new results to " + resultsFile.getPath() + ": " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+	} catch (Throwable e) {
+	    throw new QueryTestFailedException(
+		    "Failed to convert results to JDOM: " + StringUtil.getStackTrace(e)); //$NON-NLS-1$
+	} finally {
+	    try {
+		outputStream.close();
+	    } catch (IOException e) {
+	    }
+	}
+    }
+
+    public String generateErrorFile(final String querySetID,
+	    final String queryID, final String sql, final ResultSet resultSet,
+	    final Throwable queryError, final File expectedResultsFile)
+	    throws QueryTestFailedException {
+
+	String errorFileName = null;
+	try {
+	    // write actual results to error file
+	    errorFileName = generateErrorFileName(queryID, querySetID);
+	    // configID, queryID, Integer.toString(clientID));
+	    //           CombinedTestClient.log("\t" + this.clientID + ": Writing error file with actual results: " + errorFileName); //$NON-NLS-1$ //$NON-NLS-2$
+	    File errorFile = new File(getOutputDir(), errorFileName);
+
+	    // rewind resultset
+	    if (resultSet != null) {
+		resultSet.beforeFirst();
+	    }
+	    generateErrorResults(querySetID, queryID, sql, errorFile,
+		    resultSet, expectedResultsFile, queryError);
+
+	} catch (Throwable e) {
+	    throw new QueryTestFailedException(e.getMessage());
+	    //           CombinedTestClient.logError("Error writing error file \"" + outputDir + "\"/" + errorFileName + ": " + e); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+	}
+	return errorFileName;
+    }
+
+    private File createNewResultsFile(String queryID, String querySetID,
+	    String genDir) {
+	String resultFileName = queryID + ".xml"; //$NON-NLS-1$
+
+	String targetDirname = genDir + File.separator + querySetID; //$NON-NLS-1$
+	File targetDir = new File(targetDirname);
+	targetDir.mkdirs();
+
+	return new File(targetDir, resultFileName);
+    }
+
+    //    
+    // private String generateErrorFileName(String queryID,
+    // String querySetID,
+    // String outputdir) {
+    //    	
+    // File resultsFile = createNewResultsFile(queryID, querySetID,
+    // this.outputDir);
+    //    	
+    // // String queryFileName = queryFile.getName();
+    // String name =
+    // FileUtils.getFilenameWithoutExtension(resultsFile.getName());
+    // String errorFileName = "ERROR_"
+    //                                   + name + "_" //$NON-NLS-1$
+    //                                   + FILE_NAME_DATE_FORMATER.format(new Date(System.currentTimeMillis())) + ".xml"; //$NON-NLS-1$
+    // return errorFileName;
+    //  	
+    // }
+
+    public String generateErrorFileName(String queryID, String querySetID) {
+	String errorFileName = "ERROR_"
+		// configID + "_" //$NON-NLS-1$ //$NON-NLS-2$
+		//                               + querySetID + "_" //$NON-NLS-1$
+		+ queryID
+		+ "_" //$NON-NLS-1$
+		+ FILE_NAME_DATE_FORMATER.format(new Date(System
+			.currentTimeMillis())) + ".xml"; //$NON-NLS-1$
+	return errorFileName;
+    }
+
+    /**
+     * Generate an error file for a query that failed comparison. File should
+     * have the SQL, the actual results returned from the server and the results
+     * that were expected.
+     * 
+     * @param queryID
+     * @param sql
+     * @param resultsFile
+     * @param actualResult
+     * @param expectedResultFile
+     * @param ex
+     * @throws QueryTestFailedException
+     */
+    private void generateErrorResults(String querySetID, String queryID,
+	    String sql, File resultsFile, ResultSet actualResult,
+	    File expectedResultFile, Throwable ex)
+	    throws QueryTestFailedException {
+	OutputStream outputStream;
+	try {
+	    FileOutputStream fos = new FileOutputStream(resultsFile);
+	    outputStream = new BufferedOutputStream(fos);
+	} catch (IOException e) {
+	    throw new QueryTestFailedException(
+		    "Failed to open error results file: " + resultsFile.getPath() + ": " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+	}
+
+	try {
+	    XMLQueryVisitationStrategy jstrat = new XMLQueryVisitationStrategy();
+
+	    // Create root JDOM element
+	    Element rootElement = new Element(TagNames.Elements.ROOT_ELEMENT);
+
+	    // create a JDOM element for the results
+	    Element resultElement = new Element(TagNames.Elements.QUERY_RESULTS);
+	    // set the queryIDAttr on the exception element
+	    resultElement.setAttribute(new Attribute(TagNames.Attributes.NAME,
+		    queryID));
+	    // set the querySQLAttr on the exception element
+	    resultElement.setAttribute(new Attribute(TagNames.Attributes.VALUE,
+		    sql));
+
+	    // ---------------------
+	    // Actual Exception
+	    // ---------------------
+	    // create a JDOM element from the actual exception object
+	    // produce xml for the actualException and this to the
+	    // exceptionElement
+	    if (ex != null) {
+		Element actualExceptionElement = new Element(
+			TagNames.Elements.ACTUAL_EXCEPTION);
+
+		actualExceptionElement = XMLQueryVisitationStrategy
+			.jdomException(ex, actualExceptionElement);
+		resultElement.addContent(actualExceptionElement);
+	    }
+
+	    if (actualResult != null) {
+		// ------------------------------
+		// Got a ResultSet from server
+		// error was in comparing results
+		// ------------------------------
+
+		// --------------------------
+		// Actual Result - ResultSet
+		// --------------------------
+		// produce a JDOM element from the actual results object
+		Element actualResultsElement = new Element(
+			TagNames.Elements.ACTUAL_QUERY_RESULTS);
+		actualResultsElement = jstrat.produceMsg(actualResult,
+			actualResultsElement);
+
+		// add the results elements to the root element
+		resultElement.addContent(actualResultsElement);
+
+		// ---------------------
+		// Expected Results - ...
+		// ---------------------
+		// produce xml for the expected results
+		// Get expected results
+		Element expectedResult = new Element("bogus"); //$NON-NLS-1$
+		expectedResult = jstrat.parseXMLResultsFile(expectedResultFile,
+			expectedResult);
+		if (expectedResult.getChild(TagNames.Elements.SELECT) != null) {
+		    //----------------------------------------------------------
+		    // -
+		    // Expected result was a ResultSet set element name to
+		    // reflect
+		    //----------------------------------------------------------
+		    // -
+		    expectedResult
+			    .setName(TagNames.Elements.EXPECTED_QUERY_RESULTS);
+		} else {
+		    //----------------------------------------------------------
+		    // --
+		    // Expected result was an exception set element name to
+		    // reflect
+		    //----------------------------------------------------------
+		    // --
+		    expectedResult
+			    .setName(TagNames.Elements.EXPECTED_EXCEPTION);
+		}
+		resultElement.addContent(expectedResult);
+	    } else {
+
+		// ---------------------
+		// Expected Results - ...
+		// ---------------------
+		// produce xml for the expected results
+		// Get expected results
+		Element expectedResult = new Element("bogus"); //$NON-NLS-1$
+		expectedResult = jstrat.parseXMLResultsFile(expectedResultFile,
+			expectedResult);
+		if (expectedResult.getChild(TagNames.Elements.SELECT) != null) {
+		    //----------------------------------------------------------
+		    // -
+		    // Expected result was a ResultSet set element name to
+		    // reflect
+		    //----------------------------------------------------------
+		    // -
+		    expectedResult
+			    .setName(TagNames.Elements.EXPECTED_QUERY_RESULTS);
+		} else {
+		    //----------------------------------------------------------
+		    // --
+		    // Expected result was an exception set element name to
+		    // reflect
+		    //----------------------------------------------------------
+		    // --
+		    expectedResult
+			    .setName(TagNames.Elements.EXPECTED_EXCEPTION);
+		}
+		resultElement.addContent(expectedResult);
+	    }
+
+	    // ------------------------------
+	    // Got an exeption from the server
+	    // error was in comparing exceptions
+	    // ------------------------------
+
+	    // add the results elements to the root element
+	    rootElement.addContent(resultElement);
+
+	    // Output xml
+	    XMLOutputter outputter = new XMLOutputter(JdomHelper.getFormat(
+		    "  ", true)); //$NON-NLS-1$
+	    outputter.output(new Document(rootElement), outputStream);
+
+	} catch (SQLException e) {
+	    throw new QueryTestFailedException(
+		    "Failed to convert error results to JDOM: " + e.getMessage()); //$NON-NLS-1$
+	} catch (JDOMException e) {
+	    throw new QueryTestFailedException(
+		    "Failed to convert error results to JDOM: " + e.getMessage()); //$NON-NLS-1$
+	} catch (IOException e) {
+	    throw new QueryTestFailedException(
+		    "Failed to output error results to " + resultsFile.getPath() + ": " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+	} catch (Throwable e) {
+	    throw new QueryTestFailedException(
+		    "Failed to convert error results to JDOM: " + StringUtil.getStackTrace(e)); //$NON-NLS-1$
+	} finally {
+	    try {
+		outputStream.close();
+	    } catch (IOException e) {
+	    }
+	}
+    }
+
+}


Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryReader.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryReader.java	                        (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryReader.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -0,0 +1,193 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.test.client.ctc;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.teiid.test.client.QueryReader;
+import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.ConfigPropertyNames;
+import org.teiid.test.framework.TestLogger;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+
+import com.metamatrix.core.util.FileUtils;
+import com.metamatrix.core.util.StringUtil;
+
+public class XMLQueryReader implements QueryReader {
+ 
+    private Properties props = null;
+
+//    private Map<String, Map<String, String>> querySet = new HashMap<String, Map<String, String>>();
+//    private Map<String, String> queryToFileMap = new HashMap<String, String>();
+
+    private Map<String, String> querySetIDToFileMap = new HashMap<String, String>();
+
+    public XMLQueryReader(Properties properties)
+	    throws QueryTestFailedException {
+	this.props = properties;
+	loadQuerySets();
+    }
+
+    @Override
+    public Map<String, Object> getQueries(String querySetID)
+	    throws QueryTestFailedException {
+	String queryFile = querySetIDToFileMap.get(querySetID);
+
+	try {
+	    return loadQueries(querySetID, queryFile);
+	} catch (IOException e) {
+	    throw new QueryTestFailedException((new StringBuilder()).append(
+		    "Failed to load queries from file: ").append(queryFile).append(" error:").append(e.getMessage())
+		    .toString());
+	}
+
+    }
+
+    @Override
+    public Collection<String> getQuerySetIDs() {
+	return new HashSet<String>(querySetIDToFileMap.keySet());
+    }
+
+
+    private void loadQuerySets() throws QueryTestFailedException {
+	String query_dir_loc = this.props.getProperty(PROP_QUERY_FILES_DIR_LOC);
+	if (query_dir_loc == null)
+	    throw new QueryTestFailedException(
+		    "queryfiles.loc property was not specified ");
+
+	String query_root_loc = this.props
+		.getProperty(PROP_QUERY_FILES_ROOT_DIR);
+
+	String loc = query_dir_loc;
+
+	if (query_root_loc != null) {
+	    File dir = new File(query_root_loc, query_dir_loc);
+	    loc = dir.getAbsolutePath();
+	}
+
+	TestLogger.log("Loading queries from " + loc);
+
+	File files[] = FileUtils.findAllFilesInDirectoryHavingExtension(loc,
+		".xml");
+	if (files == null || files.length == 0)
+	    throw new QueryTestFailedException((new StringBuilder()).append(
+		    "No query files found in directory ").append(loc)
+		    .toString());
+	// List<String> queryFiles = new ArrayList<String>(files.length);
+	for (int i = 0; i < files.length; i++) {
+	    String queryfile = files[i].getAbsolutePath();
+	    // Get query set name
+	    String querySet = getQuerySetName(queryfile); //$NON-NLS-1$
+	    querySetIDToFileMap.put(querySet, queryfile);
+	    // queryFiles.add(files[i].getAbsolutePath());
+	}
+
+    }
+
+    private Map<String, Object> 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);
+	    throw new TransactionRuntimeException(msg); //$NON-NLS-1$ //$NON-NLS-2$
+	} else {
+	    // Get query set name
+	    //			String querySet = getQuerySetName(queryFileName) ; //$NON-NLS-1$
+
+	    XMLQueryVisitationStrategy jstrat = new XMLQueryVisitationStrategy();
+	    try {
+		Map queryMap = jstrat.parseXMLQueryFile(queryFile);
+		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) {
+		String msg = "Error reading query file: " + queryFileName + ", " + e.getMessage(); //$NON-NLS-1$ //$NON-NLS-2$
+		TestLogger.log(msg);
+		throw new IOException(msg); //$NON-NLS-1$ //$NON-NLS-2$
+	    }
+	}
+	return queries;
+    }
+
+    private static String getQuerySetName(String queryFileName) {
+	// Get query set name
+	String querySet = queryFileName;
+	List<String> nameParts = StringUtil.split(querySet, "./\\"); //$NON-NLS-1$
+	if (nameParts.size() > 1) {
+	    querySet = (String) nameParts.get(nameParts.size() - 2);
+	}
+	return querySet;
+    }
+
+    public static void main(String[] args) {
+	System.setProperty(ConfigPropertyNames.CONFIG_FILE,
+		"ctc-bqt-test.properties");
+
+	ConfigPropertyLoader _instance = ConfigPropertyLoader.getInstance();
+	Properties p = _instance.getProperties();
+	if (p == null || p.isEmpty()) {
+	    throw new RuntimeException("Failed to load config properties file");
+
+	}
+
+	_instance.setProperty(PROP_QUERY_FILES_ROOT_DIR, new File(
+		"target/classes/").getAbsolutePath());
+
+	try {
+	    XMLQueryReader reader = new XMLQueryReader(_instance.getProperties());
+	    Iterator<String> it = reader.getQuerySetIDs().iterator();
+	    while (it.hasNext()) {
+		String querySetID = it.next();
+
+		Map queries = reader.getQueries(querySetID);
+		
+		if (queries.size() == 0l) {
+		    System.out.println("Failed, didn't load any queries ");
+		}
+	    }
+	} catch (QueryTestFailedException e) {
+	    // TODO Auto-generated catch block
+	    e.printStackTrace();
+	}
+
+    }
+
+}


Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryReader.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryVisitationStrategy.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryVisitationStrategy.java	                        (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryVisitationStrategy.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -0,0 +1,1493 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.test.client.ctc;
+
+import java.io.File;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.jdom.Attribute;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.input.SAXBuilder;
+import org.teiid.test.client.ctc.QueryResults.ColumnInfo;
+import org.teiid.test.util.StringUtil;
+
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.internal.core.xml.SAXBuilderHelper;
+import com.metamatrix.query.sql.lang.Select;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
+
+/**
+ * <P> This program helps in parsing XML Query and Results files into
+ * map objects containing individual queries/ResultSets</P>
+ *
+ * <P> This program is useful to convert the JDBC ResultSet objects into
+ * XML format. We physically walk through the ResultSet object and use JDOM to
+ * convert the ResultSets into XML. This also helps convert Exceptions into XML
+ * format.</P>
+ */
+
+public class XMLQueryVisitationStrategy {
+
+    //the row from which we start converting ResultSets to XML
+    private static final int START_ROW = 1;
+
+    // list containing datatypes of field identifiers
+
+    public XMLQueryVisitationStrategy() {
+    }
+
+    /**
+     * Consume an XML Query File and produce a Map containing queries, with
+     * queryNames/IDs as Keys.
+     * <br>
+     * @param queryFile the XML file object that is to be parsed
+     * @return the Map containig query strings.
+     * @exception JDOMException if there is an error consuming the message.
+     */
+    public Map parseXMLQueryFile(File queryFile) throws IOException, JDOMException {
+
+        HashMap queryMap = new HashMap();
+        SAXBuilder builder = SAXBuilderHelper.createSAXBuilder(false);
+        Document queryDocument = builder.build(queryFile);
+        List queryElements = queryDocument.getRootElement().getChildren(TagNames.Elements.QUERY);
+        Iterator iter = queryElements.iterator();
+        while ( iter.hasNext() ) {
+            Element queryElement = (Element) iter.next();
+            String queryName = queryElement.getAttributeValue(TagNames.Attributes.NAME);
+            if ( queryElement.getChild(TagNames.Elements.EXCEPTION) == null ) {
+                String query = queryElement.getTextTrim();
+                queryMap.put(queryName, query);
+            } else {
+                Element exceptionElement = queryElement.getChild(TagNames.Elements.EXCEPTION);
+                String exceptionType = exceptionElement.getChild(TagNames.Elements.CLASS).getTextTrim();
+                queryMap.put(queryName, exceptionType);
+            }
+        }
+        return queryMap;
+    }
+
+    /**
+     * Consume an XML results File and produce a Map containing query results
+     * as List objects, with resultNames/IDs as Keys.
+     * <br>
+     * @param resultsFile the XML file object that is to be parsed
+     * @return the Map containig results.
+     * @exception JDOMException if there is an error consuming the message.
+     */
+    public ResultsHolder parseXMLResultsFile(final File resultsFile) throws IOException, JDOMException {
+
+        QueryResults queryResults;
+        ResultsHolder expectedResults = null;
+
+        final SAXBuilder builder = SAXBuilderHelper.createSAXBuilder(false);
+        final Document resultsDocument = builder.build(resultsFile);
+        final String query = resultsDocument.getRootElement().getChildText(TagNames.Elements.QUERY);
+        final List resultElements = resultsDocument.getRootElement().getChildren(TagNames.Elements.QUERY_RESULTS);
+        final Iterator iter = resultElements.iterator();
+        while ( iter.hasNext() ) {
+            final Element resultElement = (Element) iter.next();
+            final String resultName = resultElement.getAttributeValue(TagNames.Attributes.NAME);
+            queryResults = consumeMsg(new QueryResults(), resultElement);
+            if ( queryResults.getFieldCount() != 0 ) {
+                //
+                // We've got a ResultSet
+                //
+                expectedResults = new ResultsHolder( TagNames.Elements.QUERY_RESULTS );
+                expectedResults.setQueryID( resultName );
+                expectedResults.setQuery(query);
+                expectedResults.setIdentifiers( queryResults.getFieldIdents() );
+                expectedResults.setTypes( queryResults.getTypes() );
+                if ( queryResults.getRecordCount() > 0 ) {
+                    expectedResults.setRows(queryResults.getRecords());
+                }
+            } else {
+                //
+                // We've got an exception
+                //
+                expectedResults = new ResultsHolder( TagNames.Elements.EXCEPTION );
+                expectedResults.setQueryID( resultName );
+                expectedResults.setQuery(query);
+
+                final Element exceptionElement = resultElement.getChild(TagNames.Elements.EXCEPTION);
+                if ( exceptionElement != null ) {
+                    expectedResults.setExceptionClassName(exceptionElement.getChild(TagNames.Elements.CLASS).getTextTrim());
+                    String msg = exceptionElement.getChild(TagNames.Elements.MESSAGE).getTextTrim();   
+                    expectedResults.setExceptionMsg(StringUtil.removeChars(msg, new char[] {'\r'}));
+                }
+            }
+        }
+        return expectedResults;
+    }
+
+    /**
+     * Consume an XML results File, produce results as JDOM and add results to the given parent.
+     * <br>
+     * @param resultsFile the XML file object that is to be parsed
+     * @param parent the parent Element to assign results to
+     * @return the modified parent
+     * @exception JDOMException if there is an error consuming the message.
+     */
+    public Element parseXMLResultsFile(File resultsFile, Element parent) throws IOException, JDOMException {
+
+        SAXBuilder builder = SAXBuilderHelper.createSAXBuilder(false);
+        Document resultsDocument = builder.build(resultsFile);
+        List resultElements = resultsDocument.getRootElement().getChildren(TagNames.Elements.QUERY_RESULTS);
+        Iterator iter = resultElements.iterator();
+        while ( iter.hasNext() ) {
+            Element resultElement = (Element) iter.next();
+            if ( resultElement.getChild(TagNames.Elements.SELECT) == null ) {
+                // We've got an exception
+                Element exceptionElement = resultElement.getChild(TagNames.Elements.EXCEPTION);
+                if ( exceptionElement != null ) {
+                    // ---------------------------------
+                    // Add the ExceptionType element ...
+                    // ---------------------------------
+                    Element typeElement = new Element(TagNames.Elements.EXCEPTION_TYPE);
+                    typeElement.setText(exceptionElement.getChild(TagNames.Elements.EXCEPTION_TYPE).getTextTrim());
+                    parent.addContent(typeElement);
+
+                    // ---------------------------
+                    // Add the Message element ...
+                    // ---------------------------
+                    Element messageElement = new Element(TagNames.Elements.MESSAGE);    
+                    String msg = exceptionElement.getChild(TagNames.Elements.MESSAGE).getTextTrim();   
+                    
+                    messageElement.setText(StringUtil.removeChars(msg, new char[] {'\r'}));
+                    parent.addContent(messageElement);
+
+                    // -------------------------
+                    // Add the Class element ...
+                    // -------------------------
+                    Element classElement = new Element(TagNames.Elements.CLASS);
+                    classElement.setText(exceptionElement.getChild(TagNames.Elements.CLASS).getTextTrim());
+                    parent.addContent(classElement);
+                }
+            } else {
+                // We've got results
+
+                // -------------------------------
+                // Read the SELECT elements
+                // -------------------------------
+                Element selectElement = resultElement.getChild(TagNames.Elements.SELECT);
+                resultElement.removeChild(TagNames.Elements.SELECT);
+                parent.addContent(selectElement);
+
+                // -------------------------------
+                // Read the TABLE of data
+                // -------------------------------
+                Element tableElement = resultElement.getChild(TagNames.Elements.TABLE);
+                resultElement.removeChild(TagNames.Elements.TABLE);
+                parent.addContent(tableElement);
+            }
+        }
+        return parent;
+    }
+
+    /*********************************************************************************************
+     *********************************************************************************************
+     CONSUME METHODS
+     *********************************************************************************************
+     ********************************************************************************************/
+
+    /**
+     * Generate XML for an exception in Object form.
+     *
+     * @param ex
+     * @param exceptionElement
+     * @return The JDOM exception element.
+     */
+    public static Element jdomException(Throwable ex, Element exceptionElement) {
+        // ---------------------------------
+        // Add the ExceptionType element ...
+        // ---------------------------------
+        String className = ex.getClass().getName();
+        int index = className.lastIndexOf('.');
+        if ( index != -1 && (++index) < className.length() ) {
+            className = className.substring(index);
+        }
+        Element typeElement = new Element(TagNames.Elements.EXCEPTION_TYPE);
+        typeElement.setText(className);
+        exceptionElement.addContent(typeElement);
+
+        // ---------------------------
+        // Add the Message element ...
+        // ---------------------------
+ 
+        Element messageElement = new Element(TagNames.Elements.MESSAGE);
+        messageElement.setText(StringUtil.removeChars(ex.getMessage(), new char[] {'\r'}));     
+        		
+        exceptionElement.addContent(messageElement);
+
+        // -------------------------
+        // Add the Class element ...
+        // -------------------------
+        Element classElement = new Element(TagNames.Elements.CLASS);
+        classElement.setText(ex.getClass().getName());
+        exceptionElement.addContent(classElement);
+
+        return exceptionElement;
+    }
+
+    /**
+     * Consume an XML message and update the specified QueryResults instance.
+     * <br>
+     * @param object the instance that is to be updated with the XML message data.
+     * @param resultsElement the XML element that contains the data
+     * @return the updated instance.
+     */
+    private QueryResults consumeMsg(QueryResults object, Element resultsElement) throws JDOMException {
+        // -----------------------
+        // Process the element ...
+        // -----------------------
+        QueryResults results = object;
+        if ( results == null ) {
+            results = new QueryResults();
+        }
+
+        if ( resultsElement.getChild(TagNames.Elements.SELECT) == null ) {
+            return results;
+        }
+        // -------------------------------
+        // Read the SELECT elements
+        // -------------------------------
+        Element selectElement = resultsElement.getChild(TagNames.Elements.SELECT);
+        Select select = new Select();
+        select = consumeMsg(select, selectElement);
+
+        List listOfElementSymbols = select.getSymbols();
+        Iterator elementSymbolItr = listOfElementSymbols.iterator();
+        Collection collectionOfColumnInfos = new ArrayList();
+        while ( elementSymbolItr.hasNext() ) {
+            ElementSymbol elementSymbol = (ElementSymbol) elementSymbolItr.next();
+            Class elementType = elementSymbol.getType();
+            String dataType = DataTypeManager.getDataTypeName(elementType);
+            ColumnInfo columnInfo = new ColumnInfo(elementSymbol.getName(), dataType, elementType);
+            collectionOfColumnInfos.add(columnInfo);
+        }
+        // Save column info
+        results.addFields(collectionOfColumnInfos);
+        // -------------------------------
+        // Read the TABLE of data
+        // -------------------------------
+
+        Element tableElement = resultsElement.getChild(TagNames.Elements.TABLE);
+        List tableRows = tableElement.getChildren(TagNames.Elements.TABLE_ROW);
+        if ( tableRows.size() > 0 ) {
+            Iterator rowIter = tableRows.iterator();
+
+            while ( rowIter.hasNext() ) {
+                Element rowElement = (Element) rowIter.next();
+                List cellElements = rowElement.getChildren(TagNames.Elements.TABLE_CELL);
+                Iterator cellIter = cellElements.iterator();
+                // Read cells of the table
+                ArrayList row = new ArrayList();
+                Object evalue = null;
+                while ( cellIter.hasNext() ) {
+                    Element cellElement = (Element) cellIter.next();
+                    if ( cellElement.getTextTrim().equalsIgnoreCase(TagNames.Elements.NULL) ) {
+                        row.add(null);
+                    } else {
+                        Element cellChildElement = (Element) cellElement.getChildren().get(0);
+                        evalue = consumeMsg(cellChildElement);
+                        row.add(evalue);
+                    }
+                }
+                // Save row
+                results.addRecord(row);
+            }
+        }
+        return results;
+    }
+
+    /**
+     * Consume an XML message and update the specified Select instance.
+     * <br>
+     * @param object the instance that is to be updated with the XML message data.
+     * @param selectElement the XML element that contains the data
+     * @return the updated instance.
+     * @exception JDOMException if there is an error consuming the message.
+     */
+    private Select consumeMsg(Select object, Element selectElement) throws JDOMException {
+
+        Select select = (object != null) ? (Select) object : new Select();
+        // --------------------------------
+        // Read the DISTINCT attribute
+        // --------------------------------
+
+        String distinct = selectElement.getAttributeValue(TagNames.Attributes.DISTINCT);
+        if ( distinct != null ) {
+            if ( distinct.equalsIgnoreCase("true") ) { //$NON-NLS-1$
+                select.setDistinct(true);
+            }
+        }
+
+        // --------------------------------
+        // Read the STAR attribute
+        // --------------------------------
+
+        String star = selectElement.getAttributeValue(TagNames.Attributes.STAR);
+        if ( star != null ) {
+            if ( star.equalsIgnoreCase("true") ) { //$NON-NLS-1$
+                if ( selectElement.getChildren() != null ) {
+                    throw new JDOMException("No children expected when star is chosen."); //$NON-NLS-1$
+                }
+                return select;
+            }
+        }
+
+        // --------------------------------
+        // Read the IDENTIFIER elements ...
+        // --------------------------------
+        List idents = selectElement.getChildren();
+        Iterator identIter = idents.iterator();
+        while ( identIter.hasNext() ) {
+            Element dataElement = (Element) identIter.next();
+            Attribute dataType = dataElement.getAttribute(TagNames.Attributes.TYPE);
+            // add the dataType of the element to the list containing dataTypes
+            ElementSymbol nodeID = new ElementSymbol(dataElement.getText());
+            Class nodeType = (Class) TagNames.TYPE_MAP.get(dataType.getValue());
+            if (nodeType == null)  {
+                throw new JDOMException("Unknown class for type \"" + dataType.getValue() + "\"."); //$NON-NLS-1$ //$NON-NLS-2$
+            }
+            nodeID.setType(nodeType);
+            select.addSymbol(nodeID);
+        }
+
+        return select;
+    }
+
+
+    /**
+     * Produce a JDOM Element for the instance of any Object.
+     * <br>
+     * @param cellElement the XML element that is to produce the XML message.
+     * @return the root element of the XML segment that was produced.
+     * @exception JDOMException if there is an error producing XML.
+     */
+    private Object consumeMsg(Element cellElement) throws JDOMException {
+
+        Object cellObject = null;
+        String cellName = cellElement.getName();
+
+        if ( cellName.equalsIgnoreCase(TagNames.Elements.BOOLEAN) ) {
+            cellObject = consumeMsg((Boolean) cellObject, cellElement);
+        } else if ( cellName.equalsIgnoreCase(TagNames.Elements.STRING) ) {
+            cellObject = consumeMsg((String) cellObject, cellElement);
+        } else if ( cellName.equalsIgnoreCase(TagNames.Elements.CHAR) ) {
+            cellObject = consumeMsg((Character) cellObject, cellElement);
+        } else if ( cellName.equalsIgnoreCase(TagNames.Elements.BYTE) ) {
+            cellObject = consumeMsg((Byte) cellObject, cellElement);
+        } else if ( cellName.equalsIgnoreCase(TagNames.Elements.DOUBLE) ) {
+            cellObject = consumeMsg((Double) cellObject, cellElement);
+        } else if ( cellName.equalsIgnoreCase(TagNames.Elements.DATE) ) {
+            cellObject = consumeMsg((java.sql.Date) cellObject, cellElement);
+        } else if ( cellName.equalsIgnoreCase(TagNames.Elements.TIME) ) {
+            cellObject = consumeMsg((Time) cellObject, cellElement);
+        } else if ( cellName.equalsIgnoreCase(TagNames.Elements.TIMESTAMP) ) {
+            cellObject = consumeMsg((Timestamp) cellObject, cellElement);
+        } else if ( cellName.equalsIgnoreCase(TagNames.Elements.FLOAT) ) {
+            cellObject = consumeMsg((Float) cellObject, cellElement);
+        } else if ( cellName.equalsIgnoreCase(TagNames.Elements.BIGDECIMAL) ) {
+            cellObject = consumeMsg((BigDecimal) cellObject, cellElement);
+        } else if ( cellName.equalsIgnoreCase(TagNames.Elements.BIGINTEGER) ) {
+            cellObject = consumeMsg((BigInteger) cellObject, cellElement);
+        } else if ( cellName.equalsIgnoreCase(TagNames.Elements.INTEGER) ) {
+            cellObject = consumeMsg((Integer) cellObject, cellElement);
+        } else if ( cellName.equalsIgnoreCase(TagNames.Elements.LONG) ) {
+            cellObject = consumeMsg((Long) cellObject, cellElement);
+        } else if ( cellName.equalsIgnoreCase(TagNames.Elements.SHORT) ) {
+            cellObject = consumeMsg((Short) cellObject, cellElement);
+        } else if ( cellName.equalsIgnoreCase(TagNames.Elements.OBJECT) ) {
+            cellObject = consumeMsg((String) cellObject, cellElement);
+        }
+
+        return cellObject;
+    }
+
+    /**
+     * Consume an XML message and update the specified Boolean instance.
+     * <br>
+     * @param object the instance that is to be updated with the XML message data.
+     * @param cellElement the XML element that contains the data
+     * @return the updated instance.
+     * @exception JDOMException if there is an error consuming the message.
+     */
+    private Object consumeMsg(Boolean object, Element cellElement) throws JDOMException {
+
+        // -----------------------
+        // Process the element ...
+        // -----------------------
+        boolean result = false;
+        String value = cellElement.getTextTrim();
+        if ( value.equalsIgnoreCase(TagNames.Values.TRUE) ) {
+            result = true;
+        } else if ( value.equalsIgnoreCase(TagNames.Values.FALSE) ) {
+            result = false;
+        } else {
+            throw new JDOMException("Invalid value for " + cellElement.getName() + //$NON-NLS-1$
+                                    " element: \"" + value + "\" must be either \"" + //$NON-NLS-1$ //$NON-NLS-2$
+                                    TagNames.Values.TRUE + "\" or \"" + //$NON-NLS-1$
+                                    TagNames.Values.FALSE + "\""); //$NON-NLS-1$
+        }
+
+        return new Boolean(result);
+    }
+
+    /**
+     * Consume an XML message and update the specified java.sql.Date instance.
+     * <br>
+     * @param object the instance that is to be updated with the XML message data.
+     * @param cellElement the XML element that contains the data
+     * @return the updated instance.
+     * @exception JDOMException if there is an error consuming the message.
+     */
+    private Object consumeMsg(java.sql.Date object, Element cellElement) throws JDOMException {
+
+        // -----------------------
+        // Process the element ...
+        // -----------------------
+        java.sql.Date result;
+        try {
+            result = java.sql.Date.valueOf(cellElement.getTextTrim());
+        } catch ( Exception e ) {
+            throw new JDOMException("Invalid input format ", e); //$NON-NLS-1$
+        }
+        return result;
+    }
+
+    /**
+     * Consume an XML message and update the specified Time instance.
+     * <br>
+     * @param object the instance that is to be updated with the XML message data.
+     * @param cellElement the XML element that contains the data
+     * @return the updated instance.
+     * @exception JDOMException if there is an error consuming the message.
+     */
+    private Object consumeMsg(Time object, Element cellElement) throws JDOMException {
+
+        // -----------------------
+        // Process the element ...
+        // -----------------------
+        Time result;
+        try {
+            result = Time.valueOf(cellElement.getTextTrim());
+        } catch ( Exception e ) {
+            throw new JDOMException("Invalid input format ", e); //$NON-NLS-1$
+        }
+        return result;
+    }
+
+    /**
+     * Consume an XML message and update the specified Timestamp instance.
+     * <br>
+     * @param object the instance that is to be updated with the XML message data.
+     * @param cellElement the XML element that contains the data
+     * @return the updated instance.
+     * @exception JDOMException if there is an error consuming the message.
+     */
+    private Object consumeMsg(Timestamp object, Element cellElement) throws JDOMException {
+
+        // -----------------------
+        // Process the element ...
+        // -----------------------
+        Timestamp result;
+        try {
+            result = Timestamp.valueOf(cellElement.getTextTrim());
+        } catch ( Exception e ) {
+            throw new JDOMException("Invalid input format ", e); //$NON-NLS-1$
+        }
+
+        return result;
+    }
+
+    /**
+     * Consume an XML message and update the specified Double instance.
+     * <br>
+     * @param object the instance that is to be updated with the XML message data.
+     * @param cellElement the XML element that contains the data
+     * @return the updated instance.
+     * @exception JDOMException if there is an error consuming the message.
+     */
+    private Object consumeMsg(Double object, Element cellElement) throws JDOMException {
+
+        // -----------------------
+        // Process the element ...
+        // -----------------------
+        String strElement = cellElement.getTextTrim();
+        Double result;
+
+        if ( strElement.equals("NaN") ) { //$NON-NLS-1$
+            result = new Double(Double.NaN);
+        } else if ( strElement.equals("-Infinity") ) { //$NON-NLS-1$
+            result = new Double(Double.NEGATIVE_INFINITY);
+        } else if ( strElement.equals("Infinity") ) { //$NON-NLS-1$
+            result = new Double(Double.POSITIVE_INFINITY);
+        } else {
+            try {
+                result = Double.valueOf(strElement);
+            } catch ( NumberFormatException e ) {
+                throw new JDOMException("Unable to parse the value for " + cellElement.getName() + //$NON-NLS-1$
+                                        " element: " + strElement, e); //$NON-NLS-1$
+            }
+        }
+        return result;
+    }
+
+    /**
+     * Consume an XML message and update the specified Float instance.
+     * <br>
+     * @param object the instance that is to be updated with the XML message data.
+     * @param cellElement the XML element that contains the data
+     * @return the updated instance.
+     * @exception JDOMException if there is an error consuming the message.
+     */
+    private Object consumeMsg(Float object, Element cellElement) throws JDOMException {
+
+        // -----------------------
+        // Process the element ...
+        // -----------------------
+        String strElement = cellElement.getTextTrim();
+        Float result;
+
+        if ( strElement.equals("NaN") ) { //$NON-NLS-1$
+            result = new Float(Float.NaN);
+        } else if ( strElement.equals("-Infinity") ) { //$NON-NLS-1$
+            result = new Float(Float.NEGATIVE_INFINITY);
+        } else if ( strElement.equals("Infinity") ) { //$NON-NLS-1$
+            result = new Float(Float.POSITIVE_INFINITY);
+        } else {
+            try {
+                result = Float.valueOf(strElement);
+            } catch ( NumberFormatException e ) {
+                throw new JDOMException("Unable to parse the value for " + cellElement.getName() + //$NON-NLS-1$
+                                        " element: " + strElement, e); //$NON-NLS-1$
+            }
+        }
+        return result;
+    }
+
+    /**
+     * Consume an XML message and update the specified BigDecimal instance.
+     * <br>
+     * @param object the instance that is to be updated with the XML message data.
+     * @param cellElement the XML element that contains the data
+     * @return the updated instance.
+     * @exception JDOMException if there is an error consuming the message.
+     */
+    private Object consumeMsg(BigDecimal object, Element cellElement) throws JDOMException {
+
+        // -----------------------
+        // Process the element ...
+        // -----------------------
+        BigDecimal result;
+        try {
+            result = new BigDecimal(cellElement.getTextTrim());
+        } catch ( NumberFormatException e ) {
+            throw new JDOMException("Unable to parse the value for " + cellElement.getName() + //$NON-NLS-1$
+                                    " element: " + cellElement.getTextTrim(), e); //$NON-NLS-1$
+        }
+        return result;
+    }
+
+    /**
+     * Consume an XML message and update the specified BigInteger instance.
+     * <br>
+     * @param object the instance that is to be updated with the XML message data.
+     * @param cellElement the XML element that contains the data
+     * @return the updated instance.
+     * @exception JDOMException if there is an error consuming the message.
+     */
+    private Object consumeMsg(BigInteger object, Element cellElement) throws JDOMException {
+
+        // -----------------------
+        // Process the element ...
+        // -----------------------
+        BigInteger result;
+        try {
+            result = new BigInteger(cellElement.getTextTrim());
+        } catch ( NumberFormatException e ) {
+            throw new JDOMException("Unable to parse the value for " + cellElement.getName() + //$NON-NLS-1$
+                                    " element: " + cellElement.getTextTrim(), e); //$NON-NLS-1$
+        }
+        return result;
+    }
+
+    /**
+     * Consume an XML message and update the specified String instance.
+     * <br>
+     * @param object the instance that is to be updated with the XML message data.
+     * @param cellElement the XML element that contains the data
+     * @return the updated instance.
+     * @exception JDOMException if there is an error consuming the message.
+     */
+    private Object consumeMsg(String object, Element cellElement) throws JDOMException {
+
+        // -----------------------
+        // Process the element ...
+        // -----------------------
+
+        return cellElement.getText();
+    }
+
+    /**
+     * Consume an XML message and update the specified Character instance.
+     * <br>
+     * @param object the instance that is to be updated with the XML message data.
+     * @param cellElement the XML element that contains the data
+     * @return the updated instance.
+     * @exception JDOMException if there is an error consuming the message.
+     */
+    private Object consumeMsg(Character object, Element cellElement) throws JDOMException {
+
+        // -----------------------
+        // Process the element ...
+        // -----------------------
+        Character result;
+        try {
+            if ( cellElement.getTextTrim().length() == 0 ) {
+                return null;
+            }
+            result = new Character(cellElement.getTextTrim().charAt(0));
+        } catch ( NumberFormatException e ) {
+            throw new JDOMException("Unable to parse the value for " + cellElement.getName() + //$NON-NLS-1$
+                                    " element: " + cellElement.getTextTrim(), e); //$NON-NLS-1$
+        }
+        return result;
+    }
+
+    /**
+     * Consume an XML message and update the specified Byte instance.
+     * <br>
+     * @param object the instance that is to be updated with the XML message data.
+     * @param cellElement the XML element that contains the data
+     * @return the updated instance.
+     * @exception JDOMException if there is an error consuming the message.
+     */
+    private Object consumeMsg(Byte object, Element cellElement) throws JDOMException {
+
+        // -----------------------
+        // Process the element ...
+        // -----------------------
+        Byte result;
+        try {
+            result = new Byte(cellElement.getTextTrim());
+        } catch ( NumberFormatException e ) {
+            throw new JDOMException("Unable to parse the value for " + cellElement.getName() + //$NON-NLS-1$
+                                    " element: " + cellElement.getTextTrim(), e); //$NON-NLS-1$
+        }
+        return result;
+    }
+
+    /**
+     * Consume an XML message and update the specified Integer instance.
+     * <br>
+     * @param object the instance that is to be updated with the XML message data.
+     * @param cellElement the XML element that contains the data
+     * @return the updated instance.
+     * @exception JDOMException if there is an error consuming the message.
+     */
+    private Object consumeMsg(Integer object, Element cellElement) throws JDOMException {
+
+        // -----------------------
+        // Process the element ...
+        // -----------------------
+        Integer result;
+        try {
+            result = Integer.valueOf(cellElement.getTextTrim());
+        } catch ( NumberFormatException e ) {
+            throw new JDOMException("Unable to parse the value for " + cellElement.getName() + //$NON-NLS-1$
+                                    " element: " + cellElement.getTextTrim(), e); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-1$
+        }
+        return result;
+    }
+
+    /**
+     * Consume an XML message and update the specified Long instance.
+     * <br>
+     * @param object the instance that is to be updated with the XML message data.
+     * @param cellElement the XML element that contains the data
+     * @return the updated instance.
+     * @exception JDOMException if there is an error consuming the message.
+     */
+    private Object consumeMsg(Long object, Element cellElement) throws JDOMException {
+
+        // -----------------------
+        // Process the element ...
+        // -----------------------
+        Long result;
+        try {
+            result = Long.valueOf(cellElement.getTextTrim());
+        } catch ( NumberFormatException e ) {
+            throw new JDOMException("Unable to parse the value for " + cellElement.getName() + //$NON-NLS-1$
+                                    " element: " + cellElement.getTextTrim(), e); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-1$
+        }
+        return result;
+    }
+
+    /**
+     * Consume an XML message and update the specified Long instance.
+     * <br>
+     * @param object the instance that is to be updated with the XML message data.
+     * @param cellElement the XML element that contains the data
+     * @return the updated instance.
+     * @exception JDOMException if there is an error consuming the message.
+     */
+    private Object consumeMsg(Short object, Element cellElement) throws JDOMException {
+
+        // -----------------------
+        // Process the element ...
+        // -----------------------
+        Short result;
+        try {
+            result = Short.valueOf(cellElement.getTextTrim());
+        } catch ( NumberFormatException e ) {
+            throw new JDOMException("Unable to parse the value for " + cellElement.getName() + //$NON-NLS-1$
+                                    " element: " + cellElement.getTextTrim(), e); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-1$
+        }
+        return result;
+    }
+
+    /*********************************************************************************************
+     *********************************************************************************************
+     PRODUCE METHODS
+     *********************************************************************************************
+     ********************************************************************************************/
+
+    /**
+     * Produce a JDOM Element for an instance of a JDBC ResultSet object.
+     * <br>
+     * @param object for which the JDOM Element is to be produced.
+     * @return the JDOM element of the ResultSet object that was converted to XML.
+     * @exception JDOMException if there is an error producing XML.
+     * @exception JDOMException if there is an error producing XML.
+     * @exception SQLException if there is an error walking through the ResultSet object.
+     */
+    public Element produceResults(ResultSet object) throws JDOMException, SQLException {
+
+        // When no begin and end
+        return produceResults(object, START_ROW, Integer.MAX_VALUE);
+    }
+
+    /**
+     * Produce a JDOM Element for an instance of Results object.
+     * <br>
+     * @param object for which the JDOM Element is to be produced.
+     * @param beginRow The starting row from which the results are to be converted to XML.
+     * @param endRow The row until which the results are to be converted to XML.
+     * @return the JDOM element of the results object that was converted to XML.
+     * @exception JDOMException if there is an error producing XML.
+     * @exception SQLException if there is an error walking through the ResultSet object.
+     */
+    private Element produceResults(ResultSet object, int beginRow, int endRow)
+            throws JDOMException, SQLException {
+
+        if ( beginRow < START_ROW ) {
+            throw new IllegalArgumentException(
+                    "The starting row cannot be less than 1."); //$NON-NLS-1$
+        } else if ( beginRow > endRow ) {
+            throw new IllegalArgumentException(
+                    "The starting row cannot be less than the ending row."); //$NON-NLS-1$
+        }
+
+        int currentRow = object.getRow() + 1;
+
+        if ( beginRow > currentRow ) {
+            while ( !object.isLast() && currentRow != beginRow ) {
+                object.next();
+                currentRow++;
+            }
+
+        } else if ( beginRow < currentRow ) {
+            while ( !object.isFirst() && currentRow != beginRow ) {
+                object.previous();
+                currentRow--;
+            }
+        }
+
+        return produceMsg(object, endRow);
+    }
+
+    /**
+     * Produce a JDOM Element for an instance of a JDBC ResultSet object.
+     * <br>
+     * @param object for which the JDOM Element is to be produced.
+     * @param endRow The row until which the results are to be converted to XML.
+     * @return the JDOM element of the results object that was converted to XML.
+     * @exception JDOMException if there is an error producing XML.
+     * @exception SQLException if there is an error walking through the ResultSet object.
+     */
+    private Element produceMsg(ResultSet object, int endRow) throws JDOMException, SQLException {
+
+        // -----------------------------------
+        // Create the QueryResults element ...
+        // -----------------------------------
+        Element resultsElement = new Element(TagNames.Elements.QUERY_RESULTS);
+
+        // -----------------------------------
+        // Add the Select (header) element ...
+        // -----------------------------------
+        try {
+            ResultSetMetaData rmdata = object.getMetaData();
+            List identList = new ArrayList(rmdata.getColumnCount());
+            for ( int i = 1; i <= rmdata.getColumnCount(); i++ ) {
+                identList.add(new ElementSymbol(rmdata.getColumnName(i)));
+            }
+            Select select = new Select(identList);
+            resultsElement = produceMsg(select, rmdata, resultsElement);
+
+            // -------------------------
+            // Add the Table element ...
+            // -------------------------
+            resultsElement.addContent(new Element(TagNames.Elements.TABLE));
+            Element tableElement = resultsElement.getChild(TagNames.Elements.TABLE);
+            int rowCount = 0;
+            int colCount = rmdata.getColumnCount();
+
+            while ( object.next() && (object.getRow() <= endRow) ) {
+
+                // -------------------------
+                // Add the ROW element ...
+                // -------------------------
+                Element rowElement = new Element(TagNames.Elements.TABLE_ROW);
+
+                for ( int i = 1; i <= colCount; i++ ) {
+                    // -------------------------
+                    // Add the Cell element ...
+                    // -------------------------
+                    Element cellElement = new Element(TagNames.Elements.TABLE_CELL);
+                    Object cellValue = object.getObject(i);
+                    if ( cellValue != null ) {
+                        cellElement = produceMsg(cellValue, cellElement);
+                    } else {
+                        cellElement = cellElement.addContent(TagNames.Elements.NULL);
+                    }
+                    rowElement.addContent(cellElement);
+                }
+                tableElement.addContent(rowElement);
+                rowCount++;
+            }
+            Attribute rowCountAttribute = new Attribute(TagNames.Attributes.TABLE_ROW_COUNT,
+                                                        Integer.toString(rowCount));
+            Attribute columnCountAttribute = new Attribute(TagNames.Attributes.TABLE_COLUMN_COUNT,
+                                                           Integer.toString(colCount));
+            tableElement.setAttribute(rowCountAttribute);
+            tableElement.setAttribute(columnCountAttribute);
+        } catch ( SQLException e ) {
+            // error while reading results
+            throw(e);
+        }
+
+        return resultsElement;
+    }
+
+    /**
+     * Produce a JDOM Element for an instance of a JDBC ResultSet object.
+     * <br>
+     * @param object for which the JDOM Element is to be produced.
+     * @return the JDOM element of the results object that was converted to XML.
+     * @exception JDOMException if there is an error producing XML.
+     * @exception SQLException if there is an error walking through the ResultSet object.
+     */
+    public Element produceMsg(ResultSet object, Element resultsElement) throws JDOMException, SQLException {
+
+        // -----------------------------------
+        // Add the Select (header) element ...
+        // -----------------------------------
+        try {
+            ResultSetMetaData rmdata = object.getMetaData();
+            List identList = new ArrayList(rmdata.getColumnCount());
+            for ( int i = 1; i <= rmdata.getColumnCount(); i++ ) {
+                identList.add(new ElementSymbol(rmdata.getColumnName(i)));
+            }
+            Select select = new Select(identList);
+            resultsElement = produceMsg(select, rmdata, resultsElement);
+
+            // -------------------------
+            // Add the Table element ...
+            // -------------------------
+            resultsElement.addContent(new Element(TagNames.Elements.TABLE));
+            Element tableElement = resultsElement.getChild(TagNames.Elements.TABLE);
+            int rowCount = 0;
+            int colCount = rmdata.getColumnCount();
+
+            while ( object.next() ) {
+
+                // -------------------------
+                // Add the ROW element ...
+                // -------------------------
+                Element rowElement = new Element(TagNames.Elements.TABLE_ROW);
+
+                for ( int i = 1; i <= colCount; i++ ) {
+                    // -------------------------
+                    // Add the Cell element ...
+                    // -------------------------
+                    Element cellElement = new Element(TagNames.Elements.TABLE_CELL);
+                    Object cellValue = object.getObject(i);
+                    if ( cellValue != null ) {
+                        cellElement = produceMsg(cellValue, cellElement);
+                    } else {
+                        cellElement = cellElement.addContent(TagNames.Elements.NULL);
+                    }
+                    rowElement.addContent(cellElement);
+                }
+                tableElement.addContent(rowElement);
+                rowCount++;
+            }
+            Attribute rowCountAttribute = new Attribute(TagNames.Attributes.TABLE_ROW_COUNT,
+                                                        Integer.toString(rowCount));
+            Attribute columnCountAttribute = new Attribute(TagNames.Attributes.TABLE_COLUMN_COUNT,
+                                                           Integer.toString(colCount));
+            tableElement.setAttribute(rowCountAttribute);
+            tableElement.setAttribute(columnCountAttribute);
+        } catch ( SQLException e ) {
+            // error while reading results
+            throw(e);
+        }
+
+        return resultsElement;
+    }
+
+    /**
+     * Produce a JDOM Element for the instance of any Object.
+     * <br>
+     * @param object the instance for which the message is to be produced.
+     * @param parent the XML element that is to be the parent of the produced XML message.
+     * @return the root element of the XML segment that was produced.
+     * @exception JDOMException if there is an error producing XML.
+     */
+    public Element produceMsg(Object object, Element parent) throws JDOMException {
+        if ( object == null ) {
+            throw new IllegalArgumentException("Null object reference."); //$NON-NLS-1$
+        }
+        Element element = null;
+
+        if ( object instanceof Boolean ) {
+            element = produceMsg((Boolean) object, parent);
+        } else if ( object instanceof String ) {
+            element = produceMsg((String) object, parent);
+        } else if ( object instanceof Character ) {
+            element = produceMsg((Character) object, parent);
+        } else if ( object instanceof Byte ) {
+            element = produceMsg((Byte) object, parent);
+        } else if ( object instanceof Double ) {
+            element = produceMsg((Double) object, parent);
+        } else if ( object instanceof java.sql.Date ) {
+            element = produceMsg((java.sql.Date) object, parent);
+        } else if ( object instanceof Time ) {
+            element = produceMsg((Time) object, parent);
+        } else if ( object instanceof Timestamp ) {
+            element = produceMsg((Timestamp) object, parent);
+        } else if ( object instanceof Float ) {
+            element = produceMsg((Float) object, parent);
+        } else if ( object instanceof BigDecimal ) {
+            element = produceMsg((BigDecimal) object, parent);
+        } else if ( object instanceof BigInteger ) {
+            element = produceMsg((BigInteger) object, parent);
+        } else if ( object instanceof Integer ) {
+            element = produceMsg((Integer) object, parent);
+        } else if ( object instanceof Long ) {
+            element = produceMsg((Long) object, parent);
+        } else if ( object instanceof Short ) {
+            element = produceMsg((Short) object, parent);
+        } else if ( object instanceof Throwable ) {
+            element = produceMsg((Throwable) object, parent);
+        } else {
+            element = produceObject(object, parent);
+        }
+
+        return element;
+    }
+
+    /**
+     * new ----
+     * @param select
+     * @param rmdata
+     * @param parent
+     * @return
+     * @throws JDOMException
+     */
+    private Element produceMsg(Select select, ResultSetMetaData rmdata, Element parent)
+            throws JDOMException {
+
+        // -----------------------------------
+        // Create the Select element ...
+        // -----------------------------------
+
+        Element selectElement = new Element(TagNames.Elements.SELECT);
+
+        // ---------------------------------
+        // Create the DISTINCT attribute ...
+        // ---------------------------------
+        boolean distinct = select.isDistinct();
+        if ( distinct ) {
+            Attribute distinctAttribute = new Attribute(TagNames.Attributes.DISTINCT, "true"); //$NON-NLS-1$
+            selectElement.setAttribute(distinctAttribute);
+        } // else default is false so no need
+
+        // ----------------------------------
+        // Create the STAR attribute ...
+        // ----------------------------------
+        if ( select.isStar() ) {
+            Attribute starAttribute = new Attribute(TagNames.Attributes.STAR, "true"); //$NON-NLS-1$
+            selectElement.setAttribute(starAttribute);
+        }
+
+        // --------------------------------
+        // Create the DATANODE elements ...
+        // --------------------------------
+        int col = 0;
+        Iterator iter = select.getSymbols().iterator();
+        while ( iter.hasNext() ) {
+            Element dataElement = new Element(TagNames.Elements.DATA_ELEMENT);
+            ElementSymbol symbol = (ElementSymbol) iter.next();
+            String elementName = symbol.getName();
+            Attribute dataType = null;
+            try {
+                dataType = new Attribute(TagNames.Attributes.TYPE, rmdata.getColumnTypeName(++col));
+            } catch ( SQLException e ) {
+                //
+            }
+            dataElement.setAttribute(dataType);
+            dataElement.setText(elementName);
+            selectElement.addContent(dataElement);
+        }
+        if ( parent != null ) {
+            selectElement = parent.addContent(selectElement);
+        }
+
+        return selectElement;
+    }
+
+    /**
+     * Produce an XML message for an instance of the Object.
+     * <br>
+     * @param object the instance for which the message is to be produced.
+     * @param parent the XML element that is to be the parent of the produced XML message.
+     * @return the root element of the XML segment that was produced.
+     * @exception JDOMException if there is an error producing the message.
+     */
+    private Element produceObject(Object object, Element parent) throws JDOMException {
+
+        // ----------------------
+        // Create the Object element ...
+        // ----------------------
+        Element objectElement = new Element(TagNames.Elements.OBJECT);
+        
+ //       System.out.println("ProductObject (before encoding): " + object.toString() );
+ //       try {
+            objectElement.setText(object.toString());
+            	//	URLEncoder.encode(object.toString(), "UTF-8"));
+ //       } catch (UnsupportedEncodingException e) {
+            // UTF-8 is supported natively by all jvms
+ //       }
+//        System.out.println("ProductObject (after encoding): " + objectElement.getText() );
+
+        
+        if ( parent != null ) {
+            objectElement = parent.addContent(objectElement);
+        }
+
+        return objectElement;
+    }
+
+    /**
+     * Produce an XML message for an instance of the String.
+     * <br>
+     * @param object the instance for which the message is to be produced.
+     * @param parent the XML element that is to be the parent of the produced XML message.
+     * @return the root element of the XML segment that was produced.
+     * @exception JDOMException if there is an error producing the message.
+     */
+    private Element produceMsg(String object, Element parent) throws JDOMException {
+
+        // ----------------------
+        // Create the String element ...
+        // ----------------------
+        Element stringElement = new Element(TagNames.Elements.STRING);
+        stringElement.setText(object);
+        if ( parent != null ) {
+            stringElement = parent.addContent(stringElement);
+        }
+
+        return stringElement;
+    }
+
+    /**
+     * Produce an XML message for an instance of the Character.
+     * <br>
+     * @param object the instance for which the message is to be produced.
+     * @param parent the XML element that is to be the parent of the produced XML message.
+     * @return the root element of the XML segment that was produced.
+     * @exception JDOMException if there is an error producing the message.
+     */
+    private Element produceMsg(Character object, Element parent) throws JDOMException {
+
+        // ----------------------
+        // Create the Character element ...
+        // ----------------------
+        Element charElement = new Element(TagNames.Elements.CHAR);
+        charElement.setText(object.toString());
+        if ( parent != null ) {
+            charElement = parent.addContent(charElement);
+        }
+
+        return charElement;
+    }
+
+    /**
+     * Produce an XML message for an instance of the Byte.
+     * <br>
+     * @param object the instance for which the message is to be produced.
+     * @param parent the XML element that is to be the parent of the produced XML message.
+     * @return the root element of the XML segment that was produced.
+     * @exception JDOMException if there is an error producing the message.
+     */
+    private Element produceMsg(Byte object, Element parent) throws JDOMException {
+
+        // ----------------------
+        // Create the Byte element ...
+        // ----------------------
+        Element byteElement = new Element(TagNames.Elements.BYTE);
+        byteElement.setText(object.toString());
+        if ( parent != null ) {
+            byteElement = parent.addContent(byteElement);
+        }
+
+        return byteElement;
+    }
+
+    /**
+     * Produce an XML message for an instance of the Boolean.
+     * <br>
+     * @param object the instance for which the message is to be produced.
+     * @param parent the XML element that is to be the parent of the produced XML message.
+     * @return the root element of the XML segment that was produced.
+     * @exception JDOMException if there is an error producing the message.
+     */
+    private Element produceMsg(Boolean object, Element parent) throws JDOMException {
+
+        // ----------------------
+        // Create the Boolean element ...
+        // ----------------------
+        Element booleanElement = new Element(TagNames.Elements.BOOLEAN);
+
+        if ( object.booleanValue() == true ) {
+            booleanElement.setText(TagNames.Values.TRUE);
+        } else {
+            booleanElement.setText(TagNames.Values.FALSE);
+        }
+
+        if ( parent != null ) {
+            booleanElement = parent.addContent(booleanElement);
+        }
+
+        return booleanElement;
+    }
+
+    /**
+     * Produce an XML message for an instance of the Float.
+     * <br>
+     * @param object the instance for which the message is to be produced.
+     * @param parent the XML element that is to be the parent of the produced XML message.
+     * @return the root element of the XML segment that was produced.
+     * @exception JDOMException if there is an error producing the message.
+     */
+    private Element produceMsg(Float object, Element parent) throws JDOMException {
+
+        // ----------------------
+        // Create the Float element ...
+        // ----------------------
+        Element floatElement = new Element(TagNames.Elements.FLOAT);
+        floatElement.setText(object.toString());
+        if ( parent != null ) {
+            floatElement = parent.addContent(floatElement);
+        }
+
+        return floatElement;
+    }
+
+    /**
+     * Produce an XML message for an instance of the Double.
+     * <br>
+     * @param object the instance for which the message is to be produced.
+     * @param parent the XML element that is to be the parent of the produced XML message.
+     * @return the root element of the XML segment that was produced.
+     * @exception JDOMException if there is an error producing the message.
+     */
+    private Element produceMsg(Double object, Element parent) throws JDOMException {
+
+        // ----------------------
+        // Create the Double element ...
+        // ----------------------
+        Element doubleElement = new Element(TagNames.Elements.DOUBLE);
+        doubleElement.setText(object.toString());
+        if ( parent != null ) {
+            doubleElement = parent.addContent(doubleElement);
+        }
+
+        return doubleElement;
+    }
+
+    /**
+     * Produce an XML message for an instance of the BigDecimal.
+     * <br>
+     * @param object the instance for which the message is to be produced.
+     * @param parent the XML element that is to be the parent of the produced XML message.
+     * @return the root element of the XML segment that was produced.
+     * @exception JDOMException if there is an error producing the message.
+     */
+    private Element produceMsg(BigDecimal object, Element parent) throws JDOMException {
+
+        // ----------------------
+        // Create the BigDecimal element ...
+        // ----------------------
+        Element bigDecimalElement = new Element(TagNames.Elements.BIGDECIMAL);
+        bigDecimalElement.setText(object.toString());
+        if ( parent != null ) {
+            bigDecimalElement = parent.addContent(bigDecimalElement);
+        }
+
+        return bigDecimalElement;
+    }
+
+    /**
+     * Produce an XML message for an instance of the BigInteger.
+     * <br>
+     * @param object the instance for which the message is to be produced.
+     * @param parent the XML element that is to be the parent of the produced XML message.
+     * @return the root element of the XML segment that was produced.
+     * @exception JDOMException if there is an error producing the message.
+     */
+    private Element produceMsg(BigInteger object, Element parent) throws JDOMException {
+
+        // ----------------------
+        // Create the BigInteger element ...
+        // ----------------------
+        Element bigIntegerElement = new Element(TagNames.Elements.BIGINTEGER);
+        bigIntegerElement.setText(object.toString());
+        if ( parent != null ) {
+            bigIntegerElement = parent.addContent(bigIntegerElement);
+        }
+
+        return bigIntegerElement;
+    }
+
+    /**
+     * Produce an XML message for an instance of the java.sql.Date.
+     * <br>
+     * @param object the instance for which the message is to be produced.
+     * @param parent the XML element that is to be the parent of the produced XML message.
+     * @return the root element of the XML segment that was produced.
+     * @exception JDOMException if there is an error producing the message.
+     */
+    private Element produceMsg(java.sql.Date object, Element parent) throws JDOMException {
+
+        // ----------------------
+        // Create the java.sql.Date element ...
+        // ----------------------
+        Element sqldateElement = new Element(TagNames.Elements.DATE);
+        sqldateElement.setText(object.toString());
+        if ( parent != null ) {
+            sqldateElement = parent.addContent(sqldateElement);
+        }
+
+        return sqldateElement;
+    }
+
+    /**
+     * Produce an XML message for an instance of the Time.
+     * <br>
+     * @param object the instance for which the message is to be produced.
+     * @param parent the XML element that is to be the parent of the produced XML message.
+     * @return the root element of the XML segment that was produced.
+     * @exception JDOMException if there is an error producing the message.
+     */
+    private Element produceMsg(Time object, Element parent) throws JDOMException {
+
+        // ----------------------
+        // Create the Time element ...
+        // ----------------------
+        Element timeElement = new Element(TagNames.Elements.TIME);
+        timeElement.setText(object.toString());
+        if ( parent != null ) {
+            timeElement = parent.addContent(timeElement);
+        }
+
+        return timeElement;
+    }
+
+    /**
+     * Produce an XML message for an instance of the Timestamp.
+     * <br>
+     * @param object the instance for which the message is to be produced.
+     * @param parent the XML element that is to be the parent of the produced XML message.
+     * @return the root element of the XML segment that was produced.
+     * @exception JDOMException if there is an error producing the message.
+     */
+    private Element produceMsg(Timestamp object, Element parent) throws JDOMException {
+
+        // ----------------------
+        // Create the Timestamp element ...
+        // ----------------------
+        Element timestampElement = new Element(TagNames.Elements.TIMESTAMP);
+        timestampElement.setText(object.toString());
+        if ( parent != null ) {
+            timestampElement = parent.addContent(timestampElement);
+        }
+
+        return timestampElement;
+    }
+
+    /**
+     * Produce an XML message for an instance of the Integer.
+     * <br>
+     * @param object the instance for which the message is to be produced.
+     * @param parent the XML element that is to be the parent of the produced XML message.
+     * @return the root element of the XML segment that was produced.
+     * @exception JDOMException if there is an error producing the message.
+     */
+    private Element produceMsg(Integer object, Element parent) throws JDOMException {
+
+        // ----------------------
+        // Create the Integer element ...
+        // ----------------------
+        Element integerElement = new Element(TagNames.Elements.INTEGER);
+        integerElement.setText(object.toString());
+        if ( parent != null ) {
+            integerElement = parent.addContent(integerElement);
+        }
+
+        return integerElement;
+    }
+
+    /**
+     * Produce an XML message for an instance of the Long.
+     * <br>
+     * @param object the instance for which the message is to be produced.
+     * @param parent the XML element that is to be the parent of the produced XML message.
+     * @return the root element of the XML segment that was produced.
+     * @exception JDOMException if there is an error producing the message.
+     */
+    private Element produceMsg(Long object, Element parent) throws JDOMException {
+
+        // ----------------------
+        // Create the Long element ...
+        // ----------------------
+        Element longElement = new Element(TagNames.Elements.LONG);
+        longElement.setText(object.toString());
+        if ( parent != null ) {
+            longElement = parent.addContent(longElement);
+        }
+
+        return longElement;
+    }
+
+    /**
+     * Produce an XML message for an instance of the Short.
+     * <br>
+     * @param object the instance for which the message is to be produced.
+     * @param parent the XML element that is to be the parent of the produced XML message.
+     * @return the root element of the XML segment that was produced.
+     * @exception JDOMException if there is an error producing the message.
+     */
+    private Element produceMsg(Short object, Element parent) throws JDOMException {
+
+        // ----------------------
+        // Create the Long element ...
+        // ----------------------
+        Element shortElement = new Element(TagNames.Elements.SHORT);
+        shortElement.setText(object.toString());
+        if ( parent != null ) {
+            shortElement = parent.addContent(shortElement);
+        }
+
+        return shortElement;
+    }
+
+    /**
+     * Produce an XML message for an instance of the SQLException.
+     * <br>
+     * @param object the instance for which the message is to be produced.
+     * @param parent the XML element that is to be the parent of the produced XML message.
+     * @return the root element of the XML segment that was produced.
+     * @exception JDOMException if there is an error producing the message.
+     */
+    private Element produceMsg(Throwable object, Element parent) throws JDOMException {
+
+        Throwable exception = object;
+        Element exceptionElement = null;
+
+        // --------------------------------
+        // Create the Exception element ...
+        // --------------------------------
+        exceptionElement = new Element(TagNames.Elements.EXCEPTION);
+
+        // ---------------------------------
+        // Add the ExceptionType element ...
+        // ---------------------------------
+        String className = exception.getClass().getName();
+        int index = className.lastIndexOf('.');
+        if ( index != -1 && (++index) < className.length() ) {
+            className = className.substring(index);
+        }
+        Element typeElement = new Element(TagNames.Elements.EXCEPTION_TYPE);
+        typeElement.setText(className);
+        exceptionElement.addContent(typeElement);
+
+        // ---------------------------
+        // Add the Message element ...
+        // ---------------------------
+        Element messageElement = new Element(TagNames.Elements.MESSAGE);
+        messageElement.setText(StringUtil.removeChars(exception.getMessage(), new char[] {'\r'}));
+         
+        exceptionElement.addContent(messageElement);
+
+        // -------------------------
+        // Add the Class element ...
+        // -------------------------
+        Element classElement = new Element(TagNames.Elements.CLASS);
+        classElement.setText(exception.getClass().getName());
+        exceptionElement.addContent(classElement);
+
+        if ( parent != null ) {
+            exceptionElement = parent.addContent(exceptionElement);
+        }
+
+        return exceptionElement;
+    }
+}


Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryVisitationStrategy.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/test-integration/db/src/main/java/org/teiid/test/client/results/TestResultStat.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/results/TestResultStat.java	                        (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/results/TestResultStat.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -0,0 +1,122 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.test.client.results;
+
+import java.io.Serializable;
+
+import org.teiid.test.client.TestResult;
+
+/**
+ * ATestResultStat
+ *
+ * <p>A per-query set of result stats.</p>
+ */
+public class TestResultStat implements TestResult, Serializable {
+  
+    /**
+	 * @since
+	 */
+	private static final long serialVersionUID = 6670189391506288744L;
+	protected int resultStatus = -1;
+    protected String queryID;
+    protected String querySetID;
+    protected String errorMsg;
+    protected String query;
+    
+    private long beginTS;
+    private long endTS;
+    
+    private String errorFile;
+
+
+    public TestResultStat(final String querySetID, final String queryID, String query, final int resultStatus, long beginTS, long endTS, final Throwable error) {
+    	this.querySetID = querySetID;
+    	this.queryID = queryID;
+        this.resultStatus = resultStatus;
+        this.beginTS = beginTS;
+        this.endTS = endTS;
+        this.errorMsg = (error != null ? error.getMessage() : ""); //$NON-NLS-1$
+    }
+    
+    public TestResultStat(final String querySetID, final String queryID, String query, final int resultStatus, long beginTS, long endTS, final Throwable error, String errorFile) {
+    	this.querySetID = querySetID;
+    	this.queryID = queryID;
+        this.resultStatus = resultStatus;
+        this.beginTS = beginTS;
+        this.endTS = endTS;
+        this.errorMsg = (error != null ? error.getMessage() : ""); //$NON-NLS-1$
+        
+        this.errorFile = errorFile;
+    }
+
+    public String getResultStatusString() {
+        switch (resultStatus) {
+            case RESULT_STATE.TEST_SUCCESS:
+                return RESULT_STATE_STRING.PASS;
+            case RESULT_STATE.TEST_EXCEPTION:
+                return RESULT_STATE_STRING.FAIL;
+            case RESULT_STATE.TEST_EXPECTED_EXCEPTION:
+                return RESULT_STATE_STRING.FAIL_EXPECTED_EXCEPTION;
+        }
+        return RESULT_STATE_STRING.UNKNOWN;
+    }
+
+    
+
+	@Override
+	public String getQuerySetID() {
+		// TODO Auto-generated method stub
+		return this.querySetID;
+	}
+
+	public String getQueryID() {
+        return queryID;
+    }
+    
+    public String getQuery() {
+        return query;
+    }
+
+    public int getStatus() {
+        return resultStatus;
+    }
+
+    public String getExceptionMsg() {
+        return errorMsg;
+    }
+    
+    public long getBeginTS() {
+    	return beginTS;
+   	
+    }
+    
+    public long getEndTS() {
+    	return endTS;
+    }
+    
+    /**
+     * @return Returns the errorfile.
+     */
+    public String getErrorfile() {
+        return errorFile;
+    }
+}


Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/client/results/TestResultStat.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java	2009-12-09 20:14:18 UTC (rev 1627)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -8,20 +8,17 @@
 import org.teiid.test.framework.exception.TransactionRuntimeException;
 import org.teiid.test.util.PropUtils;
 
-import com.metamatrix.common.util.PropertiesUtils;
 
-
 /**
  * The ConfigProperteryLoader will load the configuration properties to be used by a test.
- * These properties only live for the duration of one test.
+ * Unless a different configuraton file is specified, subsequent loading of the configuration
+ * fill will not occur.  However, <code>overrides</code> that are applied per test
  * 
- * NOTE: System properties set by the VM will be considered long living.   This is so the 
- * 		-Dusedatasources ( {@link ConfigPropertyNames#USE_DATASOURCES_PROP} ) option can be maintained for the duration of a set of tests. 
  * 
- * 
  * @author vanhalbert
  *
  */
+
 public class ConfigPropertyLoader {
 
 	/**
@@ -57,7 +54,6 @@
 	    	if (_instance != null && !diff) {
 	    	    return _instance;
 	    	}
-
 	    	if (_instance != null) {
 	    	    cleanup();
 	    	}
@@ -91,20 +87,33 @@
 
 	}
 	
-	public static synchronized void cleanup() {
-	    _instance.overrides.clear();
+	private static synchronized void cleanup() {
+	    
 	    _instance.modelAssignedDatabaseType.clear();
 	    _instance.props.clear();
+
 	    if (_instance.dsfactory != null) {
 		_instance.dsfactory.cleanup();
 	    }
+	    
+	    reset();
+	    
 	    _instance = null;
 	    LAST_CONFIG_FILE=null;
 	}
+	
+	/**
+	 * Called after each test to reset any per test settings.
+	 */
+	public static synchronized void reset() {
+	    _instance.overrides.clear();
 
+	}
+
 	
 	private void initialize() {
-	    loadProperties(LAST_CONFIG_FILE);
+
+	    props = PropUtils.loadProperties("/" + LAST_CONFIG_FILE, null);
 	    dsfactory = new DataSourceFactory(this);
 	}
 	
@@ -129,6 +138,10 @@
 	public void setProperty(String key, String value) {
 	    	overrides.setProperty(key, value);
 	}
+	
+	public void setProperties(Properties props) {
+	    overrides.putAll(props);
+	}
 
 	public Properties getProperties() {
 	    
@@ -148,12 +161,7 @@
 		this.modelAssignedDatabaseType.put(modelname, dbtype);
 	}
 
-	private void loadProperties(String filename) {
-		
-		props = PropUtils.loadProperties("/" + filename, null);
 
-	}
-
 	public static void main(String[] args) {
 		System.setProperty("test", "value");
 
@@ -166,6 +174,22 @@
 		if (!p.getProperty("test").equalsIgnoreCase("value")) {
 			throw new RuntimeException("Failed to pickup system property");
 		}
+		
+		_instance.setProperty("override", "ovalue");
+		
+		if (!_instance.getProperties().getProperty("override").equalsIgnoreCase("ovalue")) {
+				throw new RuntimeException("Override value wasnt found");
+		}
+		
+		ConfigPropertyLoader.reset();
+		if (_instance.getProperties().getProperty("override") != null) {
+			throw new RuntimeException("Override value was found, should have been removed on reset");
+		}
+		
+		if (!p.getProperty("test").equalsIgnoreCase("value")) {
+			throw new RuntimeException("Failed to pickup system property");
+		}
+		
 		System.out.println("Loaded Config Properties " + p.toString());
 
 	}

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java	2009-12-09 20:14:18 UTC (rev 1627)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -1,5 +1,6 @@
 package org.teiid.test.framework;
 
+import org.teiid.test.framework.connection.ConnectionStrategy;
 import org.teiid.test.framework.datasource.DataSource;
 import org.teiid.test.framework.datasource.DataSourceMgr;
 
@@ -64,6 +65,18 @@
 	public static final String OVERRIDE_DATASOURCES_LOC = "datasourceloc";
 	
 	/**
+	 * If {@link DISABLE_DATASTORES} is specified, then the assumption is that configuration related
+	 * to the datastores is being handled out side of the test framework.
+	 * This include not performing the following:
+	 * <li>{@link DataStore} will not called to configure the data prior to running a test</li>
+	 * <li>The connector bindings will not be configured as part of the {@link ConnectionStrategy} vdb configuration.
+	 * The vdb must have the binding(s) defined. </li>
+	 * 
+	 * The {@link TestClientTransaction} will be using this option because the data is already assumed configured in its respective database.
+	 */
+	public static final String DISABLE_DATASTORES = "disable_datastore";
+	
+	/**
 	 * Connection Type indicates the type of connection (strategy) to use when 
 	 * connecting to Teiid.
 	 * Options are {@link CONNECTION_TYPES}

Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TestLogger.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TestLogger.java	                        (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TestLogger.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.test.framework;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * @author vanhalbert
+ *
+ */
+public class TestLogger {
+    
+    public static final Level INFO = Level.FINER;
+    public static final Level DEBUG = Level.FINEST;
+    public static final Level IMPORTANT = Level.FINE;
+    
+    private static final Logger LOGGER = Logger.getLogger("org.teiid.test");
+    
+    static {
+	LOGGER.setLevel(IMPORTANT);
+    }
+    
+    public static final void setLogLevel(Level level) {
+	LOGGER.setLevel(level);
+    }
+    
+    public static final void logDebug(String msg) {
+	log(Level.FINEST, msg, null);
+    }
+    
+    public static final void logDebug(String msg, Throwable t) {
+	log(Level.FINEST, msg, t);
+    }
+    
+    // info related messages, which
+    public static final void logInfo(String msg) {
+	log(Level.FINER, msg, null);
+    }
+    
+    // configuration related messages
+    public static final void logConfig(String msg) {
+	log(Level.CONFIG, msg, null);
+    }
+    
+    // most important messages
+    public static final void log(String msg) {
+	log(Level.FINE, msg, null);
+    }
+    
+    private static final void log(Level javaLevel, Object msg, Throwable t) {
+
+    	if (LOGGER.isLoggable(javaLevel)) {
+    		LOGGER.log(javaLevel, msg.toString(), t);
+    	}
+    }
+
+}


Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TestLogger.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java	2009-12-09 20:14:18 UTC (rev 1627)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -4,50 +4,20 @@
  */
 package org.teiid.test.framework;
 
-import java.util.Properties;
-
-import org.teiid.test.framework.connection.ConnectionStrategy;
-import org.teiid.test.framework.connection.ConnectionStrategyFactory;
-import org.teiid.test.framework.exception.QueryTestFailedException;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
 
 import com.metamatrix.core.util.StringUtil;
 
 public abstract class TransactionContainer {
 
-    private boolean debug = false;
-   
- 
     private String testClassName = null;
 
-    protected ConnectionStrategy connStrategy;
-    protected Properties props;
 
     protected TransactionContainer() {
-	ConfigPropertyLoader config = ConfigPropertyLoader.getInstance();
 	
-	try {
-	    this.connStrategy = ConnectionStrategyFactory
-		    .createConnectionStrategy(config);
-	} catch (QueryTestFailedException e) {
-	    // TODO Auto-generated catch block
-	    throw new TransactionRuntimeException(e);
-	}
-	this.props = new Properties();
-	this.props.putAll(this.connStrategy.getEnvironment());
-
     }
 
 
-    public ConnectionStrategy getConnectionStrategy() {
-	return this.connStrategy;
-    }
-    
-    
-    public void setEnvironmentProperty(String key, String value) {
-	this.getConnectionStrategy().getEnvironment().setProperty(key, value);
-    }
-
     protected void before(TransactionQueryTestCase test) {
     }
 
@@ -63,10 +33,14 @@
 	    detail("Start transaction test: " + test.getTestName());
 
 	    try {
-		test.setConnectionStrategy(connStrategy);
 
 		test.setup();
 
+	    } catch (TransactionRuntimeException tre) {  
+			if (!test.exceptionExpected()) {
+			    tre.printStackTrace();
+			}
+        		throw tre;
 	    } catch (Throwable e) {
 		if (!test.exceptionExpected()) {
 		    e.printStackTrace();
@@ -81,15 +55,8 @@
 	} finally {
 	    debug("	test.cleanup");
 
-	    try {
 		test.cleanup();
-	    } finally {
 
-		// cleanup all connections created for this test.
-		if (connStrategy != null) {
-		    connStrategy.shutdown();
-		}
-	    }
 	}
 
     }
@@ -120,6 +87,8 @@
 
 	    debug("End runTest: " + test.getTestName());
 
+	} catch (TransactionRuntimeException tre) {    
+	    throw tre;
 	} catch (Throwable e) {
 
 	    if (!test.exceptionExpected()) {
@@ -141,14 +110,11 @@
 
 
     protected void debug(String message) {
-	if (debug) {
-	    System.out.println("[" + this.testClassName + "] " + message);
-	}
-
+	TestLogger.logDebug("[" + this.testClassName + "] " + message);
     }
 
     protected void detail(String message) {
-	System.out.println("[" + this.testClassName + "] " + message);
+	TestLogger.log("[" + this.testClassName + "] " + message);
     }
 
     protected boolean done() {

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTestCase.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTestCase.java	2009-12-09 20:14:18 UTC (rev 1627)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTestCase.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -106,13 +106,13 @@
     String getTestName();
 
     /**
-     * Called to set the current connection strategy being used.
+     * Called to get the current connection strategy being used.
      * 
-     * @param connStrategy
+     * @return connStrategy
      * 
      * @since
      */
-    void setConnectionStrategy(ConnectionStrategy connStrategy)  throws QueryTestFailedException;
+    ConnectionStrategy getConnectionStrategy() ;
 
     /**
      * Called by the {@link TransactionContainer} prior to testcase processing

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java	2009-12-09 20:14:18 UTC (rev 1627)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -18,6 +18,8 @@
 import org.teiid.adminapi.AdminOptions;
 import org.teiid.adminapi.Model;
 import org.teiid.adminapi.VDB;
+import org.teiid.test.framework.ConfigPropertyNames;
+import org.teiid.test.framework.TestLogger;
 import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
 import org.teiid.test.framework.datasource.DataSource;
 import org.teiid.test.framework.datasource.DataSourceFactory;
@@ -73,13 +75,29 @@
         return null;
     }
     
+    /**
+     * In certain testcases, the data that being provided is already preconfigured and should not
+     * be touched by the {@link DataStore} processing.
+     * @return
+     */
+    public boolean isDataStoreDisabled() {
+	String disable_config =  getEnvironment().getProperty(ConfigPropertyNames.DISABLE_DATASTORES, null);
+	if (disable_config != null) {
+	    return true;
+	}
+	return false;
+    }
+    
 
     
     
     public Properties getEnvironment() {
     	return env;
     }
-    
+
+    public void setEnvironmentProperty(String key, String value) {
+	this.env.setProperty(key, value);
+    }
    
     class CloseInterceptor implements InvocationHandler {
 
@@ -103,6 +121,11 @@
    
     void configure() throws QueryTestFailedException  {
     	
+	if (this.isDataStoreDisabled()) {
+	    return;
+	}
+
+	
     	String ac = this.env.getProperty(CONNECTION_STRATEGY_PROPS.AUTOCOMMIT, "true");
     	this.autoCommit = Boolean.getBoolean(ac);
     	
@@ -127,9 +150,9 @@
             
             int sleep = 5;
  
-            System.out.println("Bouncing the system..(wait " + sleep + " seconds)"); //$NON-NLS-1$
+            TestLogger.log("Bouncing the system..(wait " + sleep + " seconds)"); //$NON-NLS-1$
             Thread.sleep(1000*sleep);
-            System.out.println("done."); //$NON-NLS-1$
+            TestLogger.log("done."); //$NON-NLS-1$
 
         } catch (Throwable e) {
         	e.printStackTrace();
@@ -155,9 +178,9 @@
 
 	    String urlString = this.env.getProperty(DriverConnection.DS_URL);
 	    MMJDBCURL url = new MMJDBCURL(urlString);
-	    System.out.println("Trying to match VDB : " + url.getVDBName());
+	    TestLogger.logDebug("Trying to match VDB : " + url.getVDBName());
 
-	    for (Iterator iterator = vdbs.iterator(); iterator.hasNext();) {
+	    for (Iterator<VDB> iterator = vdbs.iterator(); iterator.hasNext();) {
 		VDB v = (VDB) iterator.next();
 		if (v.getName().equalsIgnoreCase(url.getVDBName())) {
 		    vdb = v;
@@ -190,8 +213,7 @@
 
 		if (ds != null) {
 
-		    System.out
-			    .println("Set up Connector Binding (model:mapping:type): " + m.getName() + ":" + useName + ":" + ds.getConnectorType()); //$NON-NLS-1$
+		    TestLogger.logInfo("Set up Connector Binding (model:mapping:type): " + m.getName() + ":" + useName + ":" + ds.getConnectorType()); //$NON-NLS-1$
 
 		    AdminOptions ao = new AdminOptions(
 			    AdminOptions.OnConflict.OVERWRITE);
@@ -272,9 +294,9 @@
 	
 	ConnectionStrategy cs = null;
 	if (identifier == null) {
-	    cs = new DriverConnection(ds.getProperties(), this.dsFactory);
+	    cs = new DataSourceConnection(ds.getProperties(), this.dsFactory);
 	} else {
-	    cs = new DriverConnection(ds.getProperties(), this.dsFactory);
+	    cs = new DataSourceConnection(ds.getProperties(), this.dsFactory);
 	}
 	
 	ds.setXAConnection(cs);

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java	2009-12-09 20:14:18 UTC (rev 1627)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -8,8 +8,8 @@
 
 import org.teiid.test.framework.ConfigPropertyLoader;
 import org.teiid.test.framework.ConfigPropertyNames;
+import org.teiid.test.framework.TestLogger;
 import org.teiid.test.framework.datasource.DataSourceFactory;
-import org.teiid.test.framework.exception.QueryTestFailedException;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
 
 /**
@@ -21,36 +21,44 @@
 public class ConnectionStrategyFactory {
 	
     
-	    public static ConnectionStrategy createConnectionStrategy(ConfigPropertyLoader configprops) throws QueryTestFailedException {
-	     	ConnectionStrategy strategy = null;
-	     	Properties props = configprops.getProperties();
+	    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 RuntimeException("Property " + ConfigPropertyNames.CONNECTION_TYPE + " was specified");
+	        	throw new TransactionRuntimeException("Property " + ConfigPropertyNames.CONNECTION_TYPE + " was specified");
 	        }
 	        
-	        if (type.equalsIgnoreCase(ConfigPropertyNames.CONNECTION_TYPES.DRIVER_CONNECTION)) {
-	        	// pass in null to create new strategy
-	                strategy = new DriverConnection(props, configprops.getDataSourceFactory());
-	                System.out.println("Created Driver Strategy");
-	        }
-	        else if (type.equalsIgnoreCase(ConfigPropertyNames.CONNECTION_TYPES.DATASOURCE_CONNECTION)) {
-	            strategy = new DataSourceConnection(props, configprops.getDataSourceFactory());
-	            System.out.println("Created DataSource Strategy");
-	        }
-	        else if (type.equalsIgnoreCase(ConfigPropertyNames.CONNECTION_TYPES.JNDI_CONNECTION)) {
-	            strategy = new JEEConnection(props, configprops.getDataSourceFactory());
-	            System.out.println("Created JEE Strategy");
-	        }   
+	        try {
 	        
-	        if (strategy == null) {
-	        	new TransactionRuntimeException("Invalid property value for " + ConfigPropertyNames.CONNECTION_TYPE + " is " + type );
+        	        if (type.equalsIgnoreCase(ConfigPropertyNames.CONNECTION_TYPES.DRIVER_CONNECTION)) {
+        	        	// pass in null to create new strategy
+        	                strategy = new DriverConnection(props, configLoader.getDataSourceFactory());
+        	                TestLogger.log("Created Driver Strategy");
+        	        }
+        	        else if (type.equalsIgnoreCase(ConfigPropertyNames.CONNECTION_TYPES.DATASOURCE_CONNECTION)) {
+        	            strategy = new DataSourceConnection(props, configLoader.getDataSourceFactory());
+        	            TestLogger.log("Created DataSource Strategy");
+        	        }
+        	        else if (type.equalsIgnoreCase(ConfigPropertyNames.CONNECTION_TYPES.JNDI_CONNECTION)) {
+        	            strategy = new JEEConnection(props, configLoader.getDataSourceFactory());
+        	            TestLogger.log("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);
 	        }
-	        // 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;
 
 	    }	    
 	    

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java	2009-12-09 20:14:18 UTC (rev 1627)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -8,15 +8,18 @@
 import java.sql.SQLException;
 import java.util.Properties;
 
+import javax.sql.DataSource;
 import javax.sql.XAConnection;
 import javax.sql.XADataSource;
 
 import org.teiid.connector.jdbc.JDBCPropertyNames;
 import org.teiid.jdbc.TeiidDataSource;
+import org.teiid.test.framework.TestLogger;
 import org.teiid.test.framework.datasource.DataSourceFactory;
 import org.teiid.test.framework.exception.QueryTestFailedException;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
 
+import com.metamatrix.common.util.PropertiesUtils;
 import com.metamatrix.jdbc.BaseDataSource;
 import com.metamatrix.jdbc.EmbeddedDataSource;
 
@@ -33,12 +36,16 @@
     // connector type will provide the JDBCPropertyNames.CONNECTION_SOURCE
     // driver class
     public static final String DS_DRIVER = "driver"; //$NON-NLS-1$
+    
+    public static final String DS_DATASOURCE = "datasource"; //$NON-NLS-1$
 
+
     public static final String DS_SERVERNAME = "ServerName"; //$NON-NLS-1$
     public static final String DS_SERVERPORT = "PortNumber"; //$NON-NLS-1$
     public static final String DS_JNDINAME = "ds-jndiname"; //$NON-NLS-1$
     public static final String DS_DATABASENAME = "DatabaseName"; //$NON-NLS-1$
     public static final String DS_APPLICATION_NAME = "application-name"; //$NON-NLS-1$
+    public static final String DS_URL = "URL"; //$NON-NLS-1$
 
     private String driver = null;
     private String username = null;
@@ -47,6 +54,7 @@
     private String databaseName = null;
     private String serverName = null;
     private String portNumber = null;
+    private String url = null;
 
     private XAConnection xaConnection;
 
@@ -72,11 +80,22 @@
 
 	this.applName = this.getEnvironment().getProperty(DS_APPLICATION_NAME);
 
-	this.driver = this.getEnvironment().getProperty(DS_DRIVER);
-	if (this.driver == null || this.driver.length() == 0) {
-	    throw new TransactionRuntimeException("Property " + DS_DRIVER
-		    + " was not specified");
+	if (this.getEnvironment().getProperty(DS_DATASOURCE) != null) {
+            	this.driver = this.getEnvironment().getProperty(DS_DATASOURCE);
+        	if (this.driver == null || this.driver.length() == 0) {
+        	    throw new TransactionRuntimeException("Property " + DS_DATASOURCE
+        		    + " was null");
+        	}
+	    
+	} else {
+        	this.driver = this.getEnvironment().getProperty(DS_DRIVER);
+        	if (this.driver == null || this.driver.length() == 0) {
+        	    throw new TransactionRuntimeException("Property " + DS_DRIVER
+        		    + " was not specified");
+        	}
 	}
+	
+	this.url = this.getEnvironment().getProperty(DS_URL);
 
 	this.username = this.getEnvironment().getProperty(DS_USER);
 	if (username == null) {
@@ -113,32 +132,55 @@
     private XAConnection createConnection() throws SQLException,
 	    InstantiationException, IllegalAccessException,
 	    ClassNotFoundException {
-	System.out
-		.println("Creating Datasource Connection: \"" + this.serverName + " - " + this.databaseName + "\""); //$NON-NLS-1$ //$NON-NLS-2$
+	TestLogger.log("Creating Datasource Connection: \"" + this.serverName + " - " + this.databaseName + "\""); //$NON-NLS-1$ //$NON-NLS-2$
 
-	BaseDataSource dataSource = (BaseDataSource) Class.forName(this.driver)
-		.newInstance();
+ //   	DataSource dataSource = (DataSource)Class.forName(props.getProperty(prefix+DS_DRIVER)).newInstance();
+ 
 
-	dataSource.setDatabaseName(this.databaseName);
-	if (this.applName != null) {
-	    dataSource.setApplicationName(this.applName);
-	}
-
-	if (dataSource instanceof EmbeddedDataSource) {
-	    ((EmbeddedDataSource) dataSource).setBootstrapFile(this.serverName);
+    	DataSource ds = (DataSource)Class.forName(this.driver).newInstance();
+	
+	if (ds instanceof BaseDataSource) {
+        	BaseDataSource dataSource = (BaseDataSource)  ds;
+        	//Class.forName(this.driver).newInstance();
+        
+        	dataSource.setDatabaseName(this.databaseName);
+        	if (this.applName != null) {
+        	    dataSource.setApplicationName(this.applName);
+        	}
+        
+        	if (dataSource instanceof EmbeddedDataSource) {
+        	    ((EmbeddedDataSource) dataSource).setBootstrapFile(this.serverName);
+        	} else {
+        	    ((TeiidDataSource) dataSource).setServerName(this.serverName);
+        	    ((TeiidDataSource) dataSource).setPortNumber(Integer
+        		    .parseInt(this.portNumber));
+        	}
+        	
+        	if (this.username != null) {
+        	    dataSource.setUser(this.username);
+        	    dataSource.setPassword(this.pwd);
+        	}
+        	
+        	return ((XADataSource) dataSource).getXAConnection(this.username,
+        		this.pwd);
 	} else {
-	    ((TeiidDataSource) dataSource).setServerName(this.serverName);
-	    ((TeiidDataSource) dataSource).setPortNumber(Integer
-		    .parseInt(this.portNumber));
+	    	Properties props = new Properties();
+	    	props.setProperty(DS_DATABASENAME, this.databaseName);
+	    	props.setProperty(DS_SERVERPORT, this.portNumber);
+	    	props.setProperty(DS_URL, this.url);
+	    	props.setProperty(DS_SERVERNAME, this.serverName);
+        	if (this.username != null) {
+        	    props.setProperty(DS_USERNAME, this.username);
+        	    props.setProperty(DS_USER, this.username);
+        	    props.setProperty(DS_PASSWORD, this.pwd);
+        	}
+	    	
+	   	PropertiesUtils.setBeanProperties(ds, props, null);
+	   	Object z = ds.getConnection();
+	   	return ((XADataSource)ds).getXAConnection();
 	}
 
-	if (this.username != null) {
-	    dataSource.setUser(this.username);
-	    dataSource.setPassword(this.pwd);
-	}
 
-	return ((XADataSource) dataSource).getXAConnection(this.username,
-		this.pwd);
     }
 
     public void shutdown() {

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java	2009-12-09 20:14:18 UTC (rev 1627)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -4,16 +4,19 @@
  */
 package org.teiid.test.framework.connection;
 
+import java.lang.reflect.Proxy;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
 import java.util.Properties;
 
 import org.teiid.connector.jdbc.JDBCPropertyNames;
+import org.teiid.test.framework.TestLogger;
 import org.teiid.test.framework.datasource.DataSourceFactory;
 import org.teiid.test.framework.exception.QueryTestFailedException;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
 
+
 /**
  * The DriverConnection strategy that can get connections in standalone mode or
  * embedded mode.
@@ -111,9 +114,9 @@
     private Connection getJDBCConnection(String driver, String url,
 	    String user, String passwd) throws QueryTestFailedException {
 
-	System.out.println("Creating Driver Connection: \"" + url + "\""); //$NON-NLS-1$ //$NON-NLS-2$
+	TestLogger.log("Creating Driver Connection: \"" + url + "\""); //$NON-NLS-1$ //$NON-NLS-2$
 
-	Connection conn;
+	Connection conn = null;
 	try {
 	    // Create a connection
 	    if (user != null && user.length() > 0) {
@@ -121,9 +124,12 @@
 	    } else {
 		conn = DriverManager.getConnection(url);
 	    }
+	    
+	conn = (Connection)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {java.sql.Connection.class}, new CloseInterceptor(conn)); 
 
-	} catch (SQLException e) {
-	    throw new QueryTestFailedException(e);
+
+//	} catch (SQLException e) {
+ 
 	} catch (Throwable t) {
 	    t.printStackTrace();
 	    throw new QueryTestFailedException(t.getMessage());

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java	2009-12-09 20:14:18 UTC (rev 1627)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -11,7 +11,9 @@
 
 import org.teiid.test.framework.ConfigPropertyLoader;
 import org.teiid.test.framework.ConfigPropertyNames;
+import org.teiid.test.framework.TestLogger;
 import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
 
 import com.metamatrix.common.util.PropertiesUtils;
 import com.metamatrix.core.util.StringUtil;
@@ -142,7 +144,7 @@
 	 * @since
 	 */
 	private void config() {
-		System.out.println("Configure Datasource Factory ");
+	    TestLogger.logDebug("Configure Datasource Factory ");
 		
 		Map<String, DataSource> availDatasources = dsmgr.getDataSources();
 		
@@ -180,7 +182,7 @@
 		String limitdsprop = configprops
 				.getProperty(ConfigPropertyNames.USE_DATASOURCES_PROP);
 		if (limitdsprop != null && limitdsprop.length() > 0 && ! limitdsprop.equalsIgnoreCase(DO_NOT_USE_DEFAULT)) {
-			System.out.println("Use ONLY datasources: " + limitdsprop);
+		    TestLogger.log("Use ONLY datasources: " + limitdsprop);
 
 			List<String> dss = StringUtil.split(limitdsprop, ",");
 
@@ -196,7 +198,7 @@
 					useDS.put(String.valueOf(i), dssName);
 				
 					availDS.put(dssName, ds);
-					System.out.println("Using ds: " + dssName);
+					TestLogger.logInfo("Using ds: " + dssName);
 				}
 				
 			}
@@ -406,7 +408,7 @@
 
 		try {
 			if (factory.getDatasource("1", "model1") == null) {
-				throw new RuntimeException("No datasource was not found");
+				throw new TransactionRuntimeException("No datasource was not found");
 			}
 			
 
@@ -416,7 +418,7 @@
 		
 		factory.cleanup();
 		
-		ConfigPropertyLoader.cleanup();
+		ConfigPropertyLoader.reset();
 
 		
 		// the following verifies that order of "use" datasources is applied to request for datasources.
@@ -430,26 +432,26 @@
 			
 			DataSource dsfind = factory.getDatasource("2", "model2");
 			if (dsfind == null) {
-				throw new RuntimeException("No datasource was not found as the 2nd datasource");
+				throw new TransactionRuntimeException("No datasource was not found as the 2nd datasource");
 				
 			}
 			
 			if (dsfind.getConnectorType() == null) {
-				throw new RuntimeException("Connector types was not defined");
+				throw new TransactionRuntimeException("Connector types was not defined");
 			}
 			
 			if (!dsfind.getName().equalsIgnoreCase("sqlserver")) {
-				throw new RuntimeException("Sqlserver was not found as the 2nd datasource");
+				throw new TransactionRuntimeException("Sqlserver was not found as the 2nd datasource");
 				
 			}
 			
 			dsfind = factory.getDatasource("1", "model1");
 			if (dsfind == null) {
-				throw new RuntimeException("No datasource was not found as the 2nd datasource");
+				throw new TransactionRuntimeException("No datasource was not found as the 2nd datasource");
 				
 			}
 			if (!dsfind.getName().equalsIgnoreCase("oracle")) {
-				throw new RuntimeException("Oracle was not found as the 2nd datasource");
+				throw new TransactionRuntimeException("Oracle was not found as the 2nd datasource");
 				
 			}
 			System.out.println("Datasource :" + dsfind.getName() + " was found");
@@ -459,7 +461,7 @@
 			// returned (excluded)
 			factory.cleanup();
 		
-			ConfigPropertyLoader.cleanup();
+			ConfigPropertyLoader.reset();
 
 
 			config = ConfigPropertyLoader.getInstance();
@@ -469,17 +471,17 @@
 			factory = new DataSourceFactory(config);
 
 			int n = factory.getNumberAvailableDataSources();
-			System.out.println("Num avail datasources: " + n);
+			TestLogger.log("Num avail datasources: " + n);
 
 			for (int i=0; i<n; i++) {
 				
 				String k = String.valueOf(i);
 				DataSource ds1 = factory.getDatasource(k, "model" + k);
 				if (ds1 == null) {
-					throw new RuntimeException("No datasource was found for: model:" + k);
+					throw new TransactionRuntimeException("No datasource was found for: model:" + k);
 					
 				} if (ds1.getDBType().equalsIgnoreCase(DataSourceFactory.DataBaseTypes.SQLSERVER)) {
-					throw new RuntimeException("sqlserver dbtype should have been excluded");
+					throw new TransactionRuntimeException("sqlserver dbtype should have been excluded");
 				}
 			}
 				
@@ -488,13 +490,13 @@
 				if (reuse != null) {
 					
 				} else {
-					throw new RuntimeException("The process was not able to reassign an already used datasource");
+					throw new TransactionRuntimeException("The process was not able to reassign an already used datasource");
 					
 				}
 				
 				factory.cleanup();
 				
-				ConfigPropertyLoader.cleanup();
+				ConfigPropertyLoader.reset();
 
 				
 				// test required database types
@@ -508,13 +510,13 @@
 
 				DataSource ds1 = factory.getDatasource("1","pm1");
 				if (!ds1.getDBType().equalsIgnoreCase(DataSourceFactory.DataBaseTypes.ORACLE)) {
-					throw new RuntimeException("Required DB Type of oracle for model pm1 is :" + ds1.getDBType());
+					throw new TransactionRuntimeException("Required DB Type of oracle for model pm1 is :" + ds1.getDBType());
 				}
 				
-				System.out.println("Test1 Required DS1 " + ds1.getDBType());
+				TestLogger.log("Test1 Required DS1 " + ds1.getDBType());
 				factory.cleanup();
 				
-				ConfigPropertyLoader.cleanup();
+				ConfigPropertyLoader.reset();
 
 				// test required database types
 				// test 2 sources, 1 required and other ANY
@@ -528,12 +530,12 @@
 
 				DataSource ds2 = factory.getDatasource("2","pm2");
 				if (!ds2.getDBType().equalsIgnoreCase(DataSourceFactory.DataBaseTypes.SQLSERVER)) {
-					throw new RuntimeException("Required DB Type of sqlserver for model pm2 is :" + ds2.getDBType());
+					throw new TransactionRuntimeException("Required DB Type of sqlserver for model pm2 is :" + ds2.getDBType());
 				}
-				System.out.println("Test2 Required DS2 " + ds2.getDBType());
+				TestLogger.log("Test2 Required DS2 " + ds2.getDBType());
 			
 				factory.cleanup();
-				ConfigPropertyLoader.cleanup();
+				ConfigPropertyLoader.reset();
 
 				
 				// test required database types
@@ -548,15 +550,15 @@
 
 				DataSource ds3a = factory.getDatasource("2","pm2");
 				if (!ds3a.getDBType().equalsIgnoreCase(DataSourceFactory.DataBaseTypes.SQLSERVER)) {
-					throw new RuntimeException("Required DB Type of sqlserver for model pm12 is :" + ds3a.getDBType());
+					throw new TransactionRuntimeException("Required DB Type of sqlserver for model pm12 is :" + ds3a.getDBType());
 				}
 				
 				DataSource ds3b = factory.getDatasource("2","pm1");
 				if (!ds3b.getDBType().equalsIgnoreCase(DataSourceFactory.DataBaseTypes.ORACLE)) {
-					throw new RuntimeException("Required DB Type of oracle for model pm1  is :" + ds3b.getDBType());
+					throw new TransactionRuntimeException("Required DB Type of oracle for model pm1  is :" + ds3b.getDBType());
 				}
-				System.out.println("Test3 Required DS3a " + ds3a.getDBType());
-				System.out.println("Test3 Required DS3b " + ds3b.getDBType());
+				TestLogger.log("Test3 Required DS3a " + ds3a.getDBType());
+				TestLogger.log("Test3 Required DS3b " + ds3b.getDBType());
 				
 				factory.cleanup();
 			

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java	2009-12-09 20:14:18 UTC (rev 1627)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -7,13 +7,13 @@
 import java.io.File;
 import java.io.FileFilter;
 import java.io.IOException;
-import java.io.InputStream;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
 
 import org.teiid.test.framework.ConfigPropertyLoader;
 import org.teiid.test.framework.ConfigPropertyNames;
+import org.teiid.test.framework.TestLogger;
 import org.teiid.test.framework.exception.QueryTestFailedException;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
 
@@ -108,9 +108,9 @@
 	
 	if (dsloc == null || dsloc.indexOf(UNASSIGNEDDSLOC) > -1) {
 	    dsloc = DEFAULT_DATASOURCES_LOC;
-	    System.out.println("Using default datasource loc: " +dsloc);
+	    TestLogger.log("Using default datasource loc: " +dsloc);
 	} else {
-	    System.out.println("Using override for datasources loc: " + dsloc);
+	    TestLogger.log("Using override for datasources loc: " + dsloc);
 	}
 	
 	File[] dirs = findAllChildDirectories(dsloc);
@@ -135,7 +135,7 @@
  
 	}
 
-	System.out.println("Number of total datasource mappings loaded "
+	TestLogger.logDebug("Number of total datasource mappings loaded "
 		+ allDatasourcesMap.size());
 
     }
@@ -178,25 +178,22 @@
 
     }
 
-    private void addDataSource(File datasourcedir, //String dirname, String dirloc,
+    private void addDataSource(File datasourcedir, 
 	    Map<String, DataSource> datasources) {
 	
-//	String dirname = datasourcefile.getName();
-	
 	File dsfile = new File(datasourcedir, "connection.properties");
 	
 	if (!dsfile.exists()) {
 	    return;
 	}
 
-//	String dsfile = "/datasources/" + dirname + "/connection.properties";
 	Properties dsprops = loadProperties(dsfile);
 
 	if (dsprops != null) {
 
 	    DataSource ds = new DataSource(datasourcedir.getName(), "dsgroup", dsprops);
 	    datasources.put(ds.getName(), ds);
-	    System.out.println("Loaded datasource " + ds.getName());
+	    TestLogger.log("Loaded datasource " + ds.getName());
 
 	}
 
@@ -210,13 +207,6 @@
 	    props = PropertiesUtils.load(dsfile.getAbsolutePath());
 	    return props;
 	    
-//	    InputStream in = DataSourceMgr.class.getResourceAsStream(dsfile.getAbsolutePath());
-//	    if (in != null) {
-//		props = new Properties();
-//		props.load(in);
-//		return props;
-//	    }
-//	    return null;
 	} catch (IOException e) {
 	    throw new TransactionRuntimeException(
 		    "Error loading properties from file '" + dsfile.getAbsolutePath() + "'"

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataStore.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataStore.java	2009-12-09 20:14:18 UTC (rev 1627)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataStore.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -7,7 +7,6 @@
 import java.sql.Connection;
 import java.sql.Statement;
 
-import org.teiid.test.framework.ConfigPropertyLoader;
 import org.teiid.test.framework.connection.ConnectionStrategy;
 import org.teiid.test.framework.exception.QueryTestFailedException;
 
@@ -15,16 +14,18 @@
  * This class loads the data in the databases specified, to a known state
  */
 public class DataStore {
-
-    /**
+    
+     /**
      * Called at the start of all the tests to initialize the database to ensure
      * it's in the proper state.
      * 
      * @param connStrategy
      */
     public static void initialize(ConnectionStrategy connStrategy) {
-//	ConfigPropertyLoader.cleanup();
-//	ConfigPropertyLoader.getInstance();
+	
+	if (connStrategy.isDataStoreDisabled()) {
+	    return;
+	}
 	try {
 	    load(getConnection("pm1", connStrategy));
 	    
@@ -87,6 +88,9 @@
      * @param connStrategy
      */
     public static void setup(ConnectionStrategy connStrategy) {
+	if (connStrategy.isDataStoreDisabled()) {
+	    return;
+	}
 	try {
 	    setUpTest(getConnection("pm1", connStrategy));
 	    

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java	2009-12-09 20:14:18 UTC (rev 1627)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -11,10 +11,13 @@
 
 import javax.sql.XAConnection;
 
+import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.TestLogger;
 import org.teiid.test.framework.TransactionContainer;
 import org.teiid.test.framework.TransactionQueryTestCase;
 import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
 import org.teiid.test.framework.connection.ConnectionStrategy;
+import org.teiid.test.framework.connection.ConnectionStrategyFactory;
 import org.teiid.test.framework.datasource.DataStore;
 import org.teiid.test.framework.exception.QueryTestFailedException;
 
@@ -55,10 +58,13 @@
 
     public AbstractQueryTransactionTest() {
 	super();
+	
+	this.connStrategy = ConnectionStrategyFactory
+	    .createConnectionStrategy();
     }
 
     public AbstractQueryTransactionTest(String testname) {
-	super();
+	this();
 	this.testname = testname;
     }
 
@@ -67,15 +73,7 @@
 	
     }
     
-
-    @Override
-    public void setConnectionStrategy(ConnectionStrategy connStrategy) throws QueryTestFailedException {
-	this.connStrategy = connStrategy;
-	
-	this.setConnection(connStrategy.getConnection());
-
-    }
-
+    
 //    @Override
 //    protected void compareResults(BufferedReader resultReader,
 //	    BufferedReader expectedReader) throws IOException {
@@ -84,6 +82,12 @@
 //    }
 
     @Override
+    public ConnectionStrategy getConnectionStrategy() {
+	// TODO Auto-generated method stub
+	return this.connStrategy;
+    }
+
+    @Override
     protected void assignExecutionProperties(Statement stmt) {
 	if (stmt instanceof com.metamatrix.jdbc.api.Statement) {
 	    com.metamatrix.jdbc.api.Statement statement = (com.metamatrix.jdbc.api.Statement) stmt;
@@ -107,7 +111,7 @@
 		    try {
 			fetchSize = Integer.parseInt(fetchSizeStr);
 			
-			this.print("FetchSize = " + fetchSize);
+			TestLogger.log("FetchSize = " + fetchSize);
 		    } catch (NumberFormatException e) {
 			fetchSize = -1;
 		    // this.print("Invalid fetch size value: " + fetchSizeStr
@@ -123,7 +127,7 @@
 		try {
 		    statement.setFetchSize(this.fetchSize);
 		} catch (SQLException e) {
-//		    this.print(e);
+		    TestLogger.log(e.getMessage());
 		}
 	    }
 
@@ -131,7 +135,7 @@
 		try {
 		    statement.setQueryTimeout(this.queryTimeout);
 		} catch (SQLException e) {
-//		    this.print(e);
+		    TestLogger.log(e.getMessage());
 		}
 	    }
 	}
@@ -151,17 +155,30 @@
      */
     @Override
     public void setup() throws QueryTestFailedException {
-
-	if (initialized == null || !initialized.equalsIgnoreCase(this.getClass().getSimpleName()) ) {
-	    initialized = this.getClass().getSimpleName();
-	    DataStore.initialize(connStrategy);
-	    
-	}
 	
-	DataStore.setup(connStrategy);
+	this.setConnection(connStrategy.getConnection());
+	setupDataStore();
 	
     }
+    
+    protected void setupDataStore() {
+	
+	
+	if (! this.getConnectionStrategy().isDataStoreDisabled()) {
+	    TestLogger.logDebug("Perform DataStore setup for test: " + this.testname );
+        	if (initialized == null || !initialized.equalsIgnoreCase(this.getClass().getSimpleName()) ) {
+        	    initialized = this.getClass().getSimpleName();
+        	    DataStore.initialize(connStrategy);
+        	    
+        	}
+        	
+        	DataStore.setup(connStrategy);
+	} else {
+	    TestLogger.logDebug("DataStore setup is disabled for test: " + this.testname );
+	}
 
+    }
+
     /**
      * The source connection must be asked from the connection strategy because only here
      * is it known which model was mapped to which datasource.
@@ -242,6 +259,13 @@
      * end of the test.
      */
     public void cleanup() {
+	
+	ConfigPropertyLoader.reset();
+	
+	// cleanup all connections created for this test.
+	if (connStrategy != null) {
+	    connStrategy.shutdown();
+	}
 
     }
 

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java	2009-12-09 20:14:18 UTC (rev 1627)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -7,9 +7,9 @@
 import javax.naming.InitialContext;
 import javax.transaction.UserTransaction;
 
+import org.teiid.test.framework.ConfigPropertyNames;
 import org.teiid.test.framework.TransactionContainer;
 import org.teiid.test.framework.TransactionQueryTestCase;
-import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
 
 
@@ -24,7 +24,8 @@
     }
     
     protected void before(TransactionQueryTestCase test) {
-        if (this.props.getProperty(CONNECTION_STRATEGY_PROPS.JNDINAME_USERTXN) == null) {
+	String jndi = test.getConnectionStrategy().getEnvironment().getProperty(ConfigPropertyNames.CONNECTION_STRATEGY_PROPS.JNDINAME_USERTXN);
+	if (jndi == null) {
             throw new TransactionRuntimeException("No JNDI name found for the User Transaction to look up in application server");
         }
 
@@ -32,8 +33,8 @@
  
             // begin the transaction
             InitialContext ctx = new InitialContext();
-            this.userTxn = (UserTransaction)ctx.lookup(this.props.getProperty(CONNECTION_STRATEGY_PROPS.JNDINAME_USERTXN));
-            this.userTxn.begin();
+            this.userTxn = (UserTransaction)ctx.lookup(jndi);
+             this.userTxn.begin();
         } catch (Exception e) {
             throw new TransactionRuntimeException(e);
         }        

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java	2009-12-09 20:14:18 UTC (rev 1627)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -7,7 +7,6 @@
 
 import java.sql.SQLException;
 
-import org.teiid.test.framework.ConfigPropertyLoader;
 import org.teiid.test.framework.TransactionContainer;
 import org.teiid.test.framework.TransactionQueryTestCase;
 import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
@@ -24,13 +23,13 @@
 	super();
     }
     protected void before(TransactionQueryTestCase test) {
-	this.setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_OFF);
+	test.getConnectionStrategy().setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_OFF);
 	
         try {
-        	debug("Autocommit: " + this.connStrategy.getAutocommit());
-            test.getConnection().setAutoCommit(this.connStrategy.getAutocommit());
+       		debug("Autocommit: " + test.getConnectionStrategy().getAutocommit());
+            test.getConnection().setAutoCommit(test.getConnectionStrategy().getAutocommit());
         } catch (SQLException e) {
-            throw new RuntimeException(e);
+            throw new TransactionRuntimeException(e);
         }        
     }
     
@@ -42,9 +41,10 @@
                 
             }
             else {
-                test.getConnection().commit();
+                 test.getConnection().commit();
             }
         } catch (SQLException se) {
+             se.printStackTrace();
         	exception =  true;
         	// if exception, try to trigger the rollback
         	try {
@@ -62,7 +62,7 @@
 	            try {
 	                test.getConnection().setAutoCommit(true);
 	            } catch (SQLException e) {
-	                throw new RuntimeException(e);
+	                throw new TransactionRuntimeException(e);
 	            }
         	}
         }

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OffWrapTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OffWrapTransaction.java	2009-12-09 20:14:18 UTC (rev 1627)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OffWrapTransaction.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -23,7 +23,7 @@
     }
     
     public void before(TransactionQueryTestCase test) {
-	this.setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_OFF);
+	test.getConnectionStrategy().setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_OFF);
 
         
     }

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OnWrapTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OnWrapTransaction.java	2009-12-09 20:14:18 UTC (rev 1627)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OnWrapTransaction.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -21,7 +21,7 @@
     }
         
     public void before(TransactionQueryTestCase test) {
-	this.setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_ON);
+	test.getConnectionStrategy().setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_ON);
 
         
     }

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java	2009-12-09 20:14:18 UTC (rev 1627)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -21,7 +21,7 @@
     }
     
     public void before(TransactionQueryTestCase test) {
-	this.setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_OPTIMISTIC);
+	test.getConnectionStrategy().setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_OPTIMISTIC);
 
     }
     

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java	2009-12-09 20:14:18 UTC (rev 1627)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -21,7 +21,7 @@
     }
     
     public void before(TransactionQueryTestCase test) {
-	this.setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_PESSIMISTIC);
+	test.getConnectionStrategy().setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_PESSIMISTIC);
 
     }
     

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/StandaloneGlobalTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/StandaloneGlobalTransaction.java	2009-12-09 20:14:18 UTC (rev 1627)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/StandaloneGlobalTransaction.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -25,9 +25,8 @@
     protected void before(TransactionQueryTestCase test) {
         try {          
         	xid = createXid();
-        	XAResource xaResource = this.getConnectionStrategy().getXAConnection().getXAResource();
-  //      	    getXAConnection().getXAResource();
-        	xaResource.setTransactionTimeout(120);
+        	XAResource xaResource = test.getConnectionStrategy().getXAConnection().getXAResource();
+         	xaResource.setTransactionTimeout(120);
         	xaResource.start(xid, XAResource.TMNOFLAGS);
         } catch (Exception e) {
             throw new TransactionRuntimeException(e);
@@ -46,7 +45,7 @@
         boolean delistSuccessful = false;
         boolean commit = false;
         try {
-            XAResource xaResource = this.getConnectionStrategy().getXAConnection().getXAResource();
+            XAResource xaResource = test.getConnectionStrategy().getXAConnection().getXAResource();
             
 			xaResource.end(xid, XAResource.TMSUCCESS);
             
@@ -59,11 +58,10 @@
         } finally {
             try {
                 if (!delistSuccessful || test.rollbackAllways()|| test.exceptionOccurred()) {
-                    this.getConnectionStrategy().getXAConnection().getXAResource().rollback(xid);
-                //getXAConnection().getXAResource().rollback(xid);
-                }
+                    test.getConnectionStrategy().getXAConnection().getXAResource().rollback(xid);
+                 }
                 else if (commit) {
-                    this.getConnectionStrategy().getXAConnection().getXAResource().commit(xid, true);
+                    test.getConnectionStrategy().getXAConnection().getXAResource().commit(xid, true);
                 }            
             } catch (Exception e) {
                 throw new TransactionRuntimeException(e);            

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java	2009-12-09 20:14:18 UTC (rev 1627)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java	2009-12-09 20:17:56 UTC (rev 1628)
@@ -6,13 +6,10 @@
 
 import java.util.Random;
 
-import javax.sql.XAConnection;
 import javax.transaction.xa.XAResource;
 
-import org.teiid.test.framework.ConfigPropertyLoader;
 import org.teiid.test.framework.TransactionContainer;
 import org.teiid.test.framework.TransactionQueryTestCase;
-import org.teiid.test.framework.exception.QueryTestFailedException;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
 
 import com.metamatrix.common.xa.MMXid;
@@ -28,7 +25,7 @@
     protected void before(TransactionQueryTestCase test) {
         try {          
         	xid = createXid();
-        	XAResource xaResource = getXAConnection().getXAResource();
+        	XAResource xaResource = test.getConnectionStrategy().getXAConnection().getXAResource();
         	xaResource.setTransactionTimeout(120);
         	xaResource.start(xid, XAResource.TMNOFLAGS);
         	debug("Start transaction using XID: " + xid.toString());
@@ -53,9 +50,9 @@
         XAResource xaResource = null;
         boolean exception = false;
         try {
-        	xaResource = getXAConnection().getXAResource();
+        	xaResource = test.getConnectionStrategy().getXAConnection().getXAResource();
             
-			xaResource.end(xid, XAResource.TMSUCCESS);
+		xaResource.end(xid, XAResource.TMSUCCESS);
             
             if (!test.exceptionExpected() && xaResource.prepare(xid) == XAResource.XA_OK) {
             	commit = true;
@@ -80,8 +77,4 @@
         }
     }    
     
-  
-    protected XAConnection getXAConnection() throws QueryTestFailedException {
-    	return this.connStrategy.getXAConnection();
-    }
 }



More information about the teiid-commits mailing list