[teiid-commits] teiid SVN: r1612 - in branches/JCA/test-integration/db: src/main/java/org/teiid/test/framework and 10 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Tue Dec 1 14:45:18 EST 2009


Author: rareddy
Date: 2009-12-01 14:45:17 -0500 (Tue, 01 Dec 2009)
New Revision: 1612

Added:
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTestCase.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataStore.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/query/
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/query/QueryExecution.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OffWrapTransaction.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OnWrapTransaction.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/StandaloneGlobalTransaction.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/StringUtil.java
   branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/CommonTransactionTests.java
   branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionTests.java
   branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/OffWrapTransactionTests.java
   branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/OnWrapTransactionTests.java
   branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/OptimisticWrapTransactionTests.java
   branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/PessimisticWrapTransactionTests.java
   branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/StandaloneGlobalTransactionTests.java
Removed:
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/DataSourceSetup.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/query/QueryExecution.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/ArgCheck.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/ChecksumUtil.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/FileUtils.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/StringUtil.java
   branches/JCA/test-integration/db/src/test/java/org/teiid/test/framework/
Modified:
   branches/JCA/test-integration/db/howto
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/connection/JEEConnection.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java
   branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/PropUtils.java
   branches/JCA/test-integration/db/src/main/resources/configuration.xml
   branches/JCA/test-integration/db/src/main/resources/ddl/manage_schemas.xml
   branches/JCA/test-integration/db/src/main/resources/ddl/mysql/create_tables.sql
   branches/JCA/test-integration/db/src/main/resources/default-config.properties
   branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java
Log:
partial merge of HEAD for test-integration due to merge issues

Modified: branches/JCA/test-integration/db/howto
===================================================================
--- branches/JCA/test-integration/db/howto	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/howto	2009-12-01 19:45:17 UTC (rev 1612)
@@ -10,10 +10,7 @@
 ==========================================
 
 -	Unit test should be created under db/src/test/java 
--	See SingleSourceTransactionTest.java as an example 
-
-	NOTE:  the current tests are currently  organized by the number of datasources they require in order
-			to give some organization to the test for tracking purposes.
+-	See LocalTransactionDriverFalseOffTest.java as an example 
 			
 -	Test should extend org.teiid.transaction.test.BaseAbstractTransactionTestCase
 
@@ -22,12 +19,32 @@
 -	when calling: this.getSource("modelname")			--- the "modelname" represents the model for which
 													you want the connection for
 													
-			INFO: to know which source this model is mapped to, find the config properties file being
-					loaded for this test (default is the default-config.properties) and look for
-					the model-to-datasource mapping(s)
-					
-					The default Transaction.vdb has 2 models:  pm1 and pm2
+													
+	By default, the datasource assigned to a model will be (somewhat) random.   There is not coding to 
+	specifically control this assignment, as long as the -Dusedatasources option is not used.
+	
+	If the -Dusedatasources option is used, then there is an implied model-to-datasource assignment.
+			To understand how this assignment will be made, find the config properties file being
+			loaded for this test (default is the default-config.properties) and look for
+			the model-to-order mapping(s)
+			
+			The default Transaction.vdb has 2 models:  pm1 and pm2
+			
+			example:  pm1:1
+					  pm2:2
+					  
+			Therefore, the model-to-order mapping will map to the relative order specified in the usedatasources property.
+			
+			example:  -Dusedatasources=oracle,postgres
+			
+					This will result in model 	pm1 --> oracle
+												pm2 --> postgres
 
+	To EXCLUDE a test from using a specific database type, call addProperty(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP, "postgres");
+	during setup()
+	
+	NOTE:  The EXCLUDE option excludes based on db.type, where "usedatasources" specifies the actual datasource (not by type)
+	
 
 ==========================================
 Setting up a Datasource to be used during Testing
@@ -61,6 +78,10 @@
 			run:	mvn clean install -Dusedatasources=<comma seperated datasource names>
 			Example:  mvn clean install -Dusedatasources=oracle,sqlserver
 			
+			
+	c.	To run a single class of tests, run the "singleclass" profile
+			run:	mvn clean install -Psingleclass -Dclassname=<classname>      ====>  don't add .java to classname
+			
 
 
 

Modified: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -1,75 +1,173 @@
 package org.teiid.test.framework;
 
-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.connection.ConnectionStrategyFactory;
+import org.teiid.test.framework.datasource.DataSourceFactory;
+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.
+ * 
+ * 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 {
-		
-		/**
-		 * The default config file to use when #CONFIG_FILE system property isn't set
-		 */
-		protected static final String DEFAULT_CONFIG_FILE_NAME="default-config.properties";
-		
-		private static Properties props = null;
 
-		public synchronized static void loadConfigurationProperties() {
-	        String filename = System.getProperty(ConfigPropertyNames.CONFIG_FILE);
-	        if (filename == null) {
-	            filename = DEFAULT_CONFIG_FILE_NAME;
-	        }       
-	        
-	        loadProperties(filename);		}
+	/**
+	 * The default config file to use when #CONFIG_FILE system property isn't
+	 * set
+	 */
+	public static final String DEFAULT_CONFIG_FILE_NAME = "default-config.properties";
+	
+	private static ConfigPropertyLoader _instance = null;
+	private static String LAST_CONFIG_FILE = null;
+	
+	/**
+	 * Contains any overrides specified for the test
+	 */
+	private Properties overrides = new Properties();
+
+	/**
+	 * Contains the properties loaded from the config file
+	 */
+	private Properties props = null;
+	
+	private Map<String, String>modelAssignedDatabaseType = new HashMap<String, String>(5);
+	
+	private DataSourceFactory dsfactory = null;
+
+	private ConfigPropertyLoader() {
+	}
+
+	public static synchronized ConfigPropertyLoader getInstance() {
+	    boolean diff = differentConfigProp();
+	    
+
+	    	if (_instance != null && !diff) {
+	    	    return _instance;
+	    	}
+
+	    	if (_instance != null) {
+	    	    cleanup();
+	    	}
+	    	
+		_instance = new ConfigPropertyLoader();
+		try {
+			_instance.initialize();
+		} catch (TransactionRuntimeException e) {
+			throw e;
+		}
+
+		return _instance;
+	}
+	
+	/**
+	 * because a config file could be different for the subsequent test, check
+	 * to see if the file is different.
+	 * @return
+	 */
+	private static boolean differentConfigProp( ) {
+		String filename = System.getProperty(ConfigPropertyNames.CONFIG_FILE);
+		if (filename == null) {
+			filename = DEFAULT_CONFIG_FILE_NAME;
+		}
 		
-		public static String getProperty(String key) {
-			return getProperties().getProperty(key);
+		if (LAST_CONFIG_FILE == null || ! LAST_CONFIG_FILE.equalsIgnoreCase(filename)) {
+		    LAST_CONFIG_FILE = filename;
+		    return true;
 		}
+		return false;
+
+	}
+	
+	public static synchronized void cleanup() {
+	    _instance.overrides.clear();
+	    _instance.modelAssignedDatabaseType.clear();
+	    _instance.props.clear();
+	    if (_instance.dsfactory != null) {
+		_instance.dsfactory.cleanup();
+	    }
+	    _instance = null;
+	    LAST_CONFIG_FILE=null;
+	}
+
+	
+	private void initialize() {
+	    loadProperties(LAST_CONFIG_FILE);
+	    dsfactory = new DataSourceFactory(this);
+	}
+	
+	public DataSourceFactory getDataSourceFactory() {
+	    return this.dsfactory;
+	}
+
+
+	public String getProperty(String key) {
+	    String rtn = null;
+	    rtn = overrides.getProperty(key);
+	    if (rtn == null) {
+		rtn = props.getProperty(key);
 		
-		public synchronized static Properties getProperties() {
-			return props;
+		if (rtn == null) {
+		    rtn = System.getProperty(key);
 		}
+	    }
+	    return rtn;
+	}
+	
+	public void setProperty(String key, String value) {
+	    	overrides.setProperty(key, value);
+	}
+
+	public Properties getProperties() {
 	    
-		private static void loadProperties(String filename) {
-			props = System.getProperties();
-		    try {
-		        InputStream in = ConfigPropertyLoader.class.getResourceAsStream("/"+ filename);
-		        if (in != null) {
-		        	Properties lprops = new Properties();
-		        	lprops.load(in);
-		        	props.putAll(lprops);
-		        	
-		        }
-		        else {
-		        	throw new RuntimeException("Failed to load properties from file '"+filename+ "' configuration file");
-		        }
-		    } catch (IOException e) {
-		        throw new RuntimeException("Error loading properties from file '"+filename+ "'" + e.getMessage());
-		    }
-		}
+	    Properties p = new Properties();
+	    p.putAll(System.getProperties());
+	    p.putAll(props);
+	    p.putAll(overrides);
+	    
+		return p;
+	}
+	
+	public Map<String, String> getModelAssignedDatabaseTypes() {
+		return this.modelAssignedDatabaseType;
+	}
+	
+	public void setModelAssignedToDatabaseType(String modelname, String dbtype) {
+		this.modelAssignedDatabaseType.put(modelname, dbtype);
+	}
+
+	private void loadProperties(String filename) {
 		
-		public static void cleanup() {
-            Properties p = System.getProperties();
-            p.remove(ConfigPropertyNames.CONFIG_FILE);
-            p.remove(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP);
-			
+		props = PropUtils.loadProperties("/" + filename, null);
+
+	}
+
+	public static void main(String[] args) {
+		System.setProperty("test", "value");
+
+		ConfigPropertyLoader _instance = ConfigPropertyLoader.getInstance();
+		Properties p = _instance.getProperties();
+		if (p == null || p.isEmpty()) {
+			throw new RuntimeException("Failed to load config properties file");
+
 		}
-		
-		public static void main(String[] args) {
-			System.setProperty("test", "value");
-			
-			ConfigPropertyLoader.loadConfigurationProperties();
-			Properties p = ConfigPropertyLoader.getProperties();
-			if (p == null || p.isEmpty()) {
-	        	throw new RuntimeException("Failed to load config properties file");
-		
-			}
-			if (p.getProperty("test") == null) {
-				throw new RuntimeException("Failed to pickup system property");
-			}
-			System.out.println("Loaded Config Properties " + p.toString());
+		if (!p.getProperty("test").equalsIgnoreCase("value")) {
+			throw new RuntimeException("Failed to pickup system property");
+		}
+		System.out.println("Loaded Config Properties " + p.toString());
 
-		}
-	
+	}
+
 }

Deleted: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/DataSourceSetup.java
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/DataSourceSetup.java	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/DataSourceSetup.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -1,11 +0,0 @@
-package org.teiid.test.framework;
-
-public interface DataSourceSetup {
-	
-	
-	void setup() throws Exception;
-	
-
-	int getDataSourceCnt();
-	
-}

Modified: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -4,131 +4,155 @@
  */
 package org.teiid.test.framework;
 
-import java.sql.Connection;
 import java.util.Properties;
-import java.util.Set;
 
 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;
 
-public abstract class TransactionContainer {
+    protected ConnectionStrategy connStrategy;
+    protected Properties props;
+
+    protected TransactionContainer() {
+	ConfigPropertyLoader config = ConfigPropertyLoader.getInstance();
 	
-		private boolean debug = false;
-		
-	   protected Properties props;
-	   protected ConnectionStrategy connStrategy;
-	    
-	    protected TransactionContainer(ConnectionStrategy strategy){
-	        this.connStrategy = strategy;
-	        this.props = new Properties();
-	        this.props.putAll(this.connStrategy.getEnvironment());
-	        
+	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) {
+    }
+
+    protected void after(TransactionQueryTestCase test) {
+    }
+
+    public void runTransaction(TransactionQueryTestCase test) {
+
+	this.testClassName = StringUtil.getLastToken(test.getClass().getName(),
+		".");
+
+	try {
+	    detail("Start transaction test: " + test.getTestName());
+
+	    try {
+		test.setConnectionStrategy(connStrategy);
+
+		test.setup();
+
+	    } catch (Throwable e) {
+		if (!test.exceptionExpected()) {
+		    e.printStackTrace();
+		}
+		throw new TransactionRuntimeException(e.getMessage());
 	    }
-	    
-	    
-	    protected Set getDataSources() {
-	    	Set dss = null;
-	    	
-	    	
-	    	return dss;
+
+	    runTest(test);
+
+	    detail("Completed transaction test: " + test.getTestName());
+
+	} finally {
+	    debug("	test.cleanup");
+
+	    try {
+		test.cleanup();
+	    } finally {
+
+		// cleanup all connections created for this test.
+		if (connStrategy != null) {
+		    connStrategy.shutdown();
+		}
 	    }
-	    
-   	    
-	    protected void before(TransactionQueryTest test){}
-	    
-	    protected void after(TransactionQueryTest test) {}
-	        
-	    public void runTransaction(TransactionQueryTest test) {
-	    		    	
-	    	detail("Start transaction test: " + test.getTestName());
+	}
 
-	        try {  
-	        	test.setDataSources(connStrategy.getDataSources());
-	        	test.setupDataSources();
-	        	
-	        	debug("	setConnection");
-	            test.setConnection(getConnection());
-	            test.setExecutionProperties(this.props);
-	            debug("	before(test)");
-	                        
-	            before(test);
-	            debug("	test.before");
+    }
 
-	            test.before();
-	            
-	            debug("	test.testcase");
+    protected void runTest(TransactionQueryTestCase test) {
+	debug("Start runTest: " + test.getTestName());
 
-	            // run the test
-	            test.testCase();
-	            
-	        	debug("	test.after");
+	try {
 
-	            test.after();
-	            debug("	after(test)");
+	    debug("	before(test)");
 
-	            after(test);
-	            
-	            detail("End transaction test: " + test.getTestName());
+	    before(test);
+	    debug("	test.before");
 
-	            
-	        }catch(Throwable e) {
-	        	if (!test.exceptionExpected()) {
-	        		e.printStackTrace();
-	        	}
-	            throw new TransactionRuntimeException(e.getMessage());
-	        }finally {
+	    test.before();
 
-	        }
-	        
-            if (test.exceptionExpected() && !test.exceptionOccurred()) {
-            	throw new TransactionRuntimeException("Expected exception, but one did not occur");
-            }
-	        
-	        try {
-		        detail("Start validation: " + test.getTestName());
+	    debug("	test.testcase");
 
-	        	test.validateTestCase();
-	        	
-	        	detail("End validation: " + test.getTestName());
+	    // run the test
+	    test.testCase();
 
-	        }catch(Exception e) {
-	            throw new TransactionRuntimeException(e);
-	        }
-	        
-            debug("	test.cleanup");
+	    debug("	test.after");
 
-            test.cleanup();
-            
-	    	detail("Completed transaction test: " + test.getTestName());
+	    test.after();
+	    debug("	after(test)");
 
+	    after(test);
 
+	    debug("End runTest: " + test.getTestName());
+
+	} catch (Throwable e) {
+
+	    if (!test.exceptionExpected()) {
+		e.printStackTrace();
+		debug("Error: " + e.getMessage());
+		throw new TransactionRuntimeException(e.getMessage());
+
 	    }
-	    
-	    protected Connection getConnection() throws QueryTestFailedException {
-	    	return this.connStrategy.getConnection();
-	    }	        
-	    
-	    public Properties getEnvironmentProperties() {
-	    	return props;
-	    }
-	    
-	    protected void debug(String message) {
-	    	if (debug) {
-	    		System.out.println(message);
-	    	}
-	    	
-	    }
-	    
-	    protected void detail(String message) {
-	    	System.out.println(message);
-	    }
-	    
+	}
 
-    
+	if (test.exceptionExpected() && !test.exceptionOccurred()) {
+	    throw new TransactionRuntimeException(
+		    "Expected exception, but one did not occur for test: "
+			    + this.getClass().getName() + "."
+			    + test.getTestName());
+	}
 
+    }
+
+
+    protected void debug(String message) {
+	if (debug) {
+	    System.out.println("[" + this.testClassName + "] " + message);
+	}
+
+    }
+
+    protected void detail(String message) {
+	System.out.println("[" + this.testClassName + "] " + message);
+    }
+
+    protected boolean done() {
+	return true;
+    }
+
 }

Copied: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTestCase.java (from rev 1610, trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTestCase.java)
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTestCase.java	                        (rev 0)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTestCase.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -0,0 +1,207 @@
+package org.teiid.test.framework;
+
+import java.sql.Connection;
+import java.util.Properties;
+
+import javax.sql.XAConnection;
+
+import org.teiid.test.framework.connection.ConnectionStrategy;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+/**
+ * The TransactionQueryTest interface represents the transaction test lifecycle of execution
+ * from which the @link TransactionContainer operates.
+ * <br><br>
+ * QueryTest lifecycle:</br>
+ * 
+ * <br>
+ * There are 4 phases or groupings of methods:
+ * <li>Setup </li> 
+ * <li>Test </li>
+ * <li>Validation</li> 
+ * <li>Cleanup</li>
+ * 
+ * <br>
+ * <p>
+ * <b>1. Setup phase is about setting the global environment for the testing</b>
+ * <br>
+ * 
+ * <li>{@link #setConnectionStrategy(ConnectionStrategy)} - called first to provide
+ * the environment (i.e, type of connection, parameters, etc) that the test will
+ * be run under. 
+ * <li>{@link #hasRequiredDataSources()} - called after the connection
+ * strategy is set so the determination can be made if this test has the
+ * required datasources defined and available in order to run the test. If not,
+ * then the test is bypassed. 
+ * <li>{@link #setup()} - called to enable the test to
+ * perform any pretest (i.e., global) setup. Example would be data source setup.
+ * <li>{@link #setConnection(Connection)} - called to set the client driver (i.e.,
+ * Teiid) connection that will be used to execute queries against
+ * <li>{@link #setExecutionProperties(Properties)} - called at this time so that the
+ * overriding class can obtain / initialize settings that will be assigned when
+ * <li>{@link AbstractQueryTest#assignExecutionProperties(Statement)} is called
+ * prior to sql execution. (Example: set fetch size, batch time, or timeout)
+ * </li>
+ * <br>
+ * <p>
+ * <b>2. Test phase are the methods for executing a test, including any
+ * before/after test logic to support the test</b>
+ * <br><br>
+ * 
+ * <li>{@link #before()} called before the execution of the test so that the
+ * transaction boundary can be set and any other pretest conditions
+ * <li>{@link #testCase()} called to execute the specific test 
+ * <li>{@link #after()} called after the test is executed, which will commit/rollback the transaction
+ * and perform any other post conditions
+ * </li>
+ * <br>
+ * <p>
+ * <b>3. Validation phase is meant to enable data validation post transaction
+ * completion. This is especially helpful when performing XA transactions
+ * because the results are not completed and available until after the {@link #after()} step
+ * is performed.</b>
+ *  <br><br>
+ * 
+ * {@link #validateTestCase()}
+ * 
+ * <p>
+ * <b>4. Cleanup</b>
+ * <br><br> 
+ * 
+ * {@link #cleanup()} Called to allow the testcase to perform any cleanup after execution.
+ * 
+ * <br>
+ * ================
+ * <p>
+ * <b>Other Notes:</b>
+ * <br><br>
+ * 
+ * The following methods were exposed from {@link AbstractQueryTest}:
+ * 
+ * <li>{@link #exceptionExpected()} - when an exception is expected to occur, the
+ * underlying logic will treat the execution as if it succeeded. </li>
+ * <li>{@link #exceptionOccurred()} - this method indicates when an exception
+ * actually occurred outside of the normal expected results. </li>
+ * <li>{@link #getConnection()} and {@link #getXAConnection()} - these connection
+ * methods are exposed for {@link #before()} and {@link #after()} methods</li>
+ * <li>{@link #rollbackAllways()} - this is exposed for the {@link #after()} method
+ * as to what behavior is expected after the execution of the test</li>
+ * 
+ * 
+ * <br>
+ * @author vanhalbert
+ * 
+ */
+
+public interface TransactionQueryTestCase {
+
+    /**
+     * Returns the name of the test so that better tracing of what tests are
+     * running/completing.
+     * 
+     * @return String is test name
+     */
+    String getTestName();
+
+    /**
+     * Called to set the current connection strategy being used.
+     * 
+     * @param connStrategy
+     * 
+     * @since
+     */
+    void setConnectionStrategy(ConnectionStrategy connStrategy)  throws QueryTestFailedException;
+
+    /**
+     * Called by the {@link TransactionContainer} prior to testcase processing
+     * so that the responsibility for performing an setup duties (ie..,
+     * datasource setup) can be done
+     * 
+     * 
+     * @since
+     */
+    void setup() throws QueryTestFailedException;
+
+    /**
+     * Called by the @link TransactionContainer to set the Teiid connection to
+     * be used in the test.
+     * 
+     * @param conn
+     * 
+     * @since
+     */
+    void setConnection(Connection conn);
+
+    /**
+     * Called to set the properties used to initialize prior to execution.
+     * 
+     * @param props
+     * 
+     * @since
+     */
+//    void setExecutionProperties(Properties props);
+
+    /**
+     * Override <code>before</code> if there is behavior that needs to be
+     * performed prior to {@link #testCase()} being called.
+     * 
+     * 
+     * @since
+     */
+    void before();
+
+    /**
+     * Implement testCase(), it is the entry point to the execution of the test.
+     * 
+     * @throws Exception
+     * 
+     * @since
+     */
+    void testCase() throws Exception;
+
+    /**
+     * Override <code>after</code> if there is behavior that needs to be
+     * performed after {@link #testCase()} being called.
+     * 
+     * 
+     * @since
+     */
+    void after();
+
+    /**
+     * Indicates what should be done when a failure occurs in
+     * {@link #testCase()}
+     * 
+     * @return
+     * 
+     * @since
+     */
+    boolean rollbackAllways();
+
+    /**
+     * Called at the end of the test so that the testcase can clean itself up by
+     * releasing any resources, closing any open connections, etc.
+     * 
+     * 
+     * @since
+     */
+    void cleanup();
+
+    /**
+     * Returns the connection being used in the test.
+     * 
+     * @return
+     * 
+     * @since
+     */
+    Connection getConnection();
+
+    XAConnection getXAConnection();
+
+    boolean exceptionExpected();
+
+    boolean exceptionOccurred();
+
+}

Modified: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -9,9 +9,7 @@
 import java.lang.reflect.Method;
 import java.sql.Connection;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.Iterator;
-import java.util.Map;
 import java.util.Properties;
 
 import javax.sql.XAConnection;
@@ -20,37 +18,28 @@
 import org.teiid.adminapi.AdminOptions;
 import org.teiid.adminapi.Model;
 import org.teiid.adminapi.VDB;
+import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
 import org.teiid.test.framework.datasource.DataSource;
+import org.teiid.test.framework.datasource.DataSourceFactory;
 import org.teiid.test.framework.datasource.DataSourceMgr;
 import org.teiid.test.framework.exception.QueryTestFailedException;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
 
-import com.metamatrix.jdbc.api.ExecutionProperties;
+import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.jdbc.util.MMJDBCURL;
 
 
-
 public abstract class ConnectionStrategy {
+     
     
-     public static final String JNDINAME_USERTXN = "usertxn-jndiname"; //$NON-NLS-1$  
-	
-	public static final String PROCESS_BATCH = "process-batch"; //$NON-NLS-1$
-	public static final String CONNECTOR_BATCH = "connector-batch"; //$NON-NLS-1$
-
-    public static final String AUTOCOMMIT = "autocommit"; //$NON-NLS-1$
+    private Properties env = null;
+    private DataSourceFactory dsFactory;
     
-    public static final String TXN_AUTO_WRAP = ExecutionProperties.PROP_TXN_AUTO_WRAP;
-    
-    public static final String FETCH_SIZE = ExecutionProperties.PROP_FETCH_SIZE;
-    
-    public static final String EXEC_IN_BATCH = "execute.in.batch"; //$NON-NLS-1$
-    
-    
-    private Map<String, DataSource> datasources = null;
 
-    
-    public ConnectionStrategy(Properties props) throws QueryTestFailedException {
-    	this.env = props;
-   	
+    public ConnectionStrategy(Properties props, DataSourceFactory dsf) {
+	this.env = PropertiesUtils.clone(props);
+	
+	this.dsFactory = dsf;
     }
     
     /*
@@ -63,6 +52,13 @@
      */
     public abstract Connection getConnection() throws QueryTestFailedException;
     
+    /**
+     * @since
+     */
+    public void shutdown() {    
+
+    }
+    
     public Connection getAdminConnection() throws QueryTestFailedException{
     	return null;
     }
@@ -72,24 +68,19 @@
     	return autoCommit;
     }
 
-    public abstract void shutdown();
     
     public XAConnection getXAConnection() throws QueryTestFailedException {
         return null;
     }
     
+
     
-    private Properties env = null;
     
-    
     public Properties getEnvironment() {
     	return env;
     }
     
-    public Map<String, DataSource> getDataSources() {
-    	return this.datasources;
-    }
-    
+   
     class CloseInterceptor implements InvocationHandler {
 
         Connection conn;
@@ -112,9 +103,7 @@
    
     void configure() throws QueryTestFailedException  {
     	
-    	datasources = new HashMap<String, DataSource>(3);
-    	
-    	String ac = this.env.getProperty(AUTOCOMMIT, "true");
+    	String ac = this.env.getProperty(CONNECTION_STRATEGY_PROPS.AUTOCOMMIT, "true");
     	this.autoCommit = Boolean.getBoolean(ac);
     	
         com.metamatrix.jdbc.api.Connection c =null;
@@ -130,32 +119,25 @@
         	}
             
             Admin admin = (Admin)c.getAdminAPI();
-        
-//            Properties p = new Properties();
-//            if (this.env.getProperty(PROCESS_BATCH) != null) {
-//                p.setProperty("metamatrix.buffer.processorBatchSize", this.env.getProperty(PROCESS_BATCH)); //$NON-NLS-1$
-//            }
-//            
-//            if (this.env.getProperty(CONNECTOR_BATCH) != null) {
-//                p.setProperty("metamatrix.buffer.connectorBatchSize", this.env.getProperty(CONNECTOR_BATCH)); //$NON-NLS-1$
-//            }
             
             setupVDBConnectorBindings(admin);
             
-            admin.restart();
+            
+ //          admin.restart();
+            
+            int sleep = 5;
  
-            System.out.println("Bouncing the system..(wait 15 seconds)"); //$NON-NLS-1$
-            Thread.sleep(1000*15);
-        //    Thread.sleep(1000*60);
+            System.out.println("Bouncing the system..(wait " + sleep + " seconds)"); //$NON-NLS-1$
+            Thread.sleep(1000*sleep);
             System.out.println("done."); //$NON-NLS-1$
 
-        } catch (Exception e) {
+        } catch (Throwable e) {
         	e.printStackTrace();
 
-            throw new TransactionRuntimeException(e);
+            throw new TransactionRuntimeException(e.getMessage());
         }  finally {
         	// need to close and flush the connection after restarting
-        	this.shutdown();
+      //  	this.shutdown();
            	
         }
     }    
@@ -163,48 +145,74 @@
     protected void setupVDBConnectorBindings(Admin api) throws QueryTestFailedException {
          
     	try {
+    	    
+    	    VDB vdb = null;
+	    Collection<VDB> vdbs = api.getVDBs("*");
+	    if (vdbs == null || vdbs.isEmpty()) {
+		throw new QueryTestFailedException(
+			"AdminApi.GetVDBS returned no vdbs available");
+	    }
 
-    		Collection<VDB> vdbs = api.getVDBs("*");
-    		if (vdbs == null) {
-    	  		throw new QueryTestFailedException("GetVDBS returned no vdbs available");
-    	  		 
-    		} else if (vdbs.size() != 1) {
-    			throw new QueryTestFailedException("GetVDBS returned more than 1 vdb available");
-    		}
-    		VDB vdb = (VDB) vdbs.iterator().next();
-    		Iterator<Model> modelIt = vdb.getModels().iterator();
-    		while (modelIt.hasNext() ) {
-    			Model m = modelIt.next();
-    			
-    			if (!m.isPhysical()) continue;
-    			
-    			// get the mapping, if defined
-    			String mappedName = this.env.getProperty(m.getName());
-    			
-	        	String useName = m.getName();
-	        	if(mappedName != null) {
-	        		useName = mappedName;
-	        	}
+	    String urlString = this.env.getProperty(DriverConnection.DS_URL);
+	    MMJDBCURL url = new MMJDBCURL(urlString);
+	    System.out.println("Trying to match VDB : " + url.getVDBName());
 
-	        	org.teiid.test.framework.datasource.DataSource ds = DataSourceMgr.getInstance().getDatasource(useName, m.getName());
-	        	
-	        	if (ds != null) {
-		        	datasources.put(m.getName(), ds);
+	    for (Iterator iterator = vdbs.iterator(); iterator.hasNext();) {
+		VDB v = (VDB) iterator.next();
+		if (v.getName().equalsIgnoreCase(url.getVDBName())) {
+		    vdb = v;
+		}
 
-	                System.out.println("Set up Connector Binding (model:mapping:type): " + m.getName() + ":" + useName + ":"  + ds.getConnectorType()); //$NON-NLS-1$
+	    }
+	    if (vdbs == null) {
+		throw new QueryTestFailedException(
+			"GetVDBS did not return a vdb that matched "
+				+ url.getVDBName());
+	    }
+	    	    
+	    Iterator<Model> modelIt = vdb.getModels().iterator();
+	    while (modelIt.hasNext()) {
+		Model m = modelIt.next();
 
-		        	AdminOptions ao = new AdminOptions(AdminOptions.OnConflict.OVERWRITE);
-		        	ao.addOption(AdminOptions.BINDINGS_IGNORE_DECRYPT_ERROR);
-		        	
-		        	api.addConnectorBinding(ds.getName(), ds.getConnectorType(), ds.getProperties(), ao);
-		        	
-		        	api.assignBindingToModel(ds.getName(), vdb.getName(), vdb.getVDBVersion(), m.getName());
-		        	
-	        	} else {
-	        		throw new QueryTestFailedException("Error: Unable to create binding to map to model : " + m.getName() + ", the mapped name " + useName + " had no datasource properties defined");
-	        	}
+		if (!m.isPhysical())
+		    continue;
 
-    		}
+		// get the mapping, if defined
+		String mappedName = this.env.getProperty(m.getName());
+
+		String useName = m.getName();
+		if (mappedName != null) {
+		    useName = mappedName;
+		}
+
+		org.teiid.test.framework.datasource.DataSource ds = this.dsFactory
+			.getDatasource(useName, m.getName());
+
+		if (ds != null) {
+
+		    System.out
+			    .println("Set up Connector Binding (model:mapping:type): " + m.getName() + ":" + useName + ":" + ds.getConnectorType()); //$NON-NLS-1$
+
+		    AdminOptions ao = new AdminOptions(
+			    AdminOptions.OnConflict.OVERWRITE);
+		    ao.addOption(AdminOptions.BINDINGS_IGNORE_DECRYPT_ERROR);
+
+		    api.addConnectorBinding(ds.getName(),
+			    ds.getConnectorType(), ds.getProperties(), ao);
+
+		    api.assignBindingToModel(ds.getName(), vdb.getName(), vdb
+			    .getVDBVersion(), m.getName());
+
+		    api.startConnectorBinding(ds.getName());
+		} else {
+		    throw new QueryTestFailedException(
+			    "Error: Unable to create binding to map to model : "
+				    + m.getName() + ", the mapped name "
+				    + useName
+				    + " had no datasource properties defined");
+		}
+
+	    }
     		
     	} catch (QueryTestFailedException qt) {
     		throw qt;
@@ -215,7 +223,65 @@
 
     	
     }
-        
+    
+    public synchronized Connection createDriverConnection(String identifier) throws QueryTestFailedException  {
+
+	DataSource ds = null;
+	if (identifier != null) {
+	    ds = DataSourceMgr.getInstance().getDataSource(identifier);
+	}
+	if (ds == null) {
+	    	throw new TransactionRuntimeException(
+			"Program Error: DataSource is not mapped to Identifier " + identifier);
+	}
+	
+	Connection conn = ds.getConnection();
+	
+	if (conn != null) return conn;
+	
+	ConnectionStrategy cs = null;
+	if (identifier == null) {
+	    cs = new DriverConnection(ds.getProperties(), this.dsFactory);
+ 		
+ 	} else {
+ 	    cs = new DriverConnection(ds.getProperties(), this.dsFactory);
+ 	}
+	
+	ds.setConnection(cs);
+	
+	return ds.getConnection();
  
-   
+	
+    }
+
+    
+    public synchronized XAConnection createDataSourceConnection(String identifier) throws QueryTestFailedException  {	     	
+	
+	DataSource ds = null;
+	if (identifier != null) {
+	    ds = DataSourceMgr.getInstance().getDataSource(identifier);
+	}
+	if (ds == null) {
+	    	throw new TransactionRuntimeException(
+			"Program Error: DataSource is not mapped to Identifier " + identifier);
+	}
+	
+	XAConnection conn = ds.getXAConnection();
+	
+	if (conn != null) return conn;
+	
+	ConnectionStrategy cs = null;
+	if (identifier == null) {
+	    cs = new DriverConnection(ds.getProperties(), this.dsFactory);
+	} else {
+	    cs = new DriverConnection(ds.getProperties(), this.dsFactory);
+	}
+	
+	ds.setXAConnection(cs);
+	
+	return ds.getXAConnection();
+	
+
+    }
+    
 }

Modified: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -4,102 +4,27 @@
  */
 package org.teiid.test.framework.connection;
 
-import java.util.HashMap;
-import java.util.Iterator;
-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.datasource.DataSourceFactory;
 import org.teiid.test.framework.exception.QueryTestFailedException;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
 
+/**
+ * The ConnectionStrategyFactory is responsible for creating a connection strategy that is to be used to provide the type of 
+ * connection.
+ * @author vanhalbert
+ *
+ */
 public class ConnectionStrategyFactory {
 	
-	    private static ConnectionStrategyFactory _instance = null;
-	    /**
-	     *  this strategy represents the connection strategy used to connect to Teiid
-	     *  and is based on the properties loaded by the {@link ConfigPropertyLoader}
-	     */
-	    private ConnectionStrategy strategy = null;
-	    private Map<String, ConnectionStrategy> driversources = null;
-	    private Map<String, ConnectionStrategy> datasourcesources = null;
-	    private Map<String, ConnectionStrategy> jeesources = null;
-
-   	    
-	    private ConnectionStrategyFactory(){
-	    }
-	    
-	    public static synchronized ConnectionStrategyFactory getInstance()   {
-	        if (_instance == null) {
-	            _instance = new ConnectionStrategyFactory();
-	        }
-	        return _instance;
-	    }
-	        
     
-	    public static synchronized void destroyInstance() {
-	        if (_instance != null) {
-	        	_instance.shutdown();
-	        	
-	            _instance = null;
-	        }
-	    }    
-	    
-	    private void shutdown() {
-	    	ConfigPropertyLoader.cleanup();
-            
-            if (driversources != null) {
-            	shutDownSources(driversources);
-            	driversources = null;
-            }
-            
-            if (datasourcesources != null) {
-            	shutDownSources(datasourcesources);
-            	datasourcesources = null;
-            }
-            
-            if (jeesources != null) {
-            	shutDownSources(jeesources);
-            	jeesources = null;
-            }
-        	
-        	try {
-        		strategy.shutdown();
-        	} catch (Exception e) {
-        		
-        	} finally {
-        		strategy = null;
-        	}
- 
-	    }
-	    
-	    private void shutDownSources(Map<String, ConnectionStrategy> sources) {
-	       	for (Iterator it=sources.keySet().iterator(); it.hasNext();  ){	        		
-	        		ConnectionStrategy cs = sources.get(it.next());
-	        		try {
-	        			cs.shutdown();
-	        		} catch (Exception e) {
-	        			
-	        		}
-	        		
-	        	}
-	        	sources.clear();
-	
-	    }
-	    
-	    public synchronized ConnectionStrategy getConnectionStrategy() throws QueryTestFailedException {
-	    	if (strategy == null) {
-	    		this.strategy = create(ConfigPropertyLoader.getProperties());
-	    	}
-	    	return this.strategy;
-	    }
-	    
-	        
-	    private ConnectionStrategy create(Properties props) throws QueryTestFailedException  {
-	    	
+	    public static ConnectionStrategy createConnectionStrategy(ConfigPropertyLoader configprops) throws QueryTestFailedException {
 	     	ConnectionStrategy strategy = null;
-	                
+	     	Properties props = configprops.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");
@@ -107,15 +32,15 @@
 	        
 	        if (type.equalsIgnoreCase(ConfigPropertyNames.CONNECTION_TYPES.DRIVER_CONNECTION)) {
 	        	// pass in null to create new strategy
-	                strategy = createDriverStrategy(null, props);
+	                strategy = new DriverConnection(props, configprops.getDataSourceFactory());
 	                System.out.println("Created Driver Strategy");
 	        }
 	        else if (type.equalsIgnoreCase(ConfigPropertyNames.CONNECTION_TYPES.DATASOURCE_CONNECTION)) {
-	            strategy = createDataSourceStrategy(null, props);
+	            strategy = new DataSourceConnection(props, configprops.getDataSourceFactory());
 	            System.out.println("Created DataSource Strategy");
 	        }
 	        else if (type.equalsIgnoreCase(ConfigPropertyNames.CONNECTION_TYPES.JNDI_CONNECTION)) {
-	            strategy = createJEEStrategy(null, props);
+	            strategy = new JEEConnection(props, configprops.getDataSourceFactory());
 	            System.out.println("Created JEE Strategy");
 	        }   
 	        
@@ -126,75 +51,16 @@
 	        // direct connections to the datasource use the static call directly to create strategy and don't need to configure
 	    	strategy.configure();
 	        return strategy;
-	    }
+
+	    }	    
 	    
-	    public synchronized ConnectionStrategy createDriverStrategy(String identifier, Properties props) throws QueryTestFailedException  {
-	    	if (driversources == null) {
-	    		driversources = new HashMap<String, ConnectionStrategy>();
-	    	}
-	    	
-	     	if (identifier == null) {
-	     			return new DriverConnection(props);
-	     	}
-	     	
-	     	ConnectionStrategy strategy = null;
-	     	if (driversources.containsKey(identifier)) {
-	     		strategy = driversources.get(identifier);
-	     	} else {
-	     		strategy = new DriverConnection(props);
-	     		driversources.put(identifier, strategy);
-	     	}	     	
-       	
-	       	return strategy;
-	    
-	    }
-	    
-	    public synchronized ConnectionStrategy createDataSourceStrategy(String identifier, Properties props) throws QueryTestFailedException  {	     	
-	    	if (datasourcesources == null) {
-	    		datasourcesources = new HashMap<String, ConnectionStrategy>();
-	    	}
-	    	
-	     	if (identifier == null) {
-	    		return new DataSourceConnection(props);
-	     	}
-	     	
-	     	ConnectionStrategy strategy = null;
-	     	if (datasourcesources.containsKey(identifier)) {
-	     		strategy = datasourcesources.get(identifier);
-	     	} else {
-	     		strategy = new DataSourceConnection(props);
-	     		datasourcesources.put(identifier, strategy);
-	     	}
-	       	
-	       	return strategy;
-	    
-	    }
-	    
-	    public synchronized ConnectionStrategy createJEEStrategy(String identifier, Properties props) throws QueryTestFailedException  {
-	    	if (jeesources == null) {
-	    		jeesources = new HashMap<String, ConnectionStrategy>();
-	    	}
-	    	
-	     	if (identifier == null) {
-	    		return new JEEConnection(props);
-	     	}
-	     	
-	     	ConnectionStrategy strategy = null;
-	     	if (jeesources.containsKey(identifier)) {
-	     		strategy = jeesources.get(identifier);
-	     	} else {
-	     		strategy = new JEEConnection(props);
-	     		jeesources.put(identifier, strategy);
-	     	}
-	       	
-	       	return strategy;
-	    
-	    }
-	    
-		
 		public static void main(String[] args) {
-			ConnectionStrategyFactory cf = ConnectionStrategyFactory.getInstance();
+			//NOTE: to run this test to validate the DataSourceMgr, do the following:
+			//   ---  need 3 datasources,   Oracle, SqlServer and 1 other
+			
+			ConfigPropertyLoader config = ConfigPropertyLoader.getInstance();
+			
+			new DataSourceFactory(config);
 
 		}
-	        
 }

Modified: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -13,6 +13,7 @@
 
 import org.teiid.connector.jdbc.JDBCPropertyNames;
 import org.teiid.jdbc.TeiidDataSource;
+import org.teiid.test.framework.datasource.DataSourceFactory;
 import org.teiid.test.framework.exception.QueryTestFailedException;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
 
@@ -20,134 +21,137 @@
 import com.metamatrix.jdbc.EmbeddedDataSource;
 
 public class DataSourceConnection extends ConnectionStrategy {
-	
-	   public static final String DS_USER = "user"; //$NON-NLS-1$
-	    
-	    // need both user variables because Teiid uses 'user' and connectors use 'username'
-	    public static final String DS_USERNAME = JDBCPropertyNames.USERNAME; //$NON-NLS-1$
-	    public static final String DS_PASSWORD = JDBCPropertyNames.PASSWORD;     //$NON-NLS-1$
-	    
-	    // the driver is only used for making direct connections to the source, the 
-	    // 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_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 JNDINAME_USERTXN = "usertxn-jndiname"; //$NON-NLS-1$
-	    
 
+    public static final String DS_USER = "user"; //$NON-NLS-1$
 
-	private String driver = null;
-	private String username = null;
-	private String pwd = null;
-	private String applName = null;
-	private String databaseName = null;
-	private String serverName = null;
-	private String portNumber = null;
-	
-	
-    private XAConnection xaConnection;    
- 
-   public DataSourceConnection(Properties props) throws QueryTestFailedException {
-	   super(props);
-   }
+    // need both user variables because Teiid uses 'user' and connectors use
+    // 'username'
+    public static final String DS_USERNAME = JDBCPropertyNames.USERNAME; //$NON-NLS-1$
+    public static final String DS_PASSWORD = JDBCPropertyNames.PASSWORD; //$NON-NLS-1$
 
-   
+    // the driver is only used for making direct connections to the source, the
+    // connector type will provide the JDBCPropertyNames.CONNECTION_SOURCE
+    // driver class
+    public static final String DS_DRIVER = "driver"; //$NON-NLS-1$
 
-	public void validate()  {
-	   	databaseName = this.getEnvironment().getProperty(DS_DATABASENAME);
-   	if (databaseName == null || databaseName.length() == 0) {
-   		throw new TransactionRuntimeException("Property " + DS_DATABASENAME + " was not specified");
-   	}
-   	
-	   	serverName = this.getEnvironment().getProperty(DS_SERVERNAME);
-   	if (serverName == null || serverName.length() == 0) {
-   		throw new TransactionRuntimeException("Property " + DS_SERVERNAME + " was not specified");
-   	}
+    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$
 
-   	
-   	this.portNumber = this.getEnvironment().getProperty(DS_SERVERPORT);
-       
-       this.applName = this.getEnvironment().getProperty(DS_APPLICATION_NAME);
-       
-       driver = this.getEnvironment().getProperty(DS_DRIVER);
-   	if (driver == null || driver.length() == 0) {
-   		throw new TransactionRuntimeException("Property " + DS_DRIVER + " was not specified");
-   	}
-   	
-   	this.username = this.getEnvironment().getProperty(DS_USER);
-   	this.pwd = this.getEnvironment().getProperty(DS_PASSWORD);
-      	
+    private String driver = null;
+    private String username = null;
+    private String pwd = null;
+    private String applName = null;
+    private String databaseName = null;
+    private String serverName = null;
+    private String portNumber = null;
+
+    private XAConnection xaConnection;
+
+    public DataSourceConnection(Properties props,
+	    DataSourceFactory dsf) throws QueryTestFailedException {
+	super(props, dsf);
+    }
+
+    public void validate() {
+	databaseName = this.getEnvironment().getProperty(DS_DATABASENAME);
+	if (databaseName == null || databaseName.length() == 0) {
+	    throw new TransactionRuntimeException("Property " + DS_DATABASENAME
+		    + " was not specified");
 	}
 
-	public Connection getConnection() throws QueryTestFailedException {
-       try {
-           return getXAConnection().getConnection();
-       } catch (QueryTestFailedException qtf) {
-    	   throw qtf;
-       } catch (Exception e) {
-    	   e.printStackTrace();
-           throw new QueryTestFailedException(e);
-       }
-   }
-   
-   public synchronized XAConnection getXAConnection() throws QueryTestFailedException {
-       if (xaConnection == null) {
-       	  validate();
-           try {
-               xaConnection = createConnection();
-           } catch (Exception e) {
-               throw new QueryTestFailedException(e);
-           }
-       }
-       return xaConnection;
-   }    
+	serverName = this.getEnvironment().getProperty(DS_SERVERNAME);
+	if (serverName == null || serverName.length() == 0) {
+	    throw new TransactionRuntimeException("Property " + DS_SERVERNAME
+		    + " was not specified");
+	}
 
-   private XAConnection createConnection() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException {
-       System.out.println("Creating Datasource Connection: \"" + this.serverName + " - " + this.databaseName + "\""); //$NON-NLS-1$ //$NON-NLS-2$
+	this.portNumber = this.getEnvironment().getProperty(DS_SERVERPORT);
 
-	   
-	   BaseDataSource dataSource = (BaseDataSource)Class.forName(this.driver).newInstance();
+	this.applName = this.getEnvironment().getProperty(DS_APPLICATION_NAME);
 
-       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));            
-       }
-       
-       dataSource.setUser("admin");
-       dataSource.setPassword("teiid");
-       
-//       if (this.username != null) {
-//       	dataSource.setUser(this.username);
-//       	dataSource.setPassword(this.pwd);
-//       }
-	    	   
-       
-       return ((XADataSource)dataSource).getXAConnection();
-   }  
+	this.driver = this.getEnvironment().getProperty(DS_DRIVER);
+	if (this.driver == null || this.driver.length() == 0) {
+	    throw new TransactionRuntimeException("Property " + DS_DRIVER
+		    + " was not specified");
+	}
 
-   public void shutdown() {
-       try {
+	this.username = this.getEnvironment().getProperty(DS_USER);
+	if (username == null) {
+	    this.username = this.getEnvironment().getProperty(DS_USERNAME);
+	}
+	this.pwd = this.getEnvironment().getProperty(DS_PASSWORD);
 
+    }
 
-           if (this.xaConnection != null) {
-               this.xaConnection.close();
-           }
-       } catch (SQLException e) {
-           // ignore..
-       }
-       
-       this.xaConnection = null;
-   }
+    public Connection getConnection() throws QueryTestFailedException {
+	try {
+	    return getXAConnection().getConnection();
+	} catch (QueryTestFailedException qtf) {
+	    throw qtf;
+	} catch (Exception e) {
+	    e.printStackTrace();
+	    throw new QueryTestFailedException(e);
+	}
+    }
+
+    public synchronized XAConnection getXAConnection()
+	    throws QueryTestFailedException {
+	if (xaConnection == null) {
+	    validate();
+	    try {
+		xaConnection = createConnection();
+	    } catch (Exception e) {
+		throw new QueryTestFailedException(e);
+	    }
+	}
+	return xaConnection;
+    }
+
+    private XAConnection createConnection() throws SQLException,
+	    InstantiationException, IllegalAccessException,
+	    ClassNotFoundException {
+	System.out
+		.println("Creating Datasource Connection: \"" + this.serverName + " - " + this.databaseName + "\""); //$NON-NLS-1$ //$NON-NLS-2$
+
+	BaseDataSource dataSource = (BaseDataSource) 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);
+    }
+
+    public void shutdown() {
+	super.shutdown();
+	try {
+
+	    if (this.xaConnection != null) {
+		this.xaConnection.close();
+	    }
+	} catch (SQLException e) {
+	    // ignore..
+	}
+
+	this.xaConnection = null;
+    }
 }

Modified: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -10,135 +10,139 @@
 import java.util.Properties;
 
 import org.teiid.connector.jdbc.JDBCPropertyNames;
+import org.teiid.test.framework.datasource.DataSourceFactory;
 import org.teiid.test.framework.exception.QueryTestFailedException;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
 
-import com.metamatrix.jdbc.api.ExecutionProperties;
+/**
+ * The DriverConnection strategy that can get connections in standalone mode or
+ * embedded mode.
+ */
+public class DriverConnection extends ConnectionStrategy {
 
+    public static final String DS_USER = "user"; //$NON-NLS-1$
 
+    // need both user variables because Teiid uses 'user' and connectors use
+    // 'username'
+    public static final String DS_USERNAME = JDBCPropertyNames.USERNAME; //$NON-NLS-1$
+    public static final String DS_PASSWORD = JDBCPropertyNames.PASSWORD; //$NON-NLS-1$
 
-/** 
- * The DriverConnection strategy that can get connections in standalone mode
- * or embedded mode. 
- */
-public class DriverConnection extends ConnectionStrategy{
-	
-	   public static final String DS_USER = "user"; //$NON-NLS-1$
-	    
-	    // need both user variables because Teiid uses 'user' and connectors use 'username'
-	    public static final String DS_USERNAME = JDBCPropertyNames.USERNAME; //$NON-NLS-1$
-	    public static final String DS_PASSWORD = JDBCPropertyNames.PASSWORD;     //$NON-NLS-1$
-	    
-	    // the driver is only used for making direct connections to the source, the 
-	    // 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_URL = JDBCPropertyNames.URL;     //$NON-NLS-1$
-	    public static final String DS_APPLICATION_NAME = "application-name"; //$NON-NLS-1$
-	    
-     
+    // the driver is only used for making direct connections to the source, the
+    // 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_URL = JDBCPropertyNames.URL; //$NON-NLS-1$
+    public static final String DS_APPLICATION_NAME = "application-name"; //$NON-NLS-1$
+
     private String url = null;
     private String driver = null;
     private String username = null;
     private String pwd = null;
-    
+
     private Connection connection;
 
-        
-    public DriverConnection(Properties props) throws QueryTestFailedException {
-    	   super(props);
-    	   validate();
+
+    public DriverConnection(Properties props,
+	    DataSourceFactory dsf) throws QueryTestFailedException {
+	super(props, dsf);
+	validate();
     }
-    
-	public void validate()  {
 
-    	String urlProp = this.getEnvironment().getProperty(DS_URL);
-    	if (urlProp == null || urlProp.length() == 0) {
-    		throw new TransactionRuntimeException("Property " + DS_URL + " was not specified");
-    	}
-       StringBuffer urlSB = new StringBuffer(urlProp);
-        
-       String appl = this.getEnvironment().getProperty(DS_APPLICATION_NAME);
-        if (appl != null) {
-            urlSB.append(";");
-            urlSB.append("ApplicationName").append("=").append(appl);
-        }
-        
-        url = urlSB.toString();
-        
-        driver = this.getEnvironment().getProperty(DS_DRIVER);
-    	if (driver == null || driver.length() == 0) {
-    		throw new TransactionRuntimeException("Property " + DS_DRIVER + " was not specified");
-    	}
-    	
-    	   // need both user variables because Teiid uses 'user' and connectors use 'username'
+    public void validate() {
 
-    	this.username = this.getEnvironment().getProperty(DS_USER);
-    	if (username == null) {
-    		this.username = this.getEnvironment().getProperty(DS_USERNAME);
-    	}
-    	this.pwd = this.getEnvironment().getProperty(DS_PASSWORD);
-    	
-        try {
-            // Load jdbc driver
-            Class.forName(driver);
-        } catch (ClassNotFoundException e) {
-        	throw new TransactionRuntimeException(e);
-        }
-       	
+	String urlProp = this.getEnvironment().getProperty(DS_URL);
+	if (urlProp == null || urlProp.length() == 0) {
+	    throw new TransactionRuntimeException("Property " + DS_URL
+		    + " was not specified");
 	}
+	StringBuffer urlSB = new StringBuffer(urlProp);
 
-	public synchronized Connection getConnection() throws QueryTestFailedException {
-        if (this.connection != null) {
-        	try {
-				if (!this.connection.isClosed()) {
-					return this.connection;
-				}
-			} catch (SQLException e) {
+	String appl = this.getEnvironment().getProperty(DS_APPLICATION_NAME);
+	if (appl != null) {
+	    urlSB.append(";");
+	    urlSB.append("ApplicationName").append("=").append(appl);
+	}
 
-			}
-        	
-        }
-		
-        this.connection = getJDBCConnection(this.driver, this.url, this.username, this.pwd); 
-        return this.connection;
-    }    
-   
-    
-    private Connection getJDBCConnection(String driver, String url, String user, String passwd) throws QueryTestFailedException {
+	url = urlSB.toString();
 
-        System.out.println("Creating Driver Connection: \"" + url + "\""); //$NON-NLS-1$ //$NON-NLS-2$
+	driver = this.getEnvironment().getProperty(DS_DRIVER);
+	if (driver == null || driver.length() == 0) {
+	    throw new TransactionRuntimeException("Property " + DS_DRIVER
+		    + " was not specified");
+	}
 
-        Connection conn;
-        try {
-            // Create a connection
-        	if (user != null && user.length() > 0) {
-        		conn = DriverManager.getConnection(url, user, passwd); 
-        	} else {
-        		conn = DriverManager.getConnection(url);
-        	}
-        	
-      
-        } catch (SQLException e) {
-        	throw new QueryTestFailedException(e);
-        } catch (Throwable t) {
-        	t.printStackTrace();
-        	throw new QueryTestFailedException(t.getMessage());
-        }
-        return conn;
-      
+	// need both user variables because Teiid uses 'user' and connectors use
+	// 'username'
+
+	this.username = this.getEnvironment().getProperty(DS_USER);
+	if (username == null) {
+	    this.username = this.getEnvironment().getProperty(DS_USERNAME);
+	}
+	this.pwd = this.getEnvironment().getProperty(DS_PASSWORD);
+
+	try {
+	    // Load jdbc driver
+	    Class.forName(driver);
+	} catch (ClassNotFoundException e) {
+	    throw new TransactionRuntimeException(e);
+	}
+
     }
-            
+
+    public synchronized Connection getConnection()
+	    throws QueryTestFailedException {
+	if (this.connection != null) {
+	    try {
+		if (!this.connection.isClosed()) {
+		    return this.connection;
+		}
+	    } catch (SQLException e) {
+
+	    }
+
+	}
+
+	this.connection = getJDBCConnection(this.driver, this.url,
+		this.username, this.pwd);
+	return this.connection;
+    }
+
+    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$
+
+	Connection conn;
+	try {
+	    // Create a connection
+	    if (user != null && user.length() > 0) {
+		conn = DriverManager.getConnection(url, user, passwd);
+	    } else {
+		conn = DriverManager.getConnection(url);
+	    }
+
+	} catch (SQLException e) {
+	    throw new QueryTestFailedException(e);
+	} catch (Throwable t) {
+	    t.printStackTrace();
+	    throw new QueryTestFailedException(t.getMessage());
+	}
+	return conn;
+
+    }
+
     public void shutdown() {
-    	if (this.connection != null) {
-    		try {
-    			this.connection.close();
-    		} catch (Exception e) {
-				//ignore
-			}
-       	}
-    	
-    	this.connection = null;
-           
+	super.shutdown();
+	if (this.connection != null) {
+	    try {
+		this.connection.close();
+	    } catch (Exception e) {
+		// ignore
+	    }
+	}
+
+	this.connection = null;
+
     }
 }

Modified: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/connection/JEEConnection.java
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/connection/JEEConnection.java	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/connection/JEEConnection.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -10,58 +10,60 @@
 import javax.naming.InitialContext;
 import javax.sql.DataSource;
 
+import org.teiid.test.framework.datasource.DataSourceFactory;
 import org.teiid.test.framework.exception.QueryTestFailedException;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
 
+/**
+ * JEE (JNDI) Connection Strategy, when the test is run inside an application
+ * server. Make sure all the jndi names are set correctly in the properties
+ * file.
+ */
+public class JEEConnection extends ConnectionStrategy {
 
+    public static final String DS_JNDINAME = "ds-jndiname"; //$NON-NLS-1$
 
-/** 
- * JEE (JNDI) Connection Strategy, when the test is run inside an application server. Make
- * sure all the jndi names are set correctly in the properties file.
- */
-public class JEEConnection extends ConnectionStrategy{
-	
-	 public static final String DS_JNDINAME = "ds-jndiname"; //$NON-NLS-1$
-	
-	private String jndi_name = null;
-	
-	
-	public JEEConnection(Properties props) throws QueryTestFailedException {
-    	   super(props);
+    private String jndi_name = null;
+
+
+    public JEEConnection(Properties props,
+	    DataSourceFactory dsf) throws QueryTestFailedException {
+	super(props, dsf);
     }
 
     public Connection getConnection() throws QueryTestFailedException {
-    	validate();
-        try {
-            InitialContext ctx = new InitialContext();
-            DataSource source = (DataSource)ctx.lookup(jndi_name);
-            
+	validate();
+	try {
+	    InitialContext ctx = new InitialContext();
+	    DataSource source = (DataSource) ctx.lookup(jndi_name);
 
-            if (source == null) {
-                String msg = "Unable to find jndi source " + jndi_name;//$NON-NLS-1$
+	    if (source == null) {
+		String msg = "Unable to find jndi source " + jndi_name;//$NON-NLS-1$
 
-                QueryTestFailedException mme = new QueryTestFailedException(msg);//$NON-NLS-1$
-                throw mme;
-            }            
-            Connection conn = source.getConnection();
-            return conn;
-        } catch (QueryTestFailedException qtfe) {
-        	throw qtfe;
-        } catch (Exception e) {
-            throw new QueryTestFailedException(e);
-        }
-    }    
-            
+		QueryTestFailedException mme = new QueryTestFailedException(msg);//$NON-NLS-1$
+		throw mme;
+	    }
+	    Connection conn = source.getConnection();
+	    return conn;
+	} catch (QueryTestFailedException qtfe) {
+	    throw qtfe;
+	} catch (Exception e) {
+	    throw new QueryTestFailedException(e);
+	}
+    }
+
     public void shutdown() {
-        // no connection management here; app server takes care of these..
+	super.shutdown();
+	// no connection management here; app server takes care of these..
     }
 
-	public void validate()  {
-		// TODO Auto-generated method stub
-		
-		jndi_name = getEnvironment().getProperty(DS_JNDINAME);
-    	if (jndi_name == null || jndi_name.length() == 0) {
-    		throw new TransactionRuntimeException("Property " + DS_JNDINAME + " was not specified");
-    	}
-	} 
+    public void validate() {
+	// TODO Auto-generated method stub
+
+	jndi_name = getEnvironment().getProperty(DS_JNDINAME);
+	if (jndi_name == null || jndi_name.length() == 0) {
+	    throw new TransactionRuntimeException("Property " + DS_JNDINAME
+		    + " was not specified");
+	}
+    }
 }

Modified: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -1,30 +1,42 @@
 package org.teiid.test.framework.datasource;
 
-import java.util.HashMap;
-import java.util.Map;
+import java.sql.Connection;
 import java.util.Properties;
 
+import javax.sql.XAConnection;
+
+import org.teiid.test.framework.connection.ConnectionStrategy;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+
+/**
+ * DataSource represents a single database that was configured by a connection.properties file.
+ * @author vanhalbert
+ *
+ */
 public class DataSource {
-	public static final String CONNECTOR_TYPE="connectortype";
-	public static final String DIRECTORY="dir";
+	public static final String CONNECTOR_TYPE="db.connectortype";
 	public static final String DB_TYPE="db.type";
 	
-	static Map<String, String> dbtypeBitMaskMap = null;
-
-	
 	private Properties props;
 
 	private String name;
 	private String group;
 	private String dbtype;
-	private int bitMask;
 	
+	// The connections are stored in the datasource and are reused
+	// for the duration of all tests so thats there's not
+	// disconnect/connect being performed over and over
+	private ConnectionStrategy conn;
+	private ConnectionStrategy xaconn;
+	
+	public DataSource() {
+	    this.name = "notassigned";
+	}
 	public DataSource(String name, String group, Properties properties) {
 		this.name = name;
 		this.group = group;
 		this.props = properties;
 		this.dbtype = this.props.getProperty(DB_TYPE);
-		this.setBitMask();
 	}
 
 	
@@ -51,88 +63,28 @@
 	public String getDBType() {
 		return this.dbtype;
 	}
-
-	public int getBitMask() {
-		return this.bitMask;
-	}
 	
 	
-	/**
-	 * These types match the "ddl" directories for supported database types
-	 * and it also found in the datasources connection.properties defined by the DB_TYPE property
-	 * @author vanhalbert
-	 *
-	 */
-	public static interface DataSourcTypes{
-		public static String MYSQL = "mysql";
-		public static String ORACLE = "oracle";
-		public static String POSTRES = "postgres";
-		public static String SQLSERVER = "sqlserver";
-		public static String DB2 = "db2";
-		public static String SYBASE = "sybase";
-		public static String DERBY = "derby";		
-		
+	public Connection getConnection() throws QueryTestFailedException {
+	    if (this.conn == null) return null;
+	    
+	    return this.conn.getConnection();
 	}
 	
-	
-	/**
-	 * These bitmask are used by the test to indicate which database type(s) a specific
-	 * test is not supported to run against.   
-	 * 
-	 * The exclusion postion was taken because the goal is that all test should be able to
-	 * run against all sources.   However, there are cases where specific database type
-	 * test are needed.
-	 * 
-	 * 
-	 * @author vanhalbert
-	 *
-	 */
-	public static interface ExclusionTypeBitMask{
-		
-		// Constants to hold bit masks for desired flags
-		static final int NONE_EXCLUDED = 0;  //         000...00000000 (empty mask)
-		static final int MYSQL = 1;    // 2^^0    000...00000001
-		static final int ORACLE = 2;    // 2^^1    000...00000010
-		static final int POSTGRES = 4;    // 2^^2    000...00000100
-		static final int SQLSERVER = 8;    // 2^^3    000...00001000
-		static final int DB2 = 16;   // 2^^4    000...00010000
-		static final int SYBASE = 32;   // 2^^5    000...00100000
-		static final int DERBY = 64;   // 2^^6    000...01000000
-		
+	public void setConnection(ConnectionStrategy c) {
+	    this.conn = c;
 	}
-	// don't include excluded
-	public static int NumBitMasks = 7;
-//	
-//	static int ALLOWABLE_DATA_TYPES = ExclusionTypeBitMask.MYSQL |
-//										ExclusionTypeBitMask.ORACLE |
-//										ExclusionTypeBitMask.POSTGRES |
-//										ExclusionTypeBitMask.SQLSERVER |
-//										ExclusionTypeBitMask.DB2 |
-//										ExclusionTypeBitMask.SYBASE |
-//										ExclusionTypeBitMask.DERBY;
 	
-	static {
-		dbtypeBitMaskMap = new HashMap<String, String>(NumBitMasks );
-		dbtypeBitMaskMap.put(DataSourcTypes.MYSQL, String.valueOf(ExclusionTypeBitMask.MYSQL));
-		dbtypeBitMaskMap.put(DataSourcTypes.ORACLE, String.valueOf(ExclusionTypeBitMask.ORACLE));
-		dbtypeBitMaskMap.put(DataSourcTypes.POSTRES, String.valueOf(ExclusionTypeBitMask.POSTGRES));
-		dbtypeBitMaskMap.put(DataSourcTypes.DB2, String.valueOf(ExclusionTypeBitMask.DB2));
-		dbtypeBitMaskMap.put(DataSourcTypes.SQLSERVER, String.valueOf(ExclusionTypeBitMask.SQLSERVER));
-		dbtypeBitMaskMap.put(DataSourcTypes.SYBASE, String.valueOf(ExclusionTypeBitMask.SYBASE));
-		dbtypeBitMaskMap.put(DataSourcTypes.DERBY, String.valueOf(ExclusionTypeBitMask.DERBY));
-		
+	public XAConnection getXAConnection() throws QueryTestFailedException {
+	    if (this.xaconn == null) return null;
+	    
+	    return this.xaconn.getXAConnection();
 	}
 	
-	public void setBitMask() {
-		int rtn = ExclusionTypeBitMask.NONE_EXCLUDED;
-		
-		String bitmask = dbtypeBitMaskMap.get(dbtype);
-		if (bitmask == null) {
-			bitMask = rtn;
-		} else {
-			bitMask =  new Integer(bitmask).intValue();
-		}
+	public void setXAConnection(ConnectionStrategy xaconn) {
+	    this.xaconn = xaconn;
 	}
-	
 
+		
+
 }

Copied: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java (from rev 1610, trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java)
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java	                        (rev 0)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -0,0 +1,569 @@
+package org.teiid.test.framework.datasource;
+
+import java.util.Collections;
+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 java.util.Set;
+
+import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.ConfigPropertyNames;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+
+import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.core.util.StringUtil;
+
+
+/**
+ * The DataSourceFactory is responsible for managing the datasources used during a single test.
+ * It ensures the same data source is used in both the connector binding and during validation to ensure validation is performed
+ * against the same datasource the test was performed on.
+ *
+ * The following are the available options for controlling which datasources are used during a test:
+ * <li>Control which datasources are used and to which model they are assigned</li>
+ * 
+ * <p>
+ * Use the {@link ConfigPropertyNames#USE_DATASOURCES_PROP} property to specify a comma delimited ordered list to control which data sources to use. 
+ * 
+ * <br><br>
+ * This will enable integration testing to be setup to use well known combinations, to ensure coverage and makes it easier to replicate issues.   
+ * 
+ * This indicates to use only the specified datasources for this test.   This option can be used in test cases where only 
+ * specific sources are to be used and tested against.
+ * 
+ * This ordered list will map to the model:order mapping in the config.properties file.
+ * <br><br>
+ * Example:  in the config.properties file, the models in the test and their order can be specified:
+ * 	<li>		pm1=1	</li>
+ * 	<li>		pm2=2	</li>
+ * <br>
+ * 
+ * Then set property: ConfigPropertyNames.USE_DATASOURCES_PROP=oracle,sqlserver
+ * 
+ * This will use oracle and sqlserver datasources in the test, and when a datasource is requested for model "pm1", the oracle datasource will be returned.  And when a data source
+ * for "pm2" is requested, the data source mapped to 2nd ordered datasource of sqlserver will be returned. 
+ *
+ * </p>
+ * <li>Control which datasources of a specific database type to exclude</li>
+ * <p>
+ *
+ * Use the {@link ConfigPropertyNames#EXCLUDE_DATASBASE_TYPES_PROP} property to specify a comma delimited list of {@link DataBaseTypes} to exclude.
+ * <br><br>
+ * This will remove all datasources of a specific database type from the list of available datasources.  This option will be applied after 
+ * {@link ConfigPropertyNames#USE_DATASOURCES_PROP} option.   This is done because there are some test that will not work with certain database
+ * types, and therefore, if the required datasources are not met, the test will be bypassed for execution.
+ *</p>
+ * <li>Control for a specfic model, which database type of datasource to be assigned</li>
+ * <p>
+ * This option gives the developer even more fine grain control of how datasources are assigned.   There are cases where a specific model must be assigned
+ * to a datasource of a specific database type.
+ * 
+ * To use this option, 
+ *  
+ * </p>
+ * @author vanhalbert
+ *
+ */
+public class DataSourceFactory {
+	
+	/**
+	 * These types match the "ddl" directories for supported database types
+	 * and it also found in the datasources connection.properties defined by the DB_TYPE property
+	 * These are also the values used to specify the required database types.
+	 *
+	 */
+	public static interface DataBaseTypes{
+		public static String MYSQL = "mysql";
+		public static String ORACLE = "oracle";
+		public static String POSTRES = "postgres";
+		public static String SQLSERVER = "sqlserver";
+		public static String DB2 = "db2";
+		public static String SYBASE = "sybase";
+		public static String DERBY = "derby";	
+		public static String ANY = "any";
+		
+	}
+
+	// the DO_NO_USE_DEFAULT will be passed in when the test are run from maven and no property is passed in for UseDataSources 
+	private static final String DO_NOT_USE_DEFAULT="${usedatasources}";
+	
+	private DataSourceMgr dsmgr = DataSourceMgr.getInstance();
+	
+//	private ConfigPropertyLoader configprops;
+	
+	private Properties configprops;
+	
+	// contains the names of the datasources when the -Dusedatasources option is used
+	private Map<String, String> useDS = null;
+	
+	// contains all the datasources available to be used
+	private Map<String, DataSource> availDS = null;
+
+	
+	// contains any dbtype preconditions on a model, which requires a model to be assigned a certain database type
+	private Map<String, String> requiredDataBaseTypes = null; // key=modelname  value=dbtype
+
+	// this set is use to track datasources that have already been assigned
+	private Set<String> assignedDataSources = new HashSet<String>();
+
+	private int lastassigned = 0;
+	
+	// indicates if the datasource requirements have been, it will be false in the case
+	// a specific dbtype is required and that type was not one of the available types defined
+	private boolean metDBRequiredTypes = true;
+	
+	// indicates that there are required dbtypes to consider
+	private boolean hasRequiredDBTypes = false;
+
+	
+	public DataSourceFactory(ConfigPropertyLoader config) {
+	    	this.configprops = PropertiesUtils.clone(config.getProperties(), null, true);
+		this.requiredDataBaseTypes = config.getModelAssignedDatabaseTypes();
+		config();
+	}
+	
+	public Properties getConfigProperties() {
+	    return this.configprops;
+	}
+
+	/**
+	 * config is called at the start / setup of the {@link
+	 * TransactionContainer#} test. This is to ensure any exclusions /
+	 * inclusions are considered for the next executed set of test.
+	 * 
+	 * 
+	 * 	1st, check for the usedatasource property, if exist, then only add those specific datasources
+	 * 		to the useDataSources, otherwise add all available.
+	 *  2nd, if the exclude option is used, then remove any excluded datasources from the useDataSources.
+	 *  
+	 * @since
+	 */
+	private void config() {
+		System.out.println("Configure Datasource Factory ");
+		
+		Map<String, DataSource> availDatasources = dsmgr.getDataSources();
+		
+		availDS = new HashMap<String, DataSource>(availDatasources.size());
+		
+		String usedstypeprop = configprops
+		.getProperty(ConfigPropertyNames.USE_DATASOURCE_TYPES_PROP);
+		
+		Set<String> useDBTypes = null;
+
+		if (usedstypeprop != null && usedstypeprop.length() > 0) {
+			List<String> eprops = StringUtil.split(usedstypeprop, ",");
+			useDBTypes = new HashSet<String>(eprops.size());
+			useDBTypes.addAll(eprops);
+			System.out.println("EXCLUDE datasources: " + usedstypeprop);
+		} else {
+		    useDBTypes = Collections.EMPTY_SET;
+		}
+		
+		String excludeprop = configprops
+		.getProperty(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP);
+		
+		Set<String> excludedDBTypes = null;
+
+		if (excludeprop != null && excludeprop.length() > 0) {
+			List<String> eprops = StringUtil.split(excludeprop, ",");
+			excludedDBTypes = new HashSet<String>(eprops.size());
+			excludedDBTypes.addAll(eprops);
+			System.out.println("EXCLUDE datasources: " + excludeprop);
+		} else {
+			excludedDBTypes = Collections.EMPTY_SET;
+		}
+
+		
+		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);
+
+			List<String> dss = StringUtil.split(limitdsprop, ",");
+
+			useDS = new HashMap<String, String>(dss.size());
+			DataSource ds = null;
+			int i = 1;
+			for (Iterator<String> it = dss.iterator(); it.hasNext(); i++) {
+				String dssName = it.next();
+				ds = availDatasources.get(dssName);
+				
+				if (ds != null && !excludedDBTypes.contains(ds.getDBType())) {
+				
+					useDS.put(String.valueOf(i), dssName);
+				
+					availDS.put(dssName, ds);
+					System.out.println("Using ds: " + dssName);
+				}
+				
+			}
+
+		} else {
+			for (Iterator<DataSource> it = availDatasources.values().iterator(); it.hasNext(); ) {
+				DataSource ds = it.next();
+				// if the datasource type is not excluded, then consider for usages
+				if (!excludedDBTypes.contains(ds.getDBType())) {
+				    
+				    // if use a specific db type is specified, then it must match,
+				    // otherwise add it to the available list
+				    if (useDBTypes.size() > 0 && usedstypeprop.contains(ds.getDBType())) {
+        				availDS.put(ds.getName(), ds);
+				    } else {
+					availDS.put(ds.getName(), ds);
+				    }
+				    
+				}
+			}
+		    
+		    
+		}
+
+		
+		
+		if (requiredDataBaseTypes != null && requiredDataBaseTypes.size() > 0) {
+			this.hasRequiredDBTypes = true;
+			
+			Iterator<String> rit = this.requiredDataBaseTypes.keySet().iterator();
+
+			// go thru all the datasources and remove those that are excluded
+				while (rit.hasNext()) {
+					String modelName = rit.next();
+					String rdbtype = this.requiredDataBaseTypes.get(modelName);
+					
+					Iterator<DataSource> ait = availDS.values().iterator();
+
+					metDBRequiredTypes = false;
+					
+					// go thru all the datasources and find the matching datasource of the correct dbtype
+					while (ait.hasNext()) {
+						DataSource ds = ait.next();
+						if (ds.getDBType().equalsIgnoreCase(rdbtype)) {
+							assignedDataSources.add(ds.getName());
+
+							dsmgr.setDataSource(modelName, ds);
+						//	modelToDatasourceMap.put(modelName, ds);
+							metDBRequiredTypes = true;
+				
+						}
+						
+					}
+					
+					if (!metDBRequiredTypes) {
+						// did find a required dbtype, no need going any further
+						break;
+					}
+					
+				}
+								
+		}
+		
+		
+	}
+	
+	public int getNumberAvailableDataSources() {
+		return (metDBRequiredTypes ? this.availDS.size() :0);
+	}
+
+	public synchronized DataSource getDatasource(String datasourceid,
+			String modelName) throws QueryTestFailedException {
+		DataSource ds = null;
+
+		// map the datasource to the model and datasourceid
+		// this is so the next time this combination is requested,
+		// the same datasource is returned to ensure when consecutive calls
+		// during the process
+		// corresponds to the same datasource
+		String key = null;
+
+		key = modelName;
+		//+ "_" + datasourceid;
+
+		// if the datasourceid represents a group name, then use the group name
+		// so that all future request using that group name for a specified
+		// model
+		// will use the same datasource
+		
+		ds = dsmgr.getDataSource(key);
+		if (ds != null) {
+		    return ds;
+		}
+		
+		if (this.hasRequiredDBTypes) {
+			if (this.requiredDataBaseTypes.containsKey(modelName)) {
+				String dbtype = this.requiredDataBaseTypes.get(modelName);
+				
+				Iterator<DataSource> it = availDS.values().iterator();
+
+				// need to go thru all the datasources to know if any has already been
+				// assigned
+				// because the datasourceid passed in was a group name
+				while (it.hasNext()) {
+					DataSource checkit = it.next();
+
+					if (dbtype.equalsIgnoreCase(checkit.getDBType())) {
+						ds = checkit;
+						break;
+					}
+
+				}
+
+				
+			}
+			
+		} else if (useDS != null) {
+				String dsname = useDS.get(datasourceid);
+				if (dsname != null) {
+					ds = availDS.get(dsname);
+					if (ds == null) {
+						throw new QueryTestFailedException("Datasource name "
+								+ dsname
+								+ " was not found in the allDatasources map");
+	
+					}
+				} 
+	
+
+		} else {
+		
+			Iterator<DataSource> it = availDS.values().iterator();
+	
+			// need to go thru all the datasources to know if any has already been
+			// assigned
+			// because the datasourceid passed in was a group name
+			while (it.hasNext()) {
+				DataSource checkit = it.next();
+	
+				if (!assignedDataSources.contains(checkit.getName())) {
+					ds = checkit;
+					break;
+				}
+	
+			}
+		}
+
+		if (ds == null) {
+			int cnt = 0;
+			Iterator<String> itds = assignedDataSources.iterator();
+
+			// when all the datasources have been assigned, but a new model
+			// datasource id is
+			// passed in, need to reassign a previously assigned datasource
+			// This case will happen when more models are defined than there are
+			// defined datasources.
+			while (itds.hasNext()) {
+				String dsname = itds.next();
+
+				if (cnt == this.lastassigned) {
+
+					ds = availDS.get(dsname);
+
+					this.lastassigned++;
+					if (lastassigned >= assignedDataSources.size()) {
+						this.lastassigned = 0;
+					}
+
+					break;
+				}
+			}
+
+		}
+
+		if (ds == null) {
+			throw new QueryTestFailedException(
+					"Unable to assign a datasource for model:datasourceid "
+							+ modelName + ":" + datasourceid);
+
+		}
+
+		assignedDataSources.add(ds.getName());
+
+		dsmgr.setDataSource(key, ds);
+		return ds;
+
+	}
+
+	public void cleanup() {
+
+	    	dsmgr.clear();
+		assignedDataSources.clear();
+		requiredDataBaseTypes.clear();
+
+		if (useDS != null) useDS.clear();
+		if (availDS != null) availDS.clear();
+
+	}
+	
+	public static void main(String[] args) {
+		//NOTE: to run this test to validate the DataSourceMgr, do the following:
+		//   ---  need 3 datasources,   Oracle, SqlServer and 1 other
+		
+		ConfigPropertyLoader config = ConfigPropertyLoader.getInstance();
+		
+		DataSourceFactory factory = new DataSourceFactory(config);
+
+		try {
+			if (factory.getDatasource("1", "model1") == null) {
+				throw new RuntimeException("No datasource was not found");
+			}
+			
+
+		} catch (QueryTestFailedException e) {
+			e.printStackTrace();
+		}
+		
+		factory.cleanup();
+		
+		ConfigPropertyLoader.cleanup();
+
+		
+		// the following verifies that order of "use" datasources is applied to request for datasources.
+		config = ConfigPropertyLoader.getInstance();
+		
+		config.setProperty(ConfigPropertyNames.USE_DATASOURCES_PROP, "oracle,sqlserver");
+				
+		factory = new DataSourceFactory(config);
+
+		try {
+			
+			DataSource dsfind = factory.getDatasource("2", "model2");
+			if (dsfind == null) {
+				throw new RuntimeException("No datasource was not found as the 2nd datasource");
+				
+			}
+			
+			if (dsfind.getConnectorType() == null) {
+				throw new RuntimeException("Connector types was not defined");
+			}
+			
+			if (!dsfind.getName().equalsIgnoreCase("sqlserver")) {
+				throw new RuntimeException("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");
+				
+			}
+			if (!dsfind.getName().equalsIgnoreCase("oracle")) {
+				throw new RuntimeException("Oracle was not found as the 2nd datasource");
+				
+			}
+			System.out.println("Datasource :" + dsfind.getName() + " was found");
+			
+			
+			// the following test verifies that a sqlserver datasource is not
+			// returned (excluded)
+			factory.cleanup();
+		
+			ConfigPropertyLoader.cleanup();
+
+
+			config = ConfigPropertyLoader.getInstance();
+			config.setProperty(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP, "sqlserver");
+
+			
+			factory = new DataSourceFactory(config);
+
+			int n = factory.getNumberAvailableDataSources();
+			System.out.println("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);
+					
+				} if (ds1.getDBType().equalsIgnoreCase(DataSourceFactory.DataBaseTypes.SQLSERVER)) {
+					throw new RuntimeException("sqlserver dbtype should have been excluded");
+				}
+			}
+				
+				
+				DataSource reuse = factory.getDatasource(String.valueOf(n + 1), "model1");
+				if (reuse != null) {
+					
+				} else {
+					throw new RuntimeException("The process was not able to reassign an already used datasource");
+					
+				}
+				
+				factory.cleanup();
+				
+				ConfigPropertyLoader.cleanup();
+
+				
+				// test required database types
+				// test 1 source
+
+				config = ConfigPropertyLoader.getInstance();
+				
+				config.setModelAssignedToDatabaseType("pm1", DataSourceFactory.DataBaseTypes.ORACLE);
+			
+				factory = new DataSourceFactory(config);
+
+				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());
+				}
+				
+				System.out.println("Test1 Required DS1 " + ds1.getDBType());
+				factory.cleanup();
+				
+				ConfigPropertyLoader.cleanup();
+
+				// test required database types
+				// test 2 sources, 1 required and other ANY
+				config = ConfigPropertyLoader.getInstance();
+			
+				
+				config.setModelAssignedToDatabaseType("pm2", DataSourceFactory.DataBaseTypes.SQLSERVER);
+				config.setModelAssignedToDatabaseType("pm1", DataSourceFactory.DataBaseTypes.ANY);
+			
+				factory = new DataSourceFactory(config);
+
+				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());
+				}
+				System.out.println("Test2 Required DS2 " + ds2.getDBType());
+			
+				factory.cleanup();
+				ConfigPropertyLoader.cleanup();
+
+				
+				// test required database types
+				// test 2 sources, 2 required 
+				config = ConfigPropertyLoader.getInstance();
+			
+				
+				config.setModelAssignedToDatabaseType("pm2", DataSourceFactory.DataBaseTypes.SQLSERVER);
+				config.setModelAssignedToDatabaseType("pm1", DataSourceFactory.DataBaseTypes.ORACLE);
+			
+				factory = new DataSourceFactory(config);
+
+				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());
+				}
+				
+				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());
+				}
+				System.out.println("Test3 Required DS3a " + ds3a.getDBType());
+				System.out.println("Test3 Required DS3b " + ds3b.getDBType());
+				
+				factory.cleanup();
+			
+				
+		} catch (QueryTestFailedException e) {
+			e.printStackTrace();
+		}
+	}
+
+}

Copied: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataStore.java (from rev 1610, trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataStore.java)
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataStore.java	                        (rev 0)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataStore.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.datasource;
+
+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;
+
+/** 
+ * 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();
+	try {
+	    load(getConnection("pm1", connStrategy));
+	    
+	    load(getConnection("pm2", connStrategy));
+
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        } 
+    }
+    
+    private static Connection getConnection(String identifier, ConnectionStrategy connStrategy) throws QueryTestFailedException {
+	Connection conn = connStrategy.createDriverConnection(identifier);
+	// force autocommit back to true, just in case the last user didnt
+	try {
+		conn.setAutoCommit(true);
+	} catch (Exception sqle) {
+		throw new QueryTestFailedException(sqle);
+	}
+	
+	return conn;
+    }
+    
+    private static void load(Connection c) throws Exception {
+        // DDL
+        // drop table g1;
+        // drop table g2;
+        
+        // oracle
+        // create Table g1 (e1 number(5) PRIMARY KEY,   e2 varchar2(50));
+        // create Table g2 (e1 number(5) REFERENCES g1, e2 varchar2(50));
+        
+        // SQL Server
+        // create Table g1 (e1 int PRIMARY KEY,   e2 varchar(50));
+        // create Table g2 (e1 int references g1, e2 varchar(50));   
+	            
+
+            Statement stmt = c.createStatement();
+            stmt.addBatch("delete from g2");
+            stmt.addBatch("delete from g1");
+            
+            for (int i = 0; i < 100; i++) {
+                stmt.addBatch("insert into g1 (e1, e2) values("+i+",'"+i+"')");
+            }
+            
+            
+            for (int i = 0; i < 50; i++) {
+                stmt.addBatch("insert into g2 (e1, e2) values("+i+",'"+i+"')");
+            }
+            
+            stmt.executeBatch();
+            stmt.close();
+
+    }
+    
+    /**
+     * Called as part of the setup for each test.  
+     * This will set the database state as if {@link #initialize(ConnectionStrategy)} was called.
+     * However, for performance reasons, the process goes about removing what's not needed instead of cleaning out everything
+     * and reinstalling. 
+     * @param connStrategy
+     */
+    public static void setup(ConnectionStrategy connStrategy) {
+	try {
+	    setUpTest(getConnection("pm1", connStrategy));
+	    
+	    setUpTest(getConnection("pm2", connStrategy));
+
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        } 
+
+	
+    }
+    
+    private static void setUpTest(Connection c) throws Exception {
+	
+            Statement stmt = c.createStatement();
+            stmt.addBatch("delete from g2 where e1 >= 50"); //$NON-NLS-1$
+            stmt.addBatch("delete from g1 where e1 >= 100"); 
+    
+            stmt.executeBatch();
+            stmt.close();
+            
+
+    }
+
+}

Copied: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/query (from rev 1610, trunk/test-integration/db/src/main/java/org/teiid/test/framework/query)

Deleted: branches/JCA/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-01 17:58:08 UTC (rev 1610)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -1,253 +0,0 @@
-/*
- * Copyright (c) 2000-2007 MetaMatrix, Inc.
- * All rights reserved.
- */
-package org.teiid.test.framework.query;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Properties;
-
-import javax.sql.XAConnection;
-
-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.datasource.DataStore;
-import org.teiid.test.framework.exception.QueryTestFailedException;
-
-
-
-/**
- * The AbstractQueryTransactionTest is the base implementation for the
- * {@link TransactionQueryTestCase}. This provides the default logic for perform a testcase.
- * The only method to implement in order to perform a basic, single datasource, test
- * is the {@link #testCase()} method.
- * 
- * AbstractQueryTransactionTest is the class that should be extended when a
- * testcase is being created to validate certain behavior
- * 
- * <br>
- * The following methods are useful when writing validation logic because they provide
- * a direct connection to the datasource that was used by the VDB.  This enables data
- * validation of expected behavior of Teiid.
- * <li>{@link #getSource(String)}. </li>
- * <li>{@link #getXASource(String)} </li>
- * 
- * <br>
- * 
- * @see QueryExecution for use when direct queries to the source are used to
- *      validate the results of the testcase.
- * 
- */
-public abstract class AbstractQueryTransactionTest extends  com.metamatrix.jdbc.api.AbstractQueryTest
-	implements TransactionQueryTestCase {
-    
-    private static String initialized = null;
-
-    protected String testname = "NA";
-    protected int fetchSize = -1;
-    protected int queryTimeout = -1;
-
-    protected ConnectionStrategy connStrategy;
-
-    public AbstractQueryTransactionTest() {
-	super();
-    }
-
-    public AbstractQueryTransactionTest(String testname) {
-	super();
-	this.testname = testname;
-    }
-
-    public String getTestName() {
-	return this.testname;
-	
-    }
-    
-
-    @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 {
-//	assertEquals(read(expectedReader, compareResultsCaseSensitive()), read(
-//		resultReader, compareResultsCaseSensitive()));
-//    }
-
-    @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;
-
-	    Properties executionProperties = this.connStrategy.getEnvironment();
-	    if (executionProperties != null) {
-		String txnautowrap = executionProperties
-			.getProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP);
-		if (txnautowrap != null) {
-		    statement.setExecutionProperty(
-			    CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP,
-			    txnautowrap);
-		    
-		   
-//		    this.print("TransactionAutoWrap = " + txnautowrap);
-		}
-		
-		String fetchSizeStr = executionProperties
-		    .getProperty(CONNECTION_STRATEGY_PROPS.FETCH_SIZE);
-		if (fetchSizeStr != null) {
-		    try {
-			fetchSize = Integer.parseInt(fetchSizeStr);
-			
-			this.print("FetchSize = " + fetchSize);
-		    } catch (NumberFormatException e) {
-			fetchSize = -1;
-		    // this.print("Invalid fetch size value: " + fetchSizeStr
-		    // + ", ignoring");
-		    }
-		}
-
-	    }
-	    
-
-
-	    if (this.fetchSize > 0) {
-		try {
-		    statement.setFetchSize(this.fetchSize);
-		} catch (SQLException e) {
-//		    this.print(e);
-		}
-	    }
-
-	    if (this.queryTimeout > 0) {
-		try {
-		    statement.setQueryTimeout(this.queryTimeout);
-		} catch (SQLException e) {
-//		    this.print(e);
-		}
-	    }
-	}
-
-    }
-
-
-
-    /**
-     * Override <code>setupDataSource</code> if there is different mechanism for
-     * setting up the datasources for the testcase
-     * 
-     * @throws QueryTestFailedException
-     * @throws QueryTestFailedException
-     * 
-     * @since
-     */
-    @Override
-    public void setup() throws QueryTestFailedException {
-
-	if (initialized == null || !initialized.equalsIgnoreCase(this.getClass().getSimpleName()) ) {
-	    initialized = this.getClass().getSimpleName();
-	    DataStore.initialize(connStrategy);
-	    
-	}
-	
-	DataStore.setup(connStrategy);
-	
-    }
-
-    /**
-     * The source connection must be asked from the connection strategy because only here
-     * is it known which model was mapped to which datasource.
-     * This is because each test could potentially use an include/exclude datasource option
-     * that could change the mappings between tests.
-     * @param identifier
-     * @return
-     * @throws QueryTestFailedException
-     */
-    public Connection getSource(String identifier)
-	    throws QueryTestFailedException {
-	
-	Connection conn = this.connStrategy.createDriverConnection(identifier);
-	// force autocommit back to true, just in case the last user didnt
-	try {
-		conn.setAutoCommit(true);
-	} catch (Exception sqle) {
-		throw new QueryTestFailedException(sqle);
-	}
-	
-	return conn;
-
-    }
-
-    public XAConnection getXASource(String identifier)
-	    throws QueryTestFailedException {
-
-	return this.connStrategy.createDataSourceConnection(identifier);
-
-    }
-
-    /**
-     * Implement testCase(), it is the entry point to the execution of the test.
-     * 
-     * @throws Exception
-     * 
-     * @since
-     */
-    public abstract void testCase() throws Exception;
-
-    /**
-     * Indicates what should be done when a failure occurs in
-     * {@link #testCase()}
-     * 
-     * @return
-     * 
-     * @since
-     */
-    public boolean rollbackAllways() {
-	return false;
-    }
-
-    /**
-     * Override <code>before</code> if there is behavior that needs to be
-     * performed prior to {@link #testCase()} being called.
-     * 
-     * 
-     * @since
-     */
-    public void before() {
-    }
-
-    /**
-     * Override <code>after</code> if there is behavior that needs to be
-     * performed after {@link #testCase()} being called.
-     * 
-     * 
-     * @since
-     */
-    public void after() {
-    }
-
-    /**
-     * At end of each test, perform any cleanup that your test requires. Note:
-     * Do not cleanup any connections by calling {@link ConnectionStrategy#shutdown()}. 
-     * That is performed by the
-     * {@link TransactionContainer#runTransaction(TransactionQueryTestCase)} at the
-     * end of the test.
-     */
-    public void cleanup() {
-
-    }
-
-    @Override
-    public XAConnection getXAConnection() {
-	return null;
-    }
-
-}

Copied: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java (from rev 1610, trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java)
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java	                        (rev 0)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -0,0 +1,253 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.query;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Properties;
+
+import javax.sql.XAConnection;
+
+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.datasource.DataStore;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+
+
+
+/**
+ * The AbstractQueryTransactionTest is the base implementation for the
+ * {@link TransactionQueryTestCase}. This provides the default logic for perform a testcase.
+ * The only method to implement in order to perform a basic, single datasource, test
+ * is the {@link #testCase()} method.
+ * 
+ * AbstractQueryTransactionTest is the class that should be extended when a
+ * testcase is being created to validate certain behavior
+ * 
+ * <br>
+ * The following methods are useful when writing validation logic because they provide
+ * a direct connection to the datasource that was used by the VDB.  This enables data
+ * validation of expected behavior of Teiid.
+ * <li>{@link #getSource(String)}. </li>
+ * <li>{@link #getXASource(String)} </li>
+ * 
+ * <br>
+ * 
+ * @see QueryExecution for use when direct queries to the source are used to
+ *      validate the results of the testcase.
+ * 
+ */
+public abstract class AbstractQueryTransactionTest extends  com.metamatrix.jdbc.api.AbstractQueryTest
+	implements TransactionQueryTestCase {
+    
+    private static String initialized = null;
+
+    protected String testname = "NA";
+    protected int fetchSize = -1;
+    protected int queryTimeout = -1;
+
+    protected ConnectionStrategy connStrategy;
+
+    public AbstractQueryTransactionTest() {
+	super();
+    }
+
+    public AbstractQueryTransactionTest(String testname) {
+	super();
+	this.testname = testname;
+    }
+
+    public String getTestName() {
+	return this.testname;
+	
+    }
+    
+
+    @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 {
+//	assertEquals(read(expectedReader, compareResultsCaseSensitive()), read(
+//		resultReader, compareResultsCaseSensitive()));
+//    }
+
+    @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;
+
+	    Properties executionProperties = this.connStrategy.getEnvironment();
+	    if (executionProperties != null) {
+		String txnautowrap = executionProperties
+			.getProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP);
+		if (txnautowrap != null) {
+		    statement.setExecutionProperty(
+			    CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP,
+			    txnautowrap);
+		    
+		   
+//		    this.print("TransactionAutoWrap = " + txnautowrap);
+		}
+		
+		String fetchSizeStr = executionProperties
+		    .getProperty(CONNECTION_STRATEGY_PROPS.FETCH_SIZE);
+		if (fetchSizeStr != null) {
+		    try {
+			fetchSize = Integer.parseInt(fetchSizeStr);
+			
+			this.print("FetchSize = " + fetchSize);
+		    } catch (NumberFormatException e) {
+			fetchSize = -1;
+		    // this.print("Invalid fetch size value: " + fetchSizeStr
+		    // + ", ignoring");
+		    }
+		}
+
+	    }
+	    
+
+
+	    if (this.fetchSize > 0) {
+		try {
+		    statement.setFetchSize(this.fetchSize);
+		} catch (SQLException e) {
+//		    this.print(e);
+		}
+	    }
+
+	    if (this.queryTimeout > 0) {
+		try {
+		    statement.setQueryTimeout(this.queryTimeout);
+		} catch (SQLException e) {
+//		    this.print(e);
+		}
+	    }
+	}
+
+    }
+
+
+
+    /**
+     * Override <code>setupDataSource</code> if there is different mechanism for
+     * setting up the datasources for the testcase
+     * 
+     * @throws QueryTestFailedException
+     * @throws QueryTestFailedException
+     * 
+     * @since
+     */
+    @Override
+    public void setup() throws QueryTestFailedException {
+
+	if (initialized == null || !initialized.equalsIgnoreCase(this.getClass().getSimpleName()) ) {
+	    initialized = this.getClass().getSimpleName();
+	    DataStore.initialize(connStrategy);
+	    
+	}
+	
+	DataStore.setup(connStrategy);
+	
+    }
+
+    /**
+     * The source connection must be asked from the connection strategy because only here
+     * is it known which model was mapped to which datasource.
+     * This is because each test could potentially use an include/exclude datasource option
+     * that could change the mappings between tests.
+     * @param identifier
+     * @return
+     * @throws QueryTestFailedException
+     */
+    public Connection getSource(String identifier)
+	    throws QueryTestFailedException {
+	
+	Connection conn = this.connStrategy.createDriverConnection(identifier);
+	// force autocommit back to true, just in case the last user didnt
+	try {
+		conn.setAutoCommit(true);
+	} catch (Exception sqle) {
+		throw new QueryTestFailedException(sqle);
+	}
+	
+	return conn;
+
+    }
+
+    public XAConnection getXASource(String identifier)
+	    throws QueryTestFailedException {
+
+	return this.connStrategy.createDataSourceConnection(identifier);
+
+    }
+
+    /**
+     * Implement testCase(), it is the entry point to the execution of the test.
+     * 
+     * @throws Exception
+     * 
+     * @since
+     */
+    public abstract void testCase() throws Exception;
+
+    /**
+     * Indicates what should be done when a failure occurs in
+     * {@link #testCase()}
+     * 
+     * @return
+     * 
+     * @since
+     */
+    public boolean rollbackAllways() {
+	return false;
+    }
+
+    /**
+     * Override <code>before</code> if there is behavior that needs to be
+     * performed prior to {@link #testCase()} being called.
+     * 
+     * 
+     * @since
+     */
+    public void before() {
+    }
+
+    /**
+     * Override <code>after</code> if there is behavior that needs to be
+     * performed after {@link #testCase()} being called.
+     * 
+     * 
+     * @since
+     */
+    public void after() {
+    }
+
+    /**
+     * At end of each test, perform any cleanup that your test requires. Note:
+     * Do not cleanup any connections by calling {@link ConnectionStrategy#shutdown()}. 
+     * That is performed by the
+     * {@link TransactionContainer#runTransaction(TransactionQueryTestCase)} at the
+     * end of the test.
+     */
+    public void cleanup() {
+
+    }
+
+    @Override
+    public XAConnection getXAConnection() {
+	return null;
+    }
+
+}

Deleted: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/query/QueryExecution.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/QueryExecution.java	2009-12-01 17:58:08 UTC (rev 1610)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/query/QueryExecution.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -1,22 +0,0 @@
-package org.teiid.test.framework.query;
-
-import java.sql.Connection;
-
-import com.metamatrix.jdbc.api.AbstractQueryTest;
-
-/**
- * The QueryExecution class can be used to query the source directly.   The intended use
- * of this class is for validating results after the execution of a test case.
- * 
- * @see AbstractQueryTransactionTest regarding creating a testcase to validate behavior.
- * @author vanhalbert
- *
- */
-public class QueryExecution extends AbstractQueryTest {
-    
-	public QueryExecution(Connection conn) {
-		super(conn);
-	}
-	
-
-}

Copied: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/query/QueryExecution.java (from rev 1610, trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/QueryExecution.java)
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/query/QueryExecution.java	                        (rev 0)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/query/QueryExecution.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -0,0 +1,22 @@
+package org.teiid.test.framework.query;
+
+import java.sql.Connection;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+/**
+ * The QueryExecution class can be used to query the source directly.   The intended use
+ * of this class is for validating results after the execution of a test case.
+ * 
+ * @see AbstractQueryTransactionTest regarding creating a testcase to validate behavior.
+ * @author vanhalbert
+ *
+ */
+public class QueryExecution extends AbstractQueryTest {
+    
+	public QueryExecution(Connection conn) {
+		super(conn);
+	}
+	
+
+}

Modified: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -8,9 +8,9 @@
 import javax.transaction.UserTransaction;
 
 import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.TransactionQueryTest;
+import org.teiid.test.framework.TransactionQueryTestCase;
+import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
-import org.teiid.test.framework.connection.ConnectionStrategy;
 
 
 
@@ -18,12 +18,13 @@
 public class JNDITransaction extends TransactionContainer {
     UserTransaction userTxn = null;
     
-    public JNDITransaction(ConnectionStrategy strategy) {
-        super(strategy);
+    
+    public JNDITransaction() {
+	super();
     }
     
-    protected void before(TransactionQueryTest test) {
-        if (this.props.getProperty(ConnectionStrategy.JNDINAME_USERTXN) == null) {
+    protected void before(TransactionQueryTestCase test) {
+        if (this.props.getProperty(CONNECTION_STRATEGY_PROPS.JNDINAME_USERTXN) == null) {
             throw new TransactionRuntimeException("No JNDI name found for the User Transaction to look up in application server");
         }
 
@@ -31,14 +32,14 @@
  
             // begin the transaction
             InitialContext ctx = new InitialContext();
-            this.userTxn = (UserTransaction)ctx.lookup(this.props.getProperty(ConnectionStrategy.JNDINAME_USERTXN));
+            this.userTxn = (UserTransaction)ctx.lookup(this.props.getProperty(CONNECTION_STRATEGY_PROPS.JNDINAME_USERTXN));
             this.userTxn.begin();
         } catch (Exception e) {
             throw new TransactionRuntimeException(e);
         }        
     }
     
-    protected void after(TransactionQueryTest test) {
+    protected void after(TransactionQueryTestCase test) {
         try {
             if (this.userTxn != null) {
                 if (test.rollbackAllways()|| test.exceptionOccurred()) {

Modified: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -4,28 +4,28 @@
  */
 package org.teiid.test.framework.transaction;
 
-import java.sql.Connection;
+
 import java.sql.SQLException;
 
+import org.teiid.test.framework.ConfigPropertyLoader;
 import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.TransactionQueryTest;
-import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.framework.TransactionQueryTestCase;
+import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
+import org.teiid.test.framework.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
-import org.teiid.test.framework.connection.ConnectionStrategy;
 
 
-
 /** 
  * A transaction which is user controlled. 
  */
 public class LocalTransaction extends TransactionContainer {
 
-    public LocalTransaction(ConnectionStrategy strategy) {
-        super(strategy);
-        
+    public LocalTransaction() {
+	super();
     }
-    
-    protected void before(TransactionQueryTest test) {
+    protected void before(TransactionQueryTestCase test) {
+	this.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());
@@ -34,8 +34,8 @@
         }        
     }
     
-    protected void after(TransactionQueryTest test) {
- //   	boolean exception = false;
+    protected void after(TransactionQueryTestCase test) {
+    	boolean exception = false;
         try {            
             if (test.rollbackAllways()|| test.exceptionOccurred()) {
                 test.getConnection().rollback();
@@ -45,7 +45,7 @@
                 test.getConnection().commit();
             }
         } catch (SQLException se) {
-//        	exception =  true;
+        	exception =  true;
         	// if exception, try to trigger the rollback
         	try {
         		test.getConnection().rollback();
@@ -58,13 +58,13 @@
         } finally {
         	// if an exception occurs and the autocommit is set to true - while doing a transaction
         	// will generate a new exception overriding the first exception
-//        	if (!exception) {
-//	            try {
-//	                test.getConnection().setAutoCommit(true);
-//	            } catch (SQLException e) {
-//	                throw new RuntimeException(e);
-//	            }
-//        	}
+        	if (!exception) {
+	            try {
+	                test.getConnection().setAutoCommit(true);
+	            } catch (SQLException e) {
+	                throw new RuntimeException(e);
+	            }
+        	}
         }
     }   
     

Copied: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OffWrapTransaction.java (from rev 1610, trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OffWrapTransaction.java)
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OffWrapTransaction.java	                        (rev 0)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OffWrapTransaction.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.transaction;
+
+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.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
+
+
+
+/** 
+ * This transction is only valid when 
+ * AutoCommit = ON 
+ * txnAutoWrap = OFF
+ */
+public class OffWrapTransaction extends TransactionContainer {
+    
+    public OffWrapTransaction() {
+	super();
+    }
+    
+    public void before(TransactionQueryTestCase test) {
+	this.setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_OFF);
+
+        
+    }
+    
+    public void after(TransactionQueryTestCase test) {
+
+    }
+}

Copied: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OnWrapTransaction.java (from rev 1610, trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OnWrapTransaction.java)
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OnWrapTransaction.java	                        (rev 0)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OnWrapTransaction.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.transaction;
+
+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.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
+
+
+/** 
+ * This transction is only valid when 
+ * AutoCommit = ON 
+ * txnAutoWrap = ON 
+ */
+public class OnWrapTransaction extends TransactionContainer {
+    public OnWrapTransaction() {
+	super();
+    }
+        
+    public void before(TransactionQueryTestCase test) {
+	this.setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_ON);
+
+        
+    }
+    
+    public void after(TransactionQueryTestCase test) {
+
+    }
+}

Copied: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java (from rev 1610, trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java)
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java	                        (rev 0)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.transaction;
+
+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.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
+
+
+/** 
+ * This transction is only valid when 
+ * AutoCommit = ON 
+ * txnAutoWrap = Optimistic.
+ */
+public class OptimisticWrapTransaction extends TransactionContainer {
+    public OptimisticWrapTransaction() {
+	super();
+    }
+    
+    public void before(TransactionQueryTestCase test) {
+	this.setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_OPTIMISTIC);
+
+    }
+    
+    public void after(TransactionQueryTestCase test) {
+
+    }
+}

Copied: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java (from rev 1610, trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java)
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java	                        (rev 0)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.transaction;
+
+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.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
+
+
+/** 
+ * This transaction type only is valid when
+ * AutoCommit = ON
+ * txnAutoWrap = PESSIMISTIC
+ */
+public class PessimisticWrapTransaction extends TransactionContainer {
+    public PessimisticWrapTransaction() {
+	super();
+    }
+    
+    public void before(TransactionQueryTestCase test) {
+	this.setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_PESSIMISTIC);
+
+    }
+    
+    public void after(TransactionQueryTestCase test) {
+
+    }
+    
+
+}

Copied: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/StandaloneGlobalTransaction.java (from rev 1610, trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/StandaloneGlobalTransaction.java)
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/StandaloneGlobalTransaction.java	                        (rev 0)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/StandaloneGlobalTransaction.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.transaction;
+
+import java.util.Random;
+
+import javax.transaction.xa.XAResource;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.TransactionQueryTestCase;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+
+import com.metamatrix.common.xa.MMXid;
+
+public class StandaloneGlobalTransaction extends TransactionContainer {
+	private static Random RANDOM = new Random();
+	private MMXid xid;
+	
+    public StandaloneGlobalTransaction() {
+        super();
+    }
+        
+    protected void before(TransactionQueryTestCase test) {
+        try {          
+        	xid = createXid();
+        	XAResource xaResource = this.getConnectionStrategy().getXAConnection().getXAResource();
+  //      	    getXAConnection().getXAResource();
+        	xaResource.setTransactionTimeout(120);
+        	xaResource.start(xid, XAResource.TMNOFLAGS);
+        } catch (Exception e) {
+            throw new TransactionRuntimeException(e);
+        }        
+    }
+
+	public static MMXid createXid() {
+		byte[] gid = new byte[10];
+		byte[] bid = new byte[10];
+		RANDOM.nextBytes(gid);
+		RANDOM.nextBytes(bid);
+		return new MMXid(0, gid, bid);
+	}
+    
+    protected void after(TransactionQueryTestCase test) {
+        boolean delistSuccessful = false;
+        boolean commit = false;
+        try {
+            XAResource xaResource = this.getConnectionStrategy().getXAConnection().getXAResource();
+            
+			xaResource.end(xid, XAResource.TMSUCCESS);
+            
+            if (!test.exceptionExpected() && xaResource.prepare(xid) == XAResource.XA_OK) {
+            	commit = true;
+            }
+            delistSuccessful = true;
+        } catch (Exception e) {
+            throw new TransactionRuntimeException(e);            
+        } finally {
+            try {
+                if (!delistSuccessful || test.rollbackAllways()|| test.exceptionOccurred()) {
+                    this.getConnectionStrategy().getXAConnection().getXAResource().rollback(xid);
+                //getXAConnection().getXAResource().rollback(xid);
+                }
+                else if (commit) {
+                    this.getConnectionStrategy().getXAConnection().getXAResource().commit(xid, true);
+                }            
+            } catch (Exception e) {
+                throw new TransactionRuntimeException(e);            
+            } 
+        }
+    }    
+}

Modified: branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -9,8 +9,10 @@
 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.TransactionQueryTest;
+import org.teiid.test.framework.TransactionQueryTestCase;
+import org.teiid.test.framework.exception.QueryTestFailedException;
 import org.teiid.test.framework.connection.ConnectionStrategy;
 import org.teiid.test.framework.exception.QueryTestFailedException;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
@@ -21,11 +23,11 @@
 	private static Random RANDOM = new Random();
 	private MMXid xid;
 	
-    public XATransaction(ConnectionStrategy strategy) {
-        super(strategy);
-    }
+	public XATransaction() {
+		super();
+	}
         
-    protected void before(TransactionQueryTest test) {
+    protected void before(TransactionQueryTestCase test) {
         try {          
         	xid = createXid();
         	XAResource xaResource = getXAConnection().getXAResource();
@@ -46,7 +48,7 @@
 		return new MMXid(0, gid, bid);
 	}
     
-    protected void after(TransactionQueryTest test) {
+    protected void after(TransactionQueryTestCase test) {
         boolean delistSuccessful = false;
         boolean commit = false;
         

Deleted: branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/ArgCheck.java
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/ArgCheck.java	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/ArgCheck.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -1,534 +0,0 @@
-/*
- * 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.util;
-
-import java.util.Collection;
-import java.util.Map;
-
-/**
- * This class contains a set of static utility methods for checking method arguments.
- * It contains many of the common checks that are done, such as checking that an 
- * Object is non-null, checking the range of a value, etc.  All of these methods
- * throw {@link #java.lang.IllegalArgumentException}.
- */
-public class ArgCheck {
-
-	/**
-	 * Can't construct - utility class
-	 */
-	private ArgCheck() {
-	}
-	
-	/**
-	 * Check that the boolean condition is true; throw an
-	 * IllegalArgumentException if not.
-	 * @param condition The boolean condition to check
-	 * @param message Exception message if check fails
-	 * @throws IllegalArgumentException if condition is false
-	 */
-	public static final void isTrue(boolean condition, String message){
-		if(!condition) {
-			throw new IllegalArgumentException(message);    
-		}
-	}
-
-	// ########################## int METHODS ###################################
-
-    /**
-     * Check that the value is non-negative (>=0). 
-     * @param value Value
-     * @throws IllegalArgumentException If value is negative (<0)
-     */
-	public static final void isNonNegative(int value) {
-		isNonNegative(value,null);
-	}
-
-    /**
-     * Check that the value is non-negative (>=0). 
-     * @param value Value
-     * @param message Exception message if check fails
-     * @throws IllegalArgumentException If value is negative (<0)
-     */
-	public static final void isNonNegative(int value, String message) {
-		if(value < 0) {
-            final String msg = message != null ? 
-                               message :
-                               "ArgCheck.isNonNegativeInt"; //$NON-NLS-1$
-			throw new IllegalArgumentException(msg);    
-		}
-	}
-
-    /**
-     * Check that the value is non-positive (<=0). 
-     * @param value Value
-     * @throws IllegalArgumentException If value is positive (>0)
-     */
-	public static final void isNonPositive(int value) {
-	    isNonPositive(value,null);
-	}
-
-    /**
-     * Check that the value is non-positive (<=0). 
-     * @param value Value
-     * @param message Exception message if check fails
-     * @throws IllegalArgumentException If value is positive (>0)
-     */
-	public static final void isNonPositive(int value, String message) {
-	    if(value > 0) {
-            final String msg = message != null ? 
-                               message :
-                               "ArgCheck.isNonPositiveInt"; //$NON-NLS-1$
-	        throw new IllegalArgumentException(msg);
-	    }
-	}
-
-    /**
-     * Check that the value is negative (<0). 
-     * @param value Value
-     * @throws IllegalArgumentException If value is non-negative (>=0)
-     */
-	public static final void isNegative(int value) {
-	    isNegative(value,null);
-	}
-
-    /**
-     * Check that the value is negative (<0). 
-     * @param value Value
-     * @param message Exception message if check fails
-     * @throws IllegalArgumentException If value is non-negative (>=0)
-     */
-	public static final void isNegative(int value, String message) {
-	    if(value >= 0) {
-            final String msg = message != null ? 
-                               message :
-                               "ArgCheck.isNegativeInt"; //$NON-NLS-1$
-	        throw new IllegalArgumentException(msg);
-	    }
-	}
-
-    /**
-     * Check that the value is positive (>0). 
-     * @param value Value
-     * @throws IllegalArgumentException If value is non-positive (<=0)
-     */
-	public static final void isPositive(int value) {
-	    isPositive(value,null);
-	}
-
-    /**
-     * Check that the value is positive (>0). 
-     * @param value Value
-     * @param message Exception message if check fails
-     * @throws IllegalArgumentException If value is non-positive (<=0)
-     */
-	public static final void isPositive(int value, String message) {
-	    if(value <= 0) { 
-            final String msg = message != null ? 
-                               message :
-                               "ArgCheck.isPositiveInt"; //$NON-NLS-1$
-	        throw new IllegalArgumentException(msg);
-	    }
-	}
-
-	// ########################## long METHODS ###################################
-
-    /**
-     * Check that the value is non-negative (>=0). 
-     * @param value Value
-     * @throws IllegalArgumentException If value is negative (<0)
-     */
-	public static final void isNonNegative(long value) {
-	    isNonNegative(value,null);
-	}
-
-    /**
-     * Check that the value is non-negative (>=0). 
-     * @param value Value
-     * @param message Exception message if check fails
-     * @throws IllegalArgumentException If value is negative (<0)
-     */
-	public static final void isNonNegative(long value, String message) {
-		if(value < 0) {
-            final String msg = message != null ? 
-                               message :
-                               "ArgCheck.isNonNegativeInt"; //$NON-NLS-1$
-			throw new IllegalArgumentException(msg);    
-		}
-	}
-
-    /**
-     * Check that the value is non-positive (<=0). 
-     * @param value Value
-     * @throws IllegalArgumentException If value is positive (>0)
-     */
-	public static final void isNonPositive(long value) {
-	    isNonPositive(value,null);
-	}
-
-    /**
-     * Check that the value is non-positive (<=0). 
-     * @param value Value
-     * @param message Exception message if check fails
-     * @throws IllegalArgumentException If value is positive (>0)
-     */
-	public static final void isNonPositive(long value, String message) {
-	    if(value > 0) {
-            final String msg = message != null ? 
-                               message :
-                               "ArgCheck.isNonPositiveInt"; //$NON-NLS-1$
-	        throw new IllegalArgumentException(msg);
-	    }
-	}
-
-    /**
-     * Check that the value is negative (<0). 
-     * @param value Value
-     * @throws IllegalArgumentException If value is non-negative (>=0)
-     */
-	public static final void isNegative(long value) {
-	    isNegative(value,null);
-	}
-
-    /**
-     * Check that the value is negative (<0). 
-     * @param value Value
-     * @param message Exception message if check fails
-     * @throws IllegalArgumentException If value is non-negative (>=0)
-     */
-	public static final void isNegative(long value, String message) {
-	    if(value >= 0) {
-            final String msg = message != null ? 
-                               message :
-                               "ArgCheck.isNegativeInt"; //$NON-NLS-1$
-            throw new IllegalArgumentException(msg);
-	    }
-	}
-
-    /**
-     * Check that the value is positive (>0). 
-     * @param value Value
-     * @throws IllegalArgumentException If value is non-positive (<=0)
-     */
-	public static final void isPositive(long value) {
-	    isPositive(value,null);
-	}
-
-    /**
-     * Check that the value is positive (>0). 
-     * @param value Value
-     * @param message Exception message if check fails
-     * @throws IllegalArgumentException If value is non-positive (<=0)
-     */
-	public static final void isPositive(long value, String message) {
-	    if(value <= 0) { 
-            final String msg = message != null ? 
-                               message :
-                               "ArgCheck.isPositiveInt"; //$NON-NLS-1$
-            throw new IllegalArgumentException(msg);
-	    }
-	}
-
-	// ########################## String METHODS ###################################
-
-    /**
-     * Check that the string is non-null and has length > 0
-     * @param value Value
-     * @throws IllegalArgumentException If value is null or length == 0
-     */
-	public static final void isNotZeroLength(String value) {	    
-		isNotZeroLength(value,null);
-	}
-
-    /**
-     * Check that the string is non-null and has length > 0
-     * @param value Value
-     * @param message Exception message if check fails
-     * @throws IllegalArgumentException If value is null or length == 0
-     */
-	public static final void isNotZeroLength(String value, String message) {
-		isNotNull(value);
-		if(value.length() <= 0) {
-            final String msg = message != null ? 
-                               message :
-                               "ArgCheck.isStringNonZeroLength"; //$NON-NLS-1$
-            throw new IllegalArgumentException(msg);
-		}
-	}
-
-	// ########################## Object METHODS ###################################
-	
-    /**
-     * Check that the object is non-null
-     * @param value Value
-     * @throws IllegalArgumentException If value is null
-     */
-    public static final void isNotNull(Object value) {
-        isNotNull(value,null);
-    }
-
-    /**
-     * Check that the object is non-null
-     * @param value Value
-     * @param message Exception message if check fails
-     * @throws IllegalArgumentException If value is null
-     */
-	public static final void isNotNull(Object value, String message) {
-	    if(value == null) { 
-            final String msg = message != null ? 
-                               message :
-                               "ArgCheck.isNonNull"; //$NON-NLS-1$
-            throw new IllegalArgumentException(msg);
-	    }
-	}
-
-    /**
-     * Check that the object is null
-     * @param value Value
-     * @throws IllegalArgumentException If value is non-null
-     */
-    public static final void isNull(Object value) {
-        isNull(value,null);
-    }
-
-    /**
-     * Check that the object is null
-     * @param value Value
-     * @param message Exception message if check fails
-     * @throws IllegalArgumentException If value is non-null
-     */
-    public static final void isNull(Object value, String message) {
-        if(value != null) { 
-            final String msg = message != null ? 
-                               message :
-                               "ArgCheck.isNull"; //$NON-NLS-1$
-            throw new IllegalArgumentException(msg);
-        }
-    }
-
-    /**
-     * Check that the object is an instance of the specified Class
-     * @param theClass Class
-     * @param value Value
-     * @throws IllegalArgumentException If value is null
-     */
-	public static final void isInstanceOf(Class theClass, Object value) {
-        isInstanceOf(theClass,value,null);
-	}
-
-    /**
-     * Check that the object is an instance of the specified Class
-     * @param theClass Class
-     * @param value Value
-     * @param message Exception message if check fails
-     * @throws IllegalArgumentException If value is null
-     */
-	public static final void isInstanceOf(Class theClass, Object value, String message) {
-        isNotNull(value);
-	    if( ! theClass.isInstance(value) ) {
-            final String msg = message != null ? 
-                               message :
-                              "ArgCheck.isInstanceOf "; //$NON-NLS-1$
-	        throw new IllegalArgumentException(msg);
-	    }
-	}
-
-	// ########################## COLLECTION METHODS ###################################
-	
-    /**
-     * Check that the collection is not empty
-     * @param collection Collection 
-     * @throws IllegalArgumentException If collection is null or empty
-     */
-    public static final void isNotEmpty(Collection collection) {
-        isNotEmpty(collection,null);
-    }
-
-    /**
-     * Check that the collection is not empty
-     * @param collection Collection 
-     * @param message Exception message if check fails
-     * @throws IllegalArgumentException If collection is null or empty
-     */
-    public static final void isNotEmpty(Collection collection, String message) {
-        isNotNull(collection);
-        if(collection.isEmpty()) {
-            final String msg = message != null ? 
-                               message :
-                              "ArgCheck.isCollectionNotEmpty"; //$NON-NLS-1$
-            throw new IllegalArgumentException(msg);
-        }
-    }
-    
-    /**
-     * Check that the map is not empty
-     * @param map Map 
-     * @throws IllegalArgumentException If map is null or empty
-     */
-    public static final void isNotEmpty(Map map) {
-        isNotEmpty(map,null);
-    }
-
-    /**
-     * Check that the map is not empty
-     * @param map Map 
-     * @param message Exception message if check fails
-     * @throws IllegalArgumentException If map is null or empty
-     */
-    public static final void isNotEmpty(Map map, String message) {
-        isNotNull(map);
-        if(map.isEmpty()) {
-            final String msg = message != null ? 
-                               message :
-                               "ArgCheck.isMapNotEmpty"; //$NON-NLS-1$
-            throw new IllegalArgumentException(msg);
-        }
-    }
-
-    /**
-     * Check that the array is not empty
-     * @param array Array 
-     * @throws IllegalArgumentException If array is null or empty
-     * @since 3.1
-     */
-    public static final void isNotEmpty(Object[] array) {
-        isNotEmpty(array,null);
-    }
-
-    /**
-     * Check that the array is not empty
-     * @param array Array 
-     * @param message Exception message if check fails
-     * @throws IllegalArgumentException If array is null or empty
-     * @since 3.1
-     */
-    public static final void isNotEmpty(Object[] array, String message) {
-        isNotNull(array);
-        if(array.length == 0) {
-            final String msg = message != null ? 
-                               message :
-                               "ArgCheck.isArrayNotEmpty"; //$NON-NLS-1$
-            throw new IllegalArgumentException(msg);
-        }
-    }
-
-    /**
-     * Check that the string is not empty
-     * @param string String 
-     * @throws IllegalArgumentException If string is null or empty
-     * @since 3.1
-     */
-    public static final void isNotEmpty(String string) {
-        isNotZeroLength(string,null);
-    }
-
-    /**
-     * Check that the string is not empty
-     * @param string String 
-     * @param message Exception message if check fails
-     * @throws IllegalArgumentException If string is null or empty
-     * @since 3.1
-     */
-    public static final void isNotEmpty(String string, String message) {
-        isNotZeroLength(string,message);
-    }
-
-    /**
-     * Asserts that the specified first object is not the same as (==) the specified second object.
-     * @param firstObject  The first object to assert as not the same as the second object.
-     * @param firstName    The name that will be used within the exception message for the first object, should an exception be
-     *                      thrown; if null and <code>firstObject</code> is not null, <code>firstObject.toString()</code> will be
-     *                      used.
-     * @param secondObject The second object to assert as not the same as the first object.
-     * @param secondName   The name that will be used within the exception message for the second object, should an exception be
-     *                      thrown; if null and <code>secondObject</code> is not null, <code>secondObject.toString()</code> will
-     *                      be used.
-     * @throws IllegalArgumentException If the specified objects are the same.
-     * @since 3.1
-     */
-    public static void isNotSame(final Object firstObject, String firstName, final Object secondObject, String secondName) {
-        if (firstObject == secondObject) {
-            if (firstName == null && firstObject != null) {
-                firstName = firstObject.toString();
-            }
-            if (secondName == null && secondObject != null) {
-                secondName = secondObject.toString();
-            }
-            throw new IllegalArgumentException("ArgCheck.isNotSame"); //$NON-NLS-1$
-        }
-    }
-
-    /**
-     * Check that the collection contains the value
-     * @param collection Collection to check
-     * @param value Value to check for, may be null
-     * @throws IllegalArgumentException If collection is null or doesn't contain value
-     */
-    public static final void contains(Collection collection, Object value) {
-        contains(collection, value, null);
-    }
-
-    /**
-     * Check that the collection contains the value
-     * @param collection Collection to check
-     * @param value Value to check for, may be null
-     * @param message Exception message if check fails
-     * @throws IllegalArgumentException If collection is null or doesn't contain value
-     */
-    public static final void contains(Collection collection, Object value, String message) {
-		isNotNull(collection);
-		if(! collection.contains(value)) {
-            final String msg = message != null ? 
-                               message :
-                               "ArgCheck.contains"; //$NON-NLS-1$
-            throw new IllegalArgumentException(msg);
-		}
-	}
-
-    /**
-     * Check that the map contains the key
-     * @param map Map to check
-     * @param key Key to check for, may be null
-     * @throws IllegalArgumentException If map  is null or doesn't contain key
-     */
-	public static final void containsKey(Map map, Object key) {
-	    containsKey(map, key, null);
-	}
-
-    /**
-     * Check that the map contains the key
-     * @param map Map to check
-     * @param key Key to check for, may be null
-     * @param message Exception message if check fails
-     * @throws IllegalArgumentException If map  is null or doesn't contain key
-     */
-	public static final void containsKey(Map map, Object key, String message) {
-		isNotNull(map);
-		if(! map.containsKey(key)) {
-            final String msg = message != null ? 
-                               message :
-                               "ArgCheck.containsKey"; //$NON-NLS-1$
-            throw new IllegalArgumentException(msg);
-		}
-	}
-
-}

Deleted: branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/ChecksumUtil.java
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/ChecksumUtil.java	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/ChecksumUtil.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -1,97 +0,0 @@
-/*
- * 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.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.zip.CRC32;
-import java.util.zip.Checksum;
-
-/**
- * This utility class provides mechanisms for computing the checksum.
- */
-public class ChecksumUtil {
-    
-    protected static final int BUFFER_SIZE = 1024;
-
-	/**
-	 * Compute and return the checksum (using the default CRC-32 algorithm) 
-	 * of the contents on the specified stream.
-	 * This method closes the stream upon completion.
-	 * @param stream the stream containing the contents for which
-	 * the checksum is to be computed; may not be null
-	 * @return the Checksum for the contents
-	 * @throws AssertionError if <code>stream</code> is null
-	 * @throws IOException if there is an error reading the stream
-	 */
-	public static Checksum computeChecksum( InputStream stream ) throws IOException {
-		Checksum checksum = new CRC32();
-		computeChecksum(stream,checksum);  
-		return checksum;  
-	}
-
-	/**
-	 * Compute the checksum of the contents on the specified stream
-	 * using the supplied Checksum algorithm, and modify that
-	 * Checksum instance with the checksum value.
-	 * This method closes the stream upon completion.
-	 * @param stream the stream containing the contents for which
-	 * the checksum is to be computed; may not be null
-	 * @param algorithm the checksum algorithm to be used.
-	 * @return the number of bytes from <code>stream</code>
-	 * that were processed
-	 * @throws AssertionError if <code>stream</code> or
-	 * <code>algorithm</code> is null
-	 * @throws IOException if there is an error reading the stream
-	 */
-	public static long computeChecksum( InputStream stream, Checksum algorithm ) throws IOException {
-        byte[] buffer = new byte[BUFFER_SIZE];
-        int n = 0;
-        long sizeInBytes = 0;
-
-		// Compute the checksum ...
-		IOException ioe = null;
-        try {
-	        while ((n = stream.read(buffer)) > -1){
-	            algorithm.update(buffer, 0, n);
-	            sizeInBytes += n;
-	        }
-        } catch ( IOException e ) {
-        	ioe = e;
-        } finally {
-            try {
-        		stream.close(); 
-            } catch ( IOException e ) {
-            	//Throw this only if there was no IOException from processing above    
-                if ( ioe == null ) {
-                	ioe = e;    
-                }
-            }   
-        }
-        if ( ioe != null ) {
-        	throw ioe;    
-        }
-		return sizeInBytes;
-	}
-
-}

Deleted: branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/FileUtils.java
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/FileUtils.java	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/FileUtils.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -1,871 +0,0 @@
-/*
- * 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.util;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-
-public final class FileUtils {
-
-    public interface Constants {
-        char CURRENT_FOLDER_SYMBOL_CHAR    = '.';
-        char DRIVE_SEPARATOR_CHAR          = ':';
-        char FILE_EXTENSION_SEPARATOR_CHAR = '.';
-        char FILE_NAME_WILDCARD_CHAR       = '*';
-        
-        String CURRENT_FOLDER_SYMBOL    = String.valueOf(CURRENT_FOLDER_SYMBOL_CHAR);
-        String DRIVE_SEPARATOR          = String.valueOf(DRIVE_SEPARATOR_CHAR);
-        String FILE_EXTENSION_SEPARATOR = String.valueOf(FILE_EXTENSION_SEPARATOR_CHAR);
-        String FILE_NAME_WILDCARD       = String.valueOf(FILE_NAME_WILDCARD_CHAR);
-        String PARENT_FOLDER_SYMBOL     = ".."; //$NON-NLS-1$
-    }
-
-    public static final char SEPARATOR = '/';
-    
-	public static int DEFAULT_BUFFER_SIZE = 2048;
-	public static String TEMP_DIRECTORY;
-    public static String LINE_SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$
-    public static char[] LINE_SEPARATOR_CHARS = LINE_SEPARATOR.toCharArray();
-    
-    public final static String JAVA_IO_TEMP_DIR="java.io.tmpdir";//$NON-NLS-1$
-    public final static char[] SUFFIX_class = ".class".toCharArray(); //$NON-NLS-1$
-    public final static char[] SUFFIX_CLASS = ".CLASS".toCharArray(); //$NON-NLS-1$
-    public final static char[] SUFFIX_java = ".java".toCharArray(); //$NON-NLS-1$
-    public final static char[] SUFFIX_JAVA = ".JAVA".toCharArray(); //$NON-NLS-1$
-    public final static char[] SUFFIX_jar = ".jar".toCharArray(); //$NON-NLS-1$
-    public final static char[] SUFFIX_JAR = ".JAR".toCharArray(); //$NON-NLS-1$
-    public final static char[] SUFFIX_zip = ".zip".toCharArray(); //$NON-NLS-1$
-    public final static char[] SUFFIX_ZIP = ".ZIP".toCharArray(); //$NON-NLS-1$
-    
-    
-    private static final String TEMP_FILE = "delete.me"; //$NON-NLS-1$
-    private static final String TEMP_FILE_RENAMED = "delete.me.old"; //$NON-NLS-1$
-    
-    
-    
-    static {
-        String tempDirPath = System.getProperty(JAVA_IO_TEMP_DIR); 
-        TEMP_DIRECTORY = (tempDirPath.endsWith(File.separator) ? tempDirPath : tempDirPath + File.separator);
-    }
-
-    private FileUtils() {}
-
-    /**<p>
-     * Convert the specified file name to end with the specified extension if it doesn't already end with an extension.
-     * </p>
-     * @param name
-     *              The file name.
-     * @param extension
-     *              The extension to append to the file name.
-     * @return The file name with an extension.
-     * @since 4.0
-     */
-    public static String toFileNameWithExtension(final String name,
-                                                 final String extension) {
-        return toFileNameWithExtension(name, extension, false);
-    }
-
-    /**<p>
-     * Convert the specified file name to end with the specified extension if it doesn't already end with an extension.  If force
-     * is true, the specified extension will be appended to the name if the name doesn't end with that particular extension.
-     * </p>
-     * @param name
-     *              The file name.
-     * @param extension
-     *              The extension to append to the file name.
-     * @param force
-     *              Indicates whether to force the specified extension as the extension of the file name.
-     * @return The file name with an extension.
-     * @since 4.0
-     */
-    public static String toFileNameWithExtension(final String name,
-                                                 final String extension,
-                                                 final boolean force) {
-        if (name == null) {
-            final String msg = "FileUtils.The_name_of_the_file_may_not_be_null"; //$NON-NLS-1$
-            throw new IllegalArgumentException(msg);
-        }
-        if (extension == null) {
-            final String msg = "FileUtils.The_file_extension_may_not_be_null"; //$NON-NLS-1$
-            throw new IllegalArgumentException(msg);
-        }
-        if (name.endsWith(extension)) {
-            return name;
-        }
-        if (!force  &&  name.indexOf(Constants.FILE_EXTENSION_SEPARATOR_CHAR) >= 0) {
-            return name;
-        }
-        final int nameLen = name.length() - 1;
-        final int extLen = extension.length();
-        final boolean nameEndsWithExtChr = (nameLen >= 0  &&  name.charAt(nameLen) == Constants.FILE_EXTENSION_SEPARATOR_CHAR);
-        final boolean extBeginsWithExtChr = (extLen > 0  &&  extension.charAt(0) == Constants.FILE_EXTENSION_SEPARATOR_CHAR);
-        if (nameEndsWithExtChr  &&  extBeginsWithExtChr) {
-            return name.substring(0, nameLen) + extension;
-        }
-        if (!nameEndsWithExtChr  &&  !extBeginsWithExtChr) {
-            return name + Constants.FILE_EXTENSION_SEPARATOR + extension;
-        }
-        return name + extension;
-    }
-
-    /**
-     * Determine whether the specified name is valid for a file or folder on the current file system.
-     * @param newName the new name to be checked
-     * @return true if the name is null or contains no invalid characters for a folder or file, or false otherwise
-     */
-    public static boolean isFilenameValid( String newName ) {
-    	return true; //TODO: just catch an exception when the file is accessed or created
-    }
-
-    /**
-     * Copy a file.  Overwrites the destination file if it exists. 
-     * @param fromFileName
-     * @param toFileName
-     * @throws Exception
-     * @since 4.3
-     */
-    public static void copy(String fromFileName, String toFileName) throws IOException {
-		copy(fromFileName, toFileName, true);
-    }
-    
-    /**
-     * Copy a file 
-     * @param fromFileName
-     * @param toFileName
-     * @param overwrite whether to overwrite the destination file if it exists.
-     * @throws MetaMatrixCoreException
-     * @since 4.3
-     */
-    public static void copy(String fromFileName, String toFileName, boolean overwrite) throws IOException {
-        File toFile = new File(toFileName);
-        
-        if (toFile.exists()) {
-            if (overwrite) {
-                toFile.delete();
-            } else {
-                final String msg = "FileUtils.File_already_exists " + toFileName; //$NON-NLS-1$            
-                throw new IOException(msg);
-            }
-        }
-        
-        File fromFile = new File(fromFileName);
-        if (!fromFile.exists()) {
-            throw new FileNotFoundException("FileUtils.File_does_not_exist " + fromFileName); //$NON-NLS-1$
-        }
-        
-        FileInputStream fis = null;
-        try {
-            fis = new FileInputStream(fromFile);
-            write(fis, toFileName);    
-        } finally {
-            if (fis != null) {
-                fis.close();
-            }
-        }
-    }
-    
-    /**
-     * Copy recursively the contents of <code>sourceDirectory</code> to 
-     * the <code>targetDirectory</code>. Note that <code>sourceDirectory</code>
-     * will <b>NOT</b> be copied.  If <code>targetDirectory</code> does not exist, it will be created.
-     * @param sourceDirectory The source directory to copy
-     * @param targetDirectory The target directory to copy to
-     * @throws Exception If the source directory does not exist.
-     * @since 4.3
-     */
-    public static void copyDirectoryContentsRecursively(File sourceDirectory, File targetDirectory) throws Exception {
-        copyRecursively(sourceDirectory, targetDirectory, false);
-    }
-    
-    /**
-     * Copy file from orginating directory to the destination directory.
-     * 
-     * @param orginDirectory
-     * @param destDirectory
-     * @param fileName
-     * @throws Exception
-     * @since 4.4
-     */
-    public static void copyFile(String orginDirectory,
-                          String destDirectory,
-                          String fileName) throws Exception {
-
-        copyFile(orginDirectory, fileName, destDirectory, fileName);
-    }
-
-    /**
-     * Copy file from orginating directory to the destination directory.
-     * 
-     * @param orginDirectory
-     * @param orginFileName
-     * @param destDirectory
-     * @param destFileName
-     * @throws Exception
-     * @since 4.4
-     */
-    public static void copyFile(String orginDirectory,
-                          String orginFileName,
-                          String destDirectory,
-                          String destFileName) throws Exception {
-
-        FileUtils.copy(orginDirectory + File.separator + orginFileName, destDirectory + File.separator + destFileName);
-    }    
-
-    /**
-     * Copy recursively the <code>sourceDirectory</code> and all its contents 
-     * to the <code>targetDirectory</code>.  If <code>targetDirectory</code>
-     * does not exist, it will be created.
-     * @param sourceDirectory The source directory to copy
-     * @param targetDirectory The target directory to copy to
-     * @throws Exception If the source directory does not exist.
-     * @since 4.3
-     */
-    public static void copyDirectoriesRecursively(File sourceDirectory, File targetDirectory) throws Exception {
-        copyRecursively(sourceDirectory, targetDirectory, true);
-    }
-
-    /**
-     * Copy recursively from the <code>sourceDirectory</code> all its contents 
-     * to the <code>targetDirectory</code>.  if 
-     * <code>includeSourceRoot<code> == <code>true</code>, copy <code>sourceDirectory</code>
-     * itself, else only copy <code>sourceDirectory</code>'s contents.
-     * If <code>targetDirectory</code> does not exist, it will be created.
-     * @param sourceDirectory
-     * @param targetDirectory
-     * @throws FileNotFoundException
-     * @throws Exception
-     * @since 4.3
-     */
-    private static void copyRecursively(File sourceDirectory,
-                                        File targetDirectory,
-                                        boolean includeSourceRoot) throws FileNotFoundException,
-                                                             Exception {
-        if (!sourceDirectory.exists()) {
-            throw new FileNotFoundException("FileUtils.File_does_not_exist " + sourceDirectory); //$NON-NLS-1$
-        }
-        
-        if (!sourceDirectory.isDirectory()) {
-            throw new FileNotFoundException("FileUtils.Not_a_directory " + sourceDirectory); //$NON-NLS-1$
-        }
-        
-        File targetDir = new File(targetDirectory.getAbsolutePath() + File.separatorChar + sourceDirectory.getName());
-        if (includeSourceRoot) {
-            // copy source directory
-            targetDir.mkdir();
-        } else {
-            // copy only source directory contents
-            targetDir = new File(targetDirectory.getAbsolutePath() + File.separatorChar);
-        }
-        File[] sourceFiles = sourceDirectory.listFiles();
-        for (int i = 0; i < sourceFiles.length; i++) {
-            File srcFile = sourceFiles[i];
-            if (srcFile.isDirectory()) {
-                File childTargetDir = new File(targetDir.getAbsolutePath());
-                copyRecursively(srcFile, childTargetDir, true);
-            } else {
-                copy(srcFile.getAbsolutePath(), targetDir.getAbsolutePath() + File.separatorChar + srcFile.getName());
-            }
-        }
-    }
-    
-   /**
-    *  Write an InputStream to a file.
-    */
-    public static void write(InputStream is, String fileName) throws IOException {
-        File f = new File(fileName);
-        write(is,f);
-    }
-
-   /**
-    *  Write an InputStream to a file.
-    */
-    public static void write(InputStream is, File f) throws IOException {
-		write(is, f, DEFAULT_BUFFER_SIZE);    	
-    }
-
-	/**
-	 *  Write an InputStream to a file.
-	 */
-	 public static void write(InputStream is, File f, int bufferSize) throws IOException {
-		f.delete();
-		final File parentDir = f.getParentFile();
-		if (parentDir !=null) {
-			parentDir.mkdirs();
-		}
-
-		FileOutputStream fio = null;
-		BufferedOutputStream bos = null;
-        try {
-            fio = new FileOutputStream(f);
-            bos = new BufferedOutputStream(fio);
-            if (bufferSize > 0) {
-        		byte[] buff = new byte[bufferSize];
-        		int bytesRead;
-        
-        		// Simple read/write loop.
-        		while(-1 != (bytesRead = is.read(buff, 0, buff.length))) {
-        			bos.write(buff, 0, bytesRead);
-        		}
-            }
-            bos.flush();
-        } finally {
-            if (bos != null) {
-                bos.close();
-            }
-            if (fio != null) {
-                fio.close();
-            }
-        }
-	 }
-     
-     
-     /**
-      *  Write an File to an OutputStream
-      *  Note: this will not close the outputStream;
-      */
-        public static void write(File f, OutputStream outputStream) throws IOException {
-            write(f, outputStream, DEFAULT_BUFFER_SIZE);      
-        }
-        
-        /**
-         *  Write an File to an OutputStream
-         *  Note: this will not close the outputStream;
-         */
-         public static void write(File f, OutputStream outputStream, int bufferSize) throws IOException {
-            FileInputStream fis = null;
-            try {
-                fis = new FileInputStream(f);
-                write(fis, outputStream, bufferSize);
-            } finally {
-                if (fis != null) {
-                    fis.close();
-                }
-            }
-         }     
-         
-         /**
-          * Write the given input stream to outputstream
-          * Note: this will not close in/out streams 
-          */
-         public static void write(InputStream fis, OutputStream outputStream, int bufferSize) throws IOException {             
-             byte[] buff = new byte[bufferSize];
-             int bytesRead;
- 
-             // Simple read/write loop.
-             while(-1 != (bytesRead = fis.read(buff, 0, buff.length))) {
-                 outputStream.write(buff, 0, bytesRead);
-             } 
-             outputStream.flush();
-         }           
-
-   /**
-    *  Write a byte array to a file.
-    */
-  	public static void write(byte[] data, String fileName) throws IOException {
-        ByteArrayInputStream bais = null;
-        InputStream is = null;
-        try {
-            bais = new ByteArrayInputStream(data);
-            is = new BufferedInputStream(bais);
-    
-            write(is, fileName);  
-        } finally {
-            if (is != null) {
-                is.close();
-            }
-            if (bais != null) {
-                bais.close();
-            }
-        }
-  	}
-
-	/**
-	 *  Write a byte array to a file.
-	 */
-	 public static void write(byte[] data, File file) throws IOException {
-         ByteArrayInputStream bais = null;
-         InputStream is = null;
-         try {
-    		 bais = new ByteArrayInputStream(data);
-    		 is = new BufferedInputStream(bais);
-    
-    		 write(is, file);  
-         } finally {
-             if (is != null) {
-                 is.close();
-             }
-             if (bais != null) {
-                 bais.close();
-             }
-         }
-	 }
-
-    /**
-     * Returns a <code>File</code> array that will contain all the files that 
-     * exist in the specified directory or any nested directories
-     * @return File[] of files in the directory
-     */
-    public static File[] findAllFilesInDirectoryRecursively(final String dir) {
-
-        // Recursively navigate through the contents of this directory
-        // gathering up all the files
-        List allFiles = new ArrayList();
-        File directory = new File(dir);
-        addFilesInDirectoryRecursively(directory, allFiles);
-
-        return (File[])allFiles.toArray(new File[allFiles.size()]);
-
-    }
-    
-    private static void addFilesInDirectoryRecursively(final File directory, final List allFiles) {
-        File[] files = directory.listFiles();
-        if (files != null) {
-            for (int i=0; i < files.length; i++) {
-                File file = files[i];
-                if (file.isDirectory()) {
-                    addFilesInDirectoryRecursively(file, allFiles);
-                } else {
-                    allFiles.add(file);
-                }
-            }
-        }        
-    }
-
-	/**
-     * Returns a <code>File</code> array that will contain all the files that exist in the directory
-     * 
-     * @return File[] of files in the directory
-     */
-    public static File[] findAllFilesInDirectory(String dir) {
-
-        // Find all files in the specified directory
-        File modelsDirFile = new File(dir);
-        FileFilter fileFilter = new FileFilter() {
-
-            public boolean accept(File file) {
-                if (file.isDirectory()) {
-                    return false;
-                }
-
-                String fileName = file.getName();
-
-                if (fileName == null || fileName.length() == 0) {
-                    return false;
-                }
-
-                return true;
-
-            }
-        };
-
-        File[] modelFiles = modelsDirFile.listFiles(fileFilter);
-
-        return modelFiles;
-
-    }
-
-      /**
-       * Returns a <code>File</code> array that will contain all the files that
-       * exist in the directory that have the specified extension.
-       * @return File[] of files having a certain extension
-       */
-      public static File[] findAllFilesInDirectoryHavingExtension(String dir, final String extension) {
-
-        // Find all files in that directory that end in XML and attempt to
-        // load them into the runtime metadata database.
-        File modelsDirFile = new File(dir);
-        FileFilter fileFilter = new FileFilter() {
-            public boolean accept(File file) {
-                if(file.isDirectory()) {
-                    return false;
-                }
-
-
-                String fileName = file.getName();
-
-                if (fileName==null || fileName.length()==0) {
-                    return false;
-                }
-
-                return (fileName.endsWith(extension));
-                // here we check to see if the file is an .xml file...
-//                int index = fileName.lastIndexOf("."); //$NON-NLS-1$
-//
-//                if (index<0 || index==fileName.length()) {
-//                    return false;
-//                }
-//
-//                if (fileName.substring(index, fileName.length()).equalsIgnoreCase(extension)) {
-//                    return true;
-//                }
-//                return false;
-            }
-        };
-
-        File[] modelFiles = modelsDirFile.listFiles(fileFilter);
-
-        return modelFiles;
-
-    }
-
-    /**
-     * @param string
-     * @return
-     */
-    public static String getFilenameWithoutExtension( final String filename ) {
-        if ( filename == null || filename.length() == 0 ) {
-            return filename;
-        }
-        final int extensionIndex = filename.lastIndexOf(Constants.FILE_EXTENSION_SEPARATOR_CHAR);
-        if ( extensionIndex == -1 ) {
-            return filename;    // not found
-        }
-        if ( extensionIndex == 0 ) {
-            return ""; //$NON-NLS-1$
-        }
-        return filename.substring(0,extensionIndex);
-    }
-    
-    public static String getBaseFileNameWithoutExtension(String path) {
-    	return StringUtil.getFirstToken(StringUtil.getLastToken(path, "/"), "."); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-    
-    /**
-     * Obtains the file extension of the specified <code>File</code>. The extension is considered to be all the
-     * characters after the last occurrence of {@link Constants#FILE_EXTENSION_SEPARATOR_CHAR} in the pathname
-     * of the input.
-     * @param theFile the file whose extension is being requested
-     * @return the extension or <code>null</code> if not found
-     * @since 4.2
-     */
-    public static String getExtension(File theFile) {
-        return getExtension(theFile.getPath());
-    }
-    
-    /**
-     * Obtains the file extension of the specified file name. The extension is considered to be all the
-     * characters after the last occurrence of {@link Constants#FILE_EXTENSION_SEPARATOR_CHAR}.
-     * @param theFileName the file whose extension is being requested
-     * @return the extension or <code>null</code> if not found
-     * @since 4.2
-     */
-    public static String getExtension(String theFileName) {
-        String result = null;
-        final int index = theFileName.lastIndexOf(Constants.FILE_EXTENSION_SEPARATOR_CHAR);
-        
-        // make sure extension char is found and is not the last char in the path
-        if ((index != -1) && ((index + 1) != theFileName.length())) {
-            result = theFileName.substring(index + 1);
-        }
-        
-        return result;
-    }
-    
-    /**
-     * Returns true iff str.toLowerCase().endsWith(".jar") || str.toLowerCase().endsWith(".zip")
-     * implementation is not creating extra strings.
-     */
-    public final static boolean isArchiveFileName(String name) {
-        int nameLength = name == null ? 0 : name.length();
-        int suffixLength = SUFFIX_JAR.length;
-        if (nameLength < suffixLength) return false;
-
-        // try to match as JAR file
-        for (int i = 0; i < suffixLength; i++) {
-            char c = name.charAt(nameLength - i - 1);
-            int suffixIndex = suffixLength - i - 1;
-            if (c != SUFFIX_jar[suffixIndex] && c != SUFFIX_JAR[suffixIndex]) {
-
-                // try to match as ZIP file
-                suffixLength = SUFFIX_ZIP.length;
-                if (nameLength < suffixLength) return false;
-                for (int j = 0; j < suffixLength; j++) {
-                    c = name.charAt(nameLength - j - 1);
-                    suffixIndex = suffixLength - j - 1;
-                    if (c != SUFFIX_zip[suffixIndex] && c != SUFFIX_ZIP[suffixIndex]) return false;
-                }
-                return true;
-            }
-        }
-        return true;        
-    }  
-     
-    /**
-     * Returns true iff str.toLowerCase().endsWith(".class")
-     * implementation is not creating extra strings.
-     */
-    public final static boolean isClassFileName(String name) {
-        int nameLength = name == null ? 0 : name.length();
-        int suffixLength = SUFFIX_CLASS.length;
-        if (nameLength < suffixLength) return false;
-
-        for (int i = 0; i < suffixLength; i++) {
-            char c = name.charAt(nameLength - i - 1);
-            int suffixIndex = suffixLength - i - 1;
-            if (c != SUFFIX_class[suffixIndex] && c != SUFFIX_CLASS[suffixIndex]) return false;
-        }
-        return true;        
-    } 
-      
-    /**
-     * Returns true iff str.toLowerCase().endsWith(".java")
-     * implementation is not creating extra strings.
-     */
-    public final static boolean isJavaFileName(String name) {
-        int nameLength = name == null ? 0 : name.length();
-        int suffixLength = SUFFIX_JAVA.length;
-        if (nameLength < suffixLength) return false;
-
-        for (int i = 0; i < suffixLength; i++) {
-            char c = name.charAt(nameLength - i - 1);
-            int suffixIndex = suffixLength - i - 1;
-            if (c != SUFFIX_java[suffixIndex] && c != SUFFIX_JAVA[suffixIndex]) return false;
-        }
-        return true;        
-    }
-    
-
-    public static File convertByteArrayToFile(final byte[] contents, final String parentDirectoryPath, final String fileName) {
-        if (contents != null) {
-            FileOutputStream os = null;
-            try {
-                final File temp = new File(parentDirectoryPath,fileName);
-                os = new FileOutputStream(temp);
-                os.write(contents);
-                return temp;
-            } catch (Exception e) {
-                throw new RuntimeException(e);
-            } finally {
-                if (os != null) {
-                    try {
-                        os.close();
-                    } catch (IOException e1) {
-                       // do nothing
-                    }
-                }
-            }
-        }
-        return null;
-    }
-    
-    public static void removeDirectoryAndChildren(File directory) {
-        removeChildrenRecursively(directory);        
-        if(!directory.delete()) {
-            directory.deleteOnExit();
-        }
-    }
-
-    public static void removeChildrenRecursively(File directory) {
-        File[] files = directory.listFiles();
-        if(files != null) {
-            for(int i=0; i < files.length; i++) {
-                File file = files[i];
-                if (file.isDirectory()) {
-                    removeDirectoryAndChildren(file);
-                } else {
-                    if(!file.delete()) {
-                        file.deleteOnExit();
-                    }   
-                }
-            }
-        }        
-    }
-
-    /**
-     * Builds a file directory path from a physical location and a location that needs
-     * to be appended to the physical.  This is used so that the correct File.separator 
-     * is used and that no additional separator is added when not needed. 
-     * @param physicalDirectory
-     * @param appendLocation
-     * @return
-     * @since 4.3
-     */
-    public static String buildDirectoryPath(String[] paths) {
-//      String physicalDirectory, String appendLocation) {
-
-        if (paths == null || paths.length == 0) {
-            return ""; //$NON-NLS-1$           
-        }
-        if (paths.length == 1) {
-            return (paths[0]!=null?paths[0]:"");//$NON-NLS-1$ 
-        }
-        int l = paths.length;
-        StringBuffer sb = new StringBuffer();
-        for (int cur=0;cur<l; cur++) {
-            int next = cur+1;
-            
-            String value = paths[cur]!=null?paths[cur]:"";//$NON-NLS-1$ 
-            if (value.equals("")) {//$NON-NLS-1$ 
-                continue;
-            }
-            sb.append(value);
-            
-            if (next < l) {
-                String nextValue = paths[next]!=null?paths[next]:"";//$NON-NLS-1$ 
-                if (value.endsWith(File.separator)) {
-                
-                } else if (!nextValue.startsWith(File.separator)) {
-                    sb.append(File.separator);
-                }
-            
-            }
-        }
-        
-        return sb.toString();
-    }
-    
-    /**
-     * Compute checksum for the given file. 
-     * @param f The file for which checksum needs to be computed
-     * @return The checksum
-     * @since 4.3
-     */
-    public static long getCheckSum(final File f)  throws Exception {
-        ArgCheck.isNotNull(f);
-        FileInputStream is = null;
-        try {
-            is = new FileInputStream(f);
-            return ChecksumUtil.computeChecksum(is).getValue();
-        } finally {
-            if (is != null) {
-                try {
-                    is.close();
-                } catch (IOException err1) {
-                }
-            }
-        }
-    }    
-
-    
-    /**
-     * Test whether it's possible to read and write files in the specified directory. 
-     * @param dirPath Name of the directory to test
-     * @throws MetaMatrixException
-     * @since 4.3
-     */
-    public static void testDirectoryPermissions(String dirPath) throws Exception {
-        
-        //try to create a file
-        File tmpFile = new File(dirPath + File.separatorChar + TEMP_FILE);
-        boolean success = false;
-        try {
-            success = tmpFile.createNewFile();
-        } catch (IOException e) {
-        }
-        if (!success) {
-            final String msg = "FileUtils.Unable_to_create_file_in " + dirPath; //$NON-NLS-1$            
-            throw new Exception(msg);
-        }
-        
-
-        //test if file can be written to
-        if (!tmpFile.canWrite()) {
-            final String msg = "FileUtils.Unable_to_write_file_in " + dirPath; //$NON-NLS-1$            
-            throw new Exception(msg);
-        }
-
-        //test if file can be read
-        if (!tmpFile.canRead()) {
-            final String msg = "FileUtils.Unable_to_read_file_in " + dirPath; //$NON-NLS-1$            
-            throw new Exception(msg);
-        }
-
-        //test if file can be renamed
-        File newFile = new File(dirPath + File.separatorChar + TEMP_FILE_RENAMED);
-        success = false;
-        try {
-            success = tmpFile.renameTo(newFile);
-        } catch (Exception e) {
-        }
-        if (!success) {
-            final String msg = "FileUtils.Unable_to_rename_file_in " + dirPath; //$NON-NLS-1$            
-            throw new Exception(msg);
-        }
-
-        //test if file can be deleted
-        success = false;
-        try {
-            success = newFile.delete();
-        } catch (Exception e) {
-        }
-        if (!success) {
-            final String msg = "FileUtils.Unable_to_delete_file_in " + dirPath; //$NON-NLS-1$            
-            throw new Exception(msg);
-        }
-    }
-
-    /**
-     * Rename a file. 
-     * @param oldFilePath
-     * @param newFilePath
-     * @param overwrite If true, overwrite the old file if it exists.  If false, throw an exception if the old file exists.  
-     * @throws MetaMatrixCoreException
-     * @since 4.3
-     */
-    public static void rename(String oldFilePath, String newFilePath, boolean overwrite) throws IOException {
-        File oldFile = new File(oldFilePath);
-        File newFile = new File(newFilePath);
-
-        if (newFile.exists()) {
-            if (overwrite) {
-                newFile.delete();
-            } else {
-                final String msg = "FileUtils.File_already_exists " + newFilePath; //$NON-NLS-1$            
-                throw new IOException(msg);
-            }
-        }
-
-        boolean renamed = oldFile.renameTo(newFile);
-
-        //Sometimes file.renameTo will silently fail, for example attempting to rename from different UNIX partitions.
-        //Try to copy instead.
-        if (!renamed) {
-            copy(oldFilePath, newFilePath);
-            oldFile.delete();
-        }
-    }
-    
-    
-    
-    
-
-    public static void remove(String filePath) throws IOException {
-        File file = new File(filePath);
-        if (file.exists()) {
-            file.delete();
-        }  
-    }
-   
-}
\ No newline at end of file

Modified: branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/PropUtils.java
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/PropUtils.java	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/PropUtils.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -4,11 +4,39 @@
 import java.io.InputStream;
 import java.util.Properties;
 
-import org.teiid.test.framework.connection.ConnectionStrategyFactory;
+import org.teiid.test.framework.ConfigPropertyLoader;
 
 public class PropUtils {
 	
 
 
-
+	public static Properties loadProperties(String filename, Properties defaults) {
+	    InputStream in = null;
+		Properties props = new Properties();
+		if (defaults != null) {
+			props.putAll(defaults);
+		} 
+	    try {
+	        in = ConfigPropertyLoader.class.getResourceAsStream(filename);
+	        if (in != null) {
+	        	Properties lprops = new Properties();
+	        	lprops.load(in);
+	        	props.putAll(lprops);
+	        	
+	        }
+	        else {
+	        	throw new RuntimeException("Failed to load properties from file '"+filename+ "' configuration file");
+	        }
+	    } catch (IOException e) {
+	        throw new RuntimeException("Error loading properties from file '"+filename+ "'" + e.getMessage());
+	    } finally {
+		try {
+		    in.close();
+		} catch(Exception e){
+		    
+		}
+	    }
+	    
+	    return props;
+	}
 }

Deleted: branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/StringUtil.java
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/StringUtil.java	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/StringUtil.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -1,906 +0,0 @@
-/*
- * 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.
- *
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved.
- * This code is made available under the terms of the Eclipse Public
- * License, version 1.0.
- */
-
-package org.teiid.test.util;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.regex.Pattern;
-
-/**
- * This is a common place to put String utility methods.
- */
-public final class StringUtil {
-
-    public interface Constants {
-        char CARRIAGE_RETURN_CHAR = '\r';
-        char LINE_FEED_CHAR       = '\n';
-        char NEW_LINE_CHAR        = LINE_FEED_CHAR;
-        char SPACE_CHAR           = ' ';
-        char DOT_CHAR           = '.';
-        char TAB_CHAR             = '\t';
-        
-        String CARRIAGE_RETURN = String.valueOf(CARRIAGE_RETURN_CHAR);
-        String EMPTY_STRING    = ""; //$NON-NLS-1$
-        String DBL_SPACE       = "  "; //$NON-NLS-1$
-        String LINE_FEED       = String.valueOf(LINE_FEED_CHAR);
-        String NEW_LINE        = String.valueOf(NEW_LINE_CHAR);
-        String SPACE           = String.valueOf(SPACE_CHAR);
-        String DOT             = String.valueOf(DOT_CHAR);
-        String TAB             = String.valueOf(TAB_CHAR);
-
-        String[] EMPTY_STRING_ARRAY = new String[0];
-
-        // all patterns below copied from Eclipse's PatternConstructor class.
-        final Pattern PATTERN_BACK_SLASH = Pattern.compile("\\\\"); //$NON-NLS-1$
-        final Pattern PATTERN_QUESTION = Pattern.compile("\\?"); //$NON-NLS-1$
-        final Pattern PATTERN_STAR = Pattern.compile("\\*"); //$NON-NLS-1$
-    }
-
-    /**
-     * The String "'"
-     */
-    public static final String SINGLE_QUOTE = "'"; //$NON-NLS-1$
-
-    /**
-     * The name of the System property that specifies the string that should be used to separate
-     * lines.  This property is a standard environment property that is usually set automatically.
-     */
-    public static final String LINE_SEPARATOR_PROPERTY_NAME = "line.separator"; //$NON-NLS-1$
-
-    /**
-     * The String that should be used to separate lines; defaults to
-     * {@link #NEW_LINE}
-     */
-    public static final String LINE_SEPARATOR = System.getProperty(LINE_SEPARATOR_PROPERTY_NAME, Constants.NEW_LINE);
-
-    public static final Comparator CASE_INSENSITIVE_ORDER = String.CASE_INSENSITIVE_ORDER;
-
-    public static final Comparator CASE_SENSITIVE_ORDER = new Comparator() {
-        /** 
-         * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
-         * @since 4.2
-         */
-        public int compare(Object o1, Object o2) {
-            if ( o1 == o2 ) {
-                return 0;
-            }
-            return ((String)o1).compareTo((String)o2);
-        }
-    };
-    
-    public static String getLineSeparator() {
-        return LINE_SEPARATOR;
-    }
-
-    /**
-     * Utility to return a string enclosed in ''.
-     * Creation date: (12/2/99 12:05:10 PM)
-     */
-    public static String enclosedInSingleQuotes(String aString) {
-    	StringBuffer sb = new StringBuffer();
-    	sb.append(SINGLE_QUOTE);
-    	sb.append(aString);
-    	sb.append(SINGLE_QUOTE);
-    	return sb.toString();
-    }
-    
-    public static String removeChars(final String value, final char[] chars) {
-        final StringBuffer result = new StringBuffer();
-        if (value != null && chars != null && chars.length > 0) {
-            final String removeChars = String.valueOf(chars);
-            for (int i = 0; i < value.length(); i++) {
-                final String character = value.substring(i, i + 1);
-                if (removeChars.indexOf(character) == -1) {
-                    result.append(character);
-                }
-            }
-        } else {
-            result.append(value);
-        }
-        return result.toString();
-    }
-
-	/**
-	 * Join string pieces and separate with a delimiter.  Similar to the perl function of
-	 * the same name.  If strings or delimiter are null, null is returned.  Otherwise, at
-	 * least an empty string will be returned.	 
-	 * @see #split
-	 *
-	 * @param strings String pieces to join
-	 * @param delimiter Delimiter to put between string pieces
-	 * @return One merged string
-	 */
-	public static String join(List strings, String delimiter) {
-		if(strings == null || delimiter == null) {
-			return null;
-		}
-
-		StringBuffer str = new StringBuffer();
-
-		// This is the standard problem of not putting a delimiter after the last
-		// string piece but still handling the special cases.  A typical way is to check every
-		// iteration if it is the last one and skip the delimiter - this is avoided by
-		// looping up to the last one, then appending just the last one.  
-
-		// First we loop through all but the last one (if there are at least 2) and
-		// put the piece and a delimiter after it.  An iterator is used to walk the list.
-		int most = strings.size()-1;
-		if(strings.size() > 1) {
-			Iterator iter = strings.iterator();
-			for(int i=0; i<most; i++) {            
-				str.append(iter.next());
-				str.append(delimiter);
-			}
-		}
-
-		// If there is at least one element, put the last one on with no delimiter after.
-		if(strings.size() > 0) {
-			str.append(strings.get(most));
-		}
-		
-		return str.toString();
-	}
-    
-    /**
-     * Return a stringified version of the array.
-     * @param array the array
-     * @param delim the delimiter to use between array components
-     * @return the string form of the array
-     */
-    public static String toString( final Object[] array, final String delim ) {
-        if ( array == null ) {
-            return ""; //$NON-NLS-1$
-        }
-        if ( array.length == 0 ) {
-            return "[]"; //$NON-NLS-1$
-        }
-        final StringBuffer sb = new StringBuffer();
-        sb.append('[');
-        for (int i = 0; i < array.length; ++i) {
-            if ( i != 0 ) {
-                sb.append(delim);
-            }
-            sb.append(array[i]);
-        }
-        sb.append(']');
-        return sb.toString();
-    }
-    
-    /**
-     * Return a stringified version of the array, using a ',' as a delimiter
-     * @param array the array
-     * @return the string form of the array
-     * @see #toString(Object[], String)
-     */
-    public static String toString( final Object[] array ) {
-        return toString(array,","); //$NON-NLS-1$
-    }
-    
-	/**
-	 * Split a string into pieces based on delimiters.  Similar to the perl function of
-	 * the same name.  The delimiters are not included in the returned strings.
-	 * @see #join
-	 *
-	 * @param str Full string
-	 * @param splitter Characters to split on
-	 * @return List of String pieces from full string
-	 */
-    public static List split(String str, String splitter) {
-        StringTokenizer tokens = new StringTokenizer(str, splitter);
-        ArrayList l = new ArrayList(tokens.countTokens());
-        while(tokens.hasMoreTokens()) {
-            l.add(tokens.nextToken());
-        }
-        return l;
-    }
-    
-    /**
-     * Break a string into pieces based on matching the full delimiter string in the text.
-     * The delimiter is not included in the returned strings.
-     * @param target The text to break up.
-     * @param delimiter The sub-string which is used to break the target.
-     * @return List of String from the target.
-     */
-    public static List splitOnEntireString(String target, String delimiter) {
-        ArrayList result = new ArrayList();
-        if (delimiter.length() > 0) {
-            int index = 0;
-            int indexOfNextMatch = target.indexOf(delimiter);
-            while (indexOfNextMatch > -1) {
-                result.add(target.substring(index, indexOfNextMatch));
-                index = indexOfNextMatch + delimiter.length();
-                indexOfNextMatch = target.indexOf(delimiter, index);
-            }
-            if (index <= target.length()) {
-                result.add(target.substring(index));
-            }
-        } else {
-            result.add(target);
-        }
-        return result;
-    }
-
-	/**
-	 * Split a string into pieces based on delimiters preserving spaces in
-     * quoted substring as on element in the returned list.   The delimiters are
-     * not included in the returned strings.
-	 * @see #join
-	 *
-	 * @param str Full string
-	 * @param splitter Characters to split on
-	 * @return List of String pieces from full string
-	 */
-	public static List splitPreservingQuotedSubstring(String str, String splitter) {
-		ArrayList l = new ArrayList();
-		StringTokenizer tokens = new StringTokenizer(str, splitter);
-        StringBuffer token = new StringBuffer();
-		while(tokens.hasMoreTokens()) {
-            token.setLength(0);
-            token.append(tokens.nextToken());
-            if ( token.charAt(0) == '"' ) {
-                token.deleteCharAt(0);
-                while ( tokens.hasMoreTokens() ) {
-                    token.append(Constants.SPACE + tokens.nextToken()); 
-                    if ( token.charAt(token.length() -1) == '"' ) {
-                        token.deleteCharAt(token.length() - 1);
-                        break;
-                    }
-                }
-            }
-			l.add(token.toString().trim());
-		}
-		return l;				
-	}
-	
-	/*
-	 * Replace a single occurrence of the search string with the replace string
-	 * in the source string. If any of the strings is null or the search string
-	 * is zero length, the source string is returned.
-	 * @param source the source string whose contents will be altered
-	 * @param search the string to search for in source
-	 * @param replace the string to substitute for search if present
-	 * @return source string with the *first* occurrence of the search string
-	 * replaced with the replace string
-	 */
-	public static String replace(String source, String search, String replace) {
-	    if (source != null && search != null && search.length() > 0 && replace != null) {
-	        int start = source.indexOf(search);
-            if (start > -1) {
-                return new StringBuffer(source).replace(start, start + search.length(), replace).toString();
-	        }
-	    }
-	    return source;    
-	}
-
-	/*
-	 * Replace all occurrences of the search string with the replace string
-	 * in the source string. If any of the strings is null or the search string
-	 * is zero length, the source string is returned.
-	 * @param source the source string whose contents will be altered
-	 * @param search the string to search for in source
-	 * @param replace the string to substitute for search if present
-	 * @return source string with *all* occurrences of the search string
-	 * replaced with the replace string
-	 */
-	public static String replaceAll(String source, String search, String replace) {
-	    if (source != null && search != null && search.length() > 0 && replace != null) {
-	        int start = source.indexOf(search);
-	        if (start > -1) {
-		        StringBuffer newString = new StringBuffer(source);
-	            replaceAll(newString, search, replace);
-		        return newString.toString();
-	        }
-	    }
-	    return source;    
-	}
-
-    public static void replaceAll(StringBuffer source, String search, String replace) {
-	    if (source != null && search != null && search.length() > 0 && replace != null) {
-	        int start = source.toString().indexOf(search);
-	        while (start > -1) {
-	            int end = start + search.length();
-                source.replace(start, end, replace);
-	            start = source.toString().indexOf(search, start + replace.length());
-	        }
-	    }
-	}
-
-    /**
-     * Simple static method to tuncate Strings to given length.
-     * @param in the string that may need tuncating.
-     * @param len the lenght that the string should be truncated to.
-     * @return a new String containing chars with length <= len or <code>null</code>
-     * if input String is <code>null</code>.
-     */
-    public static String truncString(String in, int len) {
-        String out = in;
-        if ( in != null && len > 0 && in.length() > len ) {
-            out = in.substring(0, len);
-        }
-        return out;
-    }
-
-    /**
-     * Simple utility method to wrap a string by inserting line separators creating
-     * multiple lines each with length no greater than the user specified maximum.
-     * The method parses the given string into tokens using a space delimiter then
-     * reassembling the tokens into the resulting string while inserting separators
-     * when required.  If the number of characters in a single token is greater
-     * than the specified maximum, the token will not be split but instead the
-     * maximum will be exceeded.
-     * @param str the string that may need tuncating.
-     * @param maxCharPerLine the max number of characters per line
-     * @return a new String containing line separators or the original string
-     * if its length was less than the maximum.
-     */
-    public static String wrap(String str, int maxCharPerLine) {
-        int strLength = str.length();
-        if (strLength > maxCharPerLine) {
-            StringBuffer sb = new StringBuffer(str.length()+(strLength/maxCharPerLine)+1);
-            strLength = 0;
-            List tokens = StringUtil.split(str,Constants.SPACE);
-            Iterator itr = tokens.iterator();
-            while (itr.hasNext()) {
-                String token = (String) itr.next();
-                if ( strLength+token.length() > maxCharPerLine ) {
-//                    sb.append(getLineSeparator());
-                    sb.append(Constants.NEW_LINE);
-                    strLength = 0;
-                }
-                sb.append(token);
-                sb.append(Constants.SPACE);
-                strLength += token.length()+1;
-            }
-            return sb.toString();
-        }
-        return str;
-    }
-
-	/**
-	 * Return the tokens in a string in a list. This is particularly
-	 * helpful if the tokens need to be processed in reverse order. In that case,
-	 * a list iterator can be acquired from the list for reverse order traversal.
-	 *
-	 * @param str String to be tokenized
-	 * @param delimiter Characters which are delimit tokens
-	 * @return List of string tokens contained in the tokenized string
-	 */
-	public static List getTokens(String str, String delimiter) {
-		ArrayList l = new ArrayList();
-		StringTokenizer tokens = new StringTokenizer(str, delimiter);
-		while(tokens.hasMoreTokens()) {
-			l.add(tokens.nextToken());
-		}
-		return l;
-    }
-    
-    /**
-     * Return the number of tokens in a string that are seperated by the delimiter.
-     *
-     * @param str String to be tokenized
-     * @param delimiter Characters which are delimit tokens
-     * @return Number of tokens seperated by the delimiter
-     */
-    public static int getTokenCount(String str, String delimiter) {
-        StringTokenizer tokens = new StringTokenizer(str, delimiter);
-        return tokens.countTokens();
-    }    
-    
-    /**
-     * Return the number of occurrences of token string that occurs in input string.
-     * Note: token is case sensitive.
-     * 
-     * @param input
-     * @param token
-     * @return int
-     */
-    public static int occurrences(String input, String token) {
-        int num = 0;
-        int index = input.indexOf(token);
-        while (index >= 0) {
-            num++;
-            index = input.indexOf(token, index+1);
-        }
-        return num;
-    }
-
-	/**
-	 * Return the last token in the string.
-	 *
-	 * @param str String to be tokenized
-	 * @param delimiter Characters which are delimit tokens
-	 * @return the last token contained in the tokenized string
-	 */
-	public static String getLastToken(String str, String delimiter) {
-        if (str == null) {
-            return Constants.EMPTY_STRING;
-        }
-        int beginIndex = 0;
-        if (str.lastIndexOf(delimiter) > 0) {
-            beginIndex = str.lastIndexOf(delimiter)+1;
-        }
-        return str.substring(beginIndex,str.length());
-    }
-
-	
-	/**
-	 * Return the first token in the string.
-	 *
-	 * @param str String to be tokenized
-	 * @param delimiter Characters which are delimit tokens
-	 * @return the first token contained in the tokenized string
-	 */
-	public static String getFirstToken(String str, String delimiter) {
-        if (str == null) {
-            return Constants.EMPTY_STRING;
-        }
-        int endIndex = str.indexOf(delimiter);
-        if (endIndex < 0) {
-        	endIndex = str.length();
-        }
-        return str.substring(0,endIndex);
-    }
-	
-
-    public static String computePluralForm(String str) {
-        return computePluralForm(str, Constants.EMPTY_STRING);
-    }
-
-    public static String computePluralForm(String str, String defaultValue ) {
-        if ( str == null || str.length() == 0 ) {
-            return defaultValue;
-        }
-        String result = str;
-        if ( result.endsWith("es") ) { //$NON-NLS-1$
-        	// do nothing 
-        } else if ( result.endsWith("ss") || //$NON-NLS-1$
-             result.endsWith("x")  || //$NON-NLS-1$
-             result.endsWith("ch") || //$NON-NLS-1$
-             result.endsWith("sh") ) { //$NON-NLS-1$
-            result = result + "es"; //$NON-NLS-1$
-        } else if ( result.endsWith("y") && ! ( //$NON-NLS-1$
-                    result.endsWith("ay") || //$NON-NLS-1$
-                    result.endsWith("ey") || //$NON-NLS-1$
-                    result.endsWith("iy") || //$NON-NLS-1$
-                    result.endsWith("oy") || //$NON-NLS-1$
-                    result.endsWith("uy") || //$NON-NLS-1$
-                    result.equalsIgnoreCase("any") ) ) { //$NON-NLS-1$
-            result = result.substring(0, result.length()-1) + "ies"; //$NON-NLS-1$
-        } else {
-            result += "s"; //$NON-NLS-1$
-        }
-        return result;
-    }
-    
-    public static String getStackTrace( final Throwable t ) {
-        final ByteArrayOutputStream bas = new ByteArrayOutputStream();
-        final PrintWriter pw = new PrintWriter(bas);
-        t.printStackTrace(pw);
-        pw.close();
-        return bas.toString();
-    }
-
-    /**
-     * Returns whether the specified text represents a boolean value, i.e., whether it equals "true" or "false"
-     * (case-insensitive).
-	 * @since 4.0
-	 */
-	public static boolean isBoolean(final String text) {
-        return (Boolean.TRUE.toString().equalsIgnoreCase(text)  ||  Boolean.FALSE.toString().equalsIgnoreCase(text));
-	}
-    
-    /**<p>
-     * Returns whether the specified text is either empty or null.
-	 * </p>
-     * @param text The text to check; may be null;
-     * @return True if the specified text is either empty or null.
-	 * @since 4.0
-	 */
-	public static boolean isEmpty(final String text) {
-        return (text == null  ||  text.length() == 0);
-	}
-    
-    /**
-     * Returns the index within this string of the first occurrence of the
-     * specified substring. The integer returned is the smallest value 
-     * <i>k</i> such that:
-     * <blockquote><pre>
-     * this.startsWith(str, <i>k</i>)
-     * </pre></blockquote>
-     * is <code>true</code>.
-     *
-     * @param   text  any string.
-     * @param   str   any string.
-     * @return  if the str argument occurs as a substring within text,
-     *          then the index of the first character of the first
-     *          such substring is returned; if it does not occur as a
-     *          substring, <code>-1</code> is returned.  If the text or 
-     *          str argument is null or empty then <code>-1</code> is returned.
-     */
-    public static int indexOfIgnoreCase(final String text, final String str) {
-        if (isEmpty(text)) {
-            return -1;
-        }
-        if (isEmpty(str)) {
-            return -1;
-        }
-        final String lowerText = text.toLowerCase();
-        final String lowerStr  = str.toLowerCase();
-        return lowerText.indexOf(lowerStr);
-    }
-    
-    /**
-     * Tests if the string starts with the specified prefix.
-     *
-     * @param   text     the string to test.
-     * @param   prefix   the prefix.
-     * @return  <code>true</code> if the character sequence represented by the
-     *          argument is a prefix of the character sequence represented by
-     *          this string; <code>false</code> otherwise.      
-     *          Note also that <code>true</code> will be returned if the 
-     *          prefix is an empty string or is equal to the text 
-     *          <code>String</code> object as determined by the 
-     *          {@link #equals(Object)} method. If the text or 
-     *          prefix argument is null <code>false</code> is returned.
-     * @since   JDK1. 0
-     */
-    public static boolean startsWithIgnoreCase(final String text, final String prefix) {
-        if (isEmpty(text)) {
-            return false;
-        }
-        if (prefix == null) {
-            return false;
-        }
-        int textLength   = text.length();
-        int prefixLength = prefix.length();
-        if (prefixLength == 0) {
-            return true;
-        }
-        if (prefixLength > textLength) {
-            return false;
-        }
-        char[] chArray = prefix.toCharArray();
-        for (int i = 0; i != chArray.length; ++i) {
-            char ch1 = chArray[i];
-            char ch2 = text.charAt(i);
-            if (ch1 == ch2 || Character.toLowerCase(ch1) == Character.toLowerCase(ch2)) {
-                // continue
-            } else {
-                return false;
-            }
-        }
-        return true;
-    }
-    
-    /**
-     * Tests if the string ends with the specified suffix.
-     *
-     * @param   text     the string to test.
-     * @param   suffix   the suffix.
-     * @return  <code>true</code> if the character sequence represented by the
-     *          argument is a suffix of the character sequence represented by
-     *          this object; <code>false</code> otherwise. Note that the 
-     *          result will be <code>true</code> if the suffix is the 
-     *          empty string or is equal to this <code>String</code> object 
-     *          as determined by the {@link #equals(Object)} method. If the text or 
-     *          suffix argument is null <code>false</code> is returned.
-     */
-    public static boolean endsWithIgnoreCase(final String text, final String suffix) {
-        if (isEmpty(text)) {
-            return false;
-        }
-        if (suffix == null) {
-            return false;
-        }
-        int textLength   = text.length();
-        int suffixLength = suffix.length();
-        if (suffixLength == 0) {
-            return true;
-        }
-        if (suffixLength > textLength) {
-            return false;
-        }
-        int offset = textLength - suffixLength;
-        char[] chArray = suffix.toCharArray();
-        for (int i = 0; i != chArray.length; ++i) {
-            char ch1 = chArray[i];
-            char ch2 = text.charAt(offset + i);
-            if (ch1 == ch2 || Character.toLowerCase(ch1) == Character.toLowerCase(ch2)) {
-                // continue
-            } else {
-                return false;
-            }
-        }
-        return true;
-    }
- 
-    /**
-     * Determine if the string passed in has all digits as its contents
-     * @param str
-     * @return true if digits; false otherwise
-     */
-    public static boolean isDigits(String str) {
-        for(int i=0; i<str.length(); i++) {
-            if(!StringUtil.isDigit(str.charAt(i))) {
-                return false;
-            }
-        }
-        return true;
-    }
-    //============================================================================================================================
-    // Constructors
-    
-    /**<p>
-     * Prevents instantiation.
-     * </p>
-     * @since 4.0
-     */
-    private StringUtil() {
-    }
-
-    /*
-     * Converts user string to regular expres '*' and '?' to regEx variables.
-     * copied from eclipse's PatternConstructor
-     */
-    static String asRegEx(String pattern) {
-        // Replace \ with \\, * with .* and ? with .
-        // Quote remaining characters
-        String result1 = Constants.PATTERN_BACK_SLASH.matcher(pattern).replaceAll(
-                "\\\\E\\\\\\\\\\\\Q"); //$NON-NLS-1$
-        String result2 = Constants.PATTERN_STAR.matcher(result1).replaceAll(
-                "\\\\E.*\\\\Q"); //$NON-NLS-1$
-        String result3 = Constants.PATTERN_QUESTION.matcher(result2).replaceAll(
-                "\\\\E.\\\\Q"); //$NON-NLS-1$
-        return "\\Q" + result3 + "\\E"; //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    /**
-     * Creates a regular expression pattern from the pattern string (which is
-     * our old 'StringMatcher' format).  Copied from Eclipse's PatternConstructor class.
-     * 
-     * @param pattern
-     *            The search pattern
-     * @param isCaseSensitive
-     *            Set to <code>true</code> to create a case insensitve pattern
-     * @return The created pattern
-     */
-    public static Pattern createPattern(String pattern, boolean isCaseSensitive) {
-        if (isCaseSensitive)
-            return Pattern.compile(asRegEx(pattern));
-        return Pattern.compile(asRegEx(pattern), Pattern.CASE_INSENSITIVE
-                | Pattern.UNICODE_CASE);
-    }
-
-    /**
-     * Removes extraneous whitespace from a string. By it's nature, it will be trimmed also. 
-     * @param raw
-     * @return
-     * @since 5.0
-     */
-    public static String collapseWhitespace(String raw) {
-        StringBuffer rv = new StringBuffer(raw.length());
-
-        StringTokenizer izer = new StringTokenizer(raw, " "); //$NON-NLS-1$
-        while (izer.hasMoreTokens()) {
-            String tok = izer.nextToken();
-            // Added one last check here so we don't append a "space" on the end of the string
-            rv.append(tok);
-            if( izer.hasMoreTokens() ) {
-                rv.append(' ');
-            }
-        } // endwhile
-
-        return rv.toString();
-    }
-    
-    /**
-     * If input == null OR input.length() < desiredLength, pad to desiredLength with spaces.  
-     * If input.length() > desiredLength, chop at desiredLength.
-     * @param input Input text
-     * @param desiredLength Desired length
-     * @return
-     * @since 5.0
-     */    
-    public static String toFixedLength(String input, int desiredLength) {
-        if(input == null) {
-            input = ""; //$NON-NLS-1$
-        }
-        
-        if(input.length() == desiredLength) {
-            return input;
-        }
-        
-        if(input.length() < desiredLength) {
-            StringBuffer str = new StringBuffer(input);
-            int needSpaces = desiredLength - input.length();
-            for(int i=0; i<needSpaces; i++) {
-                str.append(' ');
-            }
-            return str.toString();
-        }
-        
-        // Else too long - chop
-        return input.substring(0, desiredLength);
-    }
-    
-    
-    public static boolean isLetter(char c) {
-        return isBasicLatinLetter(c) || Character.isLetter(c);
-    }
-    public static boolean isDigit(char c) {
-        return isBasicLatinDigit(c) || Character.isDigit(c);
-    }
-    public static boolean isLetterOrDigit(char c) {
-        return isBasicLatinLetter(c) || isBasicLatinDigit(c) || Character.isLetterOrDigit(c);
-    }
-    
-    public static String toUpperCase(String str) {
-        String newStr = convertBasicLatinToUpper(str);
-        if (newStr == null) {
-            return str.toUpperCase();
-        }
-        return newStr;
-    }
-    
-    public static String toLowerCase(String str) {
-        String newStr = convertBasicLatinToLower(str);
-        if (newStr == null) {
-            return str.toLowerCase();
-        }
-        return newStr;
-    }
-    
-    /**
-     * Create a valid filename from the given String.
-     * 
-     * @param str The String to convert to a valid filename.
-     * @param defaultName The default name to use if only special characters exist.
-     * @return String A valid filename.
-     */
-    public static String createFileName(String str) {
-
-      /** Replace some special chars */
-      str = str.replaceAll(" \\| ", "_"); //$NON-NLS-1$ //$NON-NLS-2$
-      str = str.replaceAll(">", "_"); //$NON-NLS-1$ //$NON-NLS-2$
-      str = str.replaceAll(": ", "_"); //$NON-NLS-1$ //$NON-NLS-2$
-      str = str.replaceAll(" ", "_"); //$NON-NLS-1$ //$NON-NLS-2$
-      str = str.replaceAll("\\?", "_"); //$NON-NLS-1$ //$NON-NLS-2$
-      str = str.replaceAll("/", "_"); //$NON-NLS-1$ //$NON-NLS-2$
-      
-      /** If filename only contains of special chars */
-      if (str.matches("[_]+")) //$NON-NLS-1$
-        str = "file"; //$NON-NLS-1$
-
-      return str;
-    }
-    
-    
-    /**
-     * Make the first letter uppercase 
-     * @param str
-     * @return The string with the first letter being changed to uppercase
-     * @since 5.5
-     */
-    public static String firstLetterUppercase(String str) {
-        if(str == null || str.length() == 0) {
-            return null;
-        }
-        if(str.length() == 1) {
-            return str.toUpperCase();
-        }
-        return str.substring(0, 1).toUpperCase() + str.substring(1);
-    }
-    
-    private static String convertBasicLatinToUpper(String str) {
-        char[] chars = str.toCharArray();
-        for (int i = 0; i < chars.length; i++) {
-            if (isBasicLatinLowerCase(chars[i])) {
-                chars[i] = (char)('A' + (chars[i] - 'a'));
-            } else if (!isBasicLatinChar(chars[i])) {
-                return null;
-            }
-        }
-        return new String(chars);
-    }
-    
-    private static String convertBasicLatinToLower(String str) {
-        char[] chars = str.toCharArray();
-        for (int i = 0; i < chars.length; i++) {
-            if (isBasicLatinUpperCase(chars[i])) {
-                chars[i] = (char)('a' + (chars[i] - 'A'));
-            } else if (!isBasicLatinChar(chars[i])) {
-                return null;
-            }
-        }
-        return new String(chars);
-    }
-    
-    private static boolean isBasicLatinUpperCase(char c) {
-        return c >= 'A' && c <= 'Z';
-    }
-    private static boolean isBasicLatinLowerCase(char c) {
-        return c >= 'a' && c <= 'z';
-    }
-    private static boolean isBasicLatinLetter(char c) {
-        return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
-    }
-    private static boolean isBasicLatinDigit(char c) {
-        return c >= '0' && c <= '9';
-    }
-    private static boolean isBasicLatinChar(char c) {
-        return c <= '\u007F';
-    }   
-    
-    /**
-     * Convert the given value to specified type. 
-     * @param value
-     * @param type
-     * @return
-     */
-    @SuppressWarnings("unchecked")
-	public static <T> T valueOf(String value, Class type){
-    	
-    	if(type == String.class) {
-    		return (T) value;
-    	}
-    	else if(type == Boolean.class || type == Boolean.TYPE) {
-    		return (T) Boolean.valueOf(value);
-    	}
-    	else if (type == Integer.class || type == Integer.TYPE) {
-    		return (T) Integer.decode(value);
-    	}
-    	else if (type == Float.class || type == Float.TYPE) {
-    		return (T) Float.valueOf(value);
-    	}
-    	else if (type == Double.class || type == Double.TYPE) {
-    		return (T) Double.valueOf(value);
-    	}
-    	else if (type == Long.class || type == Long.TYPE) {
-    		return (T) Long.decode(value);
-    	}
-    	else if (type == Short.class || type == Short.TYPE) {
-    		return (T) Short.decode(value);
-    	}
-    	else if (type.isAssignableFrom(List.class)) {
-    		return (T)new ArrayList<String>(Arrays.asList(value.split(","))); //$NON-NLS-1$
-    	}
-    	else if (type == Void.class) {
-    		return null;
-    	}
-    	else if (type.isEnum()) {
-    		return (T)Enum.valueOf(type, value);
-    	}
-    	
-    	else if (type.isAssignableFrom(Map.class)) {
-    		List<String> l = Arrays.asList(value.split(",")); //$NON-NLS-1$
-    		Map m = new HashMap<String, String>();
-    		for(String key: l) {
-    			int index = key.indexOf('=');
-    			if (index != -1) {
-    				m.put(key.substring(0, index), key.substring(index+1));
-    			}
-    		}
-    		return (T)m;
-    	}
-
-    	throw new IllegalArgumentException("Conversion from String to "+ type.getName() + " is not supported"); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-}

Copied: branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/StringUtil.java (from rev 1610, trunk/test-integration/db/src/main/java/org/teiid/test/util/StringUtil.java)
===================================================================
--- branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/StringUtil.java	                        (rev 0)
+++ branches/JCA/test-integration/db/src/main/java/org/teiid/test/util/StringUtil.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ *
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved.
+ * This code is made available under the terms of the Eclipse Public
+ * License, version 1.0.
+ */
+
+package org.teiid.test.util;
+
+
+/**
+ * This is a common place to put String utility methods.
+ */
+public final class StringUtil {
+
+
+    
+    public static String removeChars(final String value, final char[] chars) {
+        final StringBuffer result = new StringBuffer();
+        if (value != null && chars != null && chars.length > 0) {
+            final String removeChars = String.valueOf(chars);
+            for (int i = 0; i < value.length(); i++) {
+                final String character = value.substring(i, i + 1);
+                if (removeChars.indexOf(character) == -1) {
+                    result.append(character);
+                }
+            }
+        } else {
+            result.append(value);
+        }
+        return result.toString();
+    }
+
+
+}

Modified: branches/JCA/test-integration/db/src/main/resources/configuration.xml
===================================================================
--- branches/JCA/test-integration/db/src/main/resources/configuration.xml	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/src/main/resources/configuration.xml	2009-12-01 19:45:17 UTC (rev 1612)
@@ -268,7 +268,7 @@
             <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="sun.jdbc.odbc.JdbcOdbcDriver" IsRequired="true"   />
             <PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:odbc:Driver={MicroSoft Excel Driver (*.xls)};DBQ=&lt;filePathToExcelFile&gt;" IsRequired="true"   />
         </ComponentType>
-        <!-- 
+        
         <ComponentType Name="Datadirect DB2 8 Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" LastChangedDate="2008-10-31T10:26:19.928-06:00" CreatedBy="ConfigurationStartup" CreationDate="2008-10-31T10:26:19.928-06:00">
             <PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="com.metamatrix.jdbcx.db2.DB2DataSource" IsRequired="true"   />
             <PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:mmx:db2://&lt;host&gt;:50000;DatabaseName=&lt;databasename&gt;;CollectionID=&lt;collectionid&gt;;PackageName=&lt;packagename&gt;" IsRequired="true"   />            
@@ -294,7 +294,7 @@
             <PropertyDefinition Name="IsXA" DisplayName="Is XA" ShortDescription="Is XA" DefaultValue="true" IsRequired="true" PropertyType="Boolean"   />
             <PropertyDefinition Name="SetCriteriaBatchSize" DisplayName="Max Values in IN Predicate" ShortDescription="Max number of values in an IN Predicate.  Must be &gt;= 0." DefaultValue="250" PropertyType="Integer"  IsExpert="true" />
         </ComponentType>
-        -->                                                                                                                  <ComponentType Name="LDAP Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" LastChangedDate="2008-10-31T10:26:19.946-06:00" CreatedBy="ConfigurationStartup" CreationDate="2008-10-31T10:26:19.946-06:00">
+                                                                                                                       <ComponentType Name="LDAP Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" LastChangedDate="2008-10-31T10:26:19.946-06:00" CreatedBy="ConfigurationStartup" CreationDate="2008-10-31T10:26:19.946-06:00">
             <PropertyDefinition Name="ConnectorTypeClassPath" DisplayName="Connector Type Class Path" ShortDescription="Connector Type classpath (defined by system, do not modify)" DefaultValue="extensionjar:connector_patch.jar;extensionjar:connector-ldap-6.2.0-SNAPSHOT.jar;" IsModifiable="false" />
 			<PropertyDefinition Name="SearchDefaultBaseDN" DisplayName="Default Search Base DN" ShortDescription="Default Base DN for LDAP Searches" IsExpert="true" />
             <PropertyDefinition Name="LdapAdminUserDN" DisplayName="Ldap Admin User DN" ShortDescription="User DN for the LDAP admin account." DefaultValue="cn=&lt;&gt;,ou=&lt;&gt;,dc=&lt;&gt;" IsRequired="true"  />

Modified: branches/JCA/test-integration/db/src/main/resources/ddl/manage_schemas.xml
===================================================================
--- branches/JCA/test-integration/db/src/main/resources/ddl/manage_schemas.xml	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/src/main/resources/ddl/manage_schemas.xml	2009-12-01 19:45:17 UTC (rev 1612)
@@ -23,15 +23,36 @@
 					<isset property="single"/>
 				</not>
 		</condition>
+		
+		<available file="${datasourceloc}" property="external.datasource.dir"/>
 
 	</target>
+
 	
-	<target name="init">
+	<target name="init"
+		depends="check.external.ds.dir, set.local.ds.dir">
+		
 		<mkdir dir="${target.dir}"/>
+
 	</target>
+	
+	
+	<target name="check.external.ds.dir"
+		if="external.datasource.dir">
 		
+		<property name="ds.loc" value="${datasourceloc}"></property>
+
+	</target>
+	
+	<target name="set.local.ds.dir"
+		unless="external.datasource.dir">
+	
+		<property name="ds.loc" value="${resources.dir}/datasources/"></property>
+		
+	</target>
+		
 	<target name="manage.all.schemas" if="all">
-		<echo>Creating all schemas from datasource dir ${resources.dir}</echo>
+		<echo>Creating all schemas from datasource dir ${ds.loc}</echo>
 		<!--
 		This will process each directory located under the refid location. 
 		Its expects the following:
@@ -39,7 +60,7 @@
 			- connection.properties file must exist in the directory to be used 
 		-->
  		<subant genericantfile="${resources.dir}/ddl/run_ddl.xml" inheritall="true"  >
- 			<dirset dir="${resources.dir}/datasources/" />
+ 			<dirset dir="${ds.loc}" />
  			<property name="sql.ddl.dir" value="${resources.dir}/ddl"/>
 			<property name="lib.dir" value="${basedir}/lib"/>
 
@@ -50,14 +71,14 @@
 
 
 	<target name="manage.single.schemas" if="single">
-		<echo>Creating single schema ${single}</echo>
+		<echo>Creating single schema ${ds.loc}/${single}</echo>
 		
-		<available file="${resources.dir}/datasources/${single}" property="dir.exist"/>
-		<fail unless="dir.exist" message="The datasource single was not found at ${resources.dir}/datasources/${single}" />
+		<available file="${ds.loc}/${single}" property="dir.exist"/>
+		<fail unless="dir.exist" message="The datasource single was not found at ${ds.loc}/${single}" />
 
 
 		<ant inheritAll="true" antfile="${resources.dir}/ddl/run_ddl.xml">
-			<property name="basedir" value="${resources.dir}/datasources/${single}"/>
+			<property name="basedir" value="${ds.loc}/${single}"/>
 			<property name="sql.ddl.dir" value="${resources.dir}/ddl"/>
 			<property name="lib.dir" value="${basedir}/lib"/>
 

Modified: branches/JCA/test-integration/db/src/main/resources/ddl/mysql/create_tables.sql
===================================================================
--- branches/JCA/test-integration/db/src/main/resources/ddl/mysql/create_tables.sql	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/src/main/resources/ddl/mysql/create_tables.sql	2009-12-01 19:45:17 UTC (rev 1612)
@@ -1,6 +1,12 @@
 
 -- these tables are used by custom junit test for testing transactions
+create Table g1 (e1 NUMERIC(5) PRIMARY KEY,   e2 varchar(50))ENGINE=INNODB;
+create Table g2 (e1 NUMERIC(5), e2 varchar(50), FOREIGN KEY (e1) REFERENCES g1(e1))ENGINE=INNODB;
 
-create Table g1 (e1 INT PRIMARY KEY,   e2 varchar(50))ENGINE=InnoDB;
-create Table g2 (e1 INT, e2 varchar(50), FOREIGN KEY (e1) REFERENCES g1(e1))ENGINE=InnoDB;
-   
+
+--create Table g1 (e1 NUMERIC(5) PRIMARY KEY,   e2 varchar(50));
+--create Table g2 (e1 NUMERIC(5) REFERENCES g1 (e1), e2 varchar(50));
+
+
+
+   
\ No newline at end of file

Modified: branches/JCA/test-integration/db/src/main/resources/default-config.properties
===================================================================
--- branches/JCA/test-integration/db/src/main/resources/default-config.properties	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/src/main/resources/default-config.properties	2009-12-01 19:45:17 UTC (rev 1612)
@@ -2,10 +2,8 @@
 # Common Properties for everybody
 ##########################################
 
+connection-type=datasource
 
-# local, xa, jndi
-#transaction-type=local
-
 process-batch = 20
 connector-batch = 20
 
@@ -17,13 +15,15 @@
 # properties for Teiid connection
 ##########################################
 #driver=org.teiid.jdbc.TeiidDriver
-driver=org.teiid.jdbc.TeiidDataSource
+driver=com.metamatrix.jdbc.EmbeddedDataSource
 
-URL=jdbc:teiid:Transaction at mm://localhost:31000;user=admin;password=teiid
+#URL=jdbc:teiid:Transaction at mm://localhost:31000
+URL=jdbc:metamatrix:Transaction at target/classes/transactions/transaction.properties;user=admin;password=teiid
 User=admin
 Password=teiid
 DatabaseName=Transaction
-ServerName=localhost
+#ServerName=localhost
+ServerName=target/classes/transactions/transaction.properties
 PortNumber=31000
 application-name=txn-test
 
@@ -41,7 +41,7 @@
 #
 # By providing the numerical order, it indicates which datasource to assign based on the order in the usedatasources property.
 #
-# If -Dusedatasources is not set, then the datasource will be assigned in the order they are calling to obtain a datasource. 
+# If -Dusedatasources is not set, then the datasource will be assigned randomly when obtaining a datasource. 
 #
 #
 
@@ -49,29 +49,5 @@
 pm2=2
 
 
-##########################################
-# For default design of testcases, these properties are in the setup method of the testcase.
-# However, you can create your own version of the config properties file
-# and specify these properties in the config file
-# NOTE:  will need to set the Sytem "config" property in order to override the default-config.properties file
-##########################################
 
 
-#available types (datasource, driver, jndi)
-#connection-type=datasource
-#connection-type=driver
-
-# autocommit applies to local transaction-type only
-# default is true
-#autocommit=false
-
-# AUTO_WRAP_OFF = "OFF" 
-# AUTO_WRAP_ON = "ON"
-# AUTO_WRAP_PESSIMISTIC = "PESSIMISTIC"
-# AUTO_WRAP_OPTIMISTIC = "OPTIMISTIC"
-
-#txnAutoWrap=off
-
-#-----------------------------
-
-

Modified: branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java
===================================================================
--- branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java	2009-12-01 18:51:26 UTC (rev 1611)
+++ branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -1,46 +1,44 @@
-/*
- * Copyright (c) 2000-2007 MetaMatrix, Inc.
- * All rights reserved.
- */
 package org.teiid.test.testcases;
 
-
-
-import java.sql.Connection;
-
-import javax.sql.XAConnection;
-
 import junit.framework.TestCase;
 
+import org.teiid.test.framework.ConfigPropertyLoader;
 import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.connection.ConnectionUtil;
-import org.teiid.test.framework.datasource.DataSourceMgr;
-import org.teiid.test.framework.exception.QueryTestFailedException;
-import org.teiid.test.framework.transaction.TransactionFactory;
 
-public class BaseAbstractTransactionTestCase extends TestCase  {
+public abstract class BaseAbstractTransactionTestCase extends TestCase {
+ 
+    protected TransactionContainer container = null;
 
-	
     public BaseAbstractTransactionTestCase(String name) {
-        super(name);
+	super(name);
+
+	
     }
+        
+    protected abstract TransactionContainer getTransactionContainter();
     
-	@Override
-	protected void setUp() throws Exception {
-		DataSourceMgr.reset();
-	}
     
-    protected TransactionContainer getTransactionContainter() throws QueryTestFailedException {
-    	return TransactionFactory.create(); 
+
+     @Override
+    protected void setUp() throws Exception {
+	// TODO Auto-generated method stub
+	super.setUp();
     }
 
+    @Override
+    protected void tearDown() throws Exception {
+	// TODO Auto-generated method stub
+	super.tearDown();
 
-//    public Connection getSource(String identifier) throws QueryTestFailedException {
-//    	return ConnectionUtil.getSource(identifier);
-//    }    
-//    
-//    public XAConnection getXASource(String identifier) throws QueryTestFailedException {
-//       	return ConnectionUtil.getXASource(identifier);
-//     }     
+    }
 
+
+    protected void addProperty(String key, String value) {
+	
+	ConfigPropertyLoader.getInstance().setProperty(key, value);
+	
+    }
+
+
+
 }

Copied: branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/CommonTransactionTests.java (from rev 1610, trunk/test-integration/db/src/test/java/org/teiid/test/testcases/CommonTransactionTests.java)
===================================================================
--- branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/CommonTransactionTests.java	                        (rev 0)
+++ branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/CommonTransactionTests.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -0,0 +1,604 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.query.AbstractQueryTransactionTest;
+import org.teiid.test.framework.query.QueryExecution;
+import org.teiid.test.framework.transaction.OnWrapTransaction;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+
+/** 
+ * A common test case among many different transaction stuff. 
+ */
+public abstract class CommonTransactionTests extends BaseAbstractTransactionTestCase {
+    
+    public CommonTransactionTests(String name) {
+        super(name);
+    }
+    
+    protected abstract TransactionContainer getTransactionContainter();
+    
+//    void runConcurrentTestCases(int howMany, final String[] sqls) {
+//        
+//        SeparateClient[] clients = new SeparateClient[howMany]; 
+//                       
+//        for(int i = 0; i < howMany; i++) {
+//            AbstractQueryTransactionTest testCase = new AbstractQueryTransactionTest() {
+//                public void testCase() throws Exception {
+//                    execute(sqls);
+//                }
+//            };            
+//            clients[i] = new SeparateClient(getTransactionContainter(), testCase);
+//        }
+//        
+//        for(int i = 0; i < howMany; i++) {
+//            clients[i].start();
+//        }
+//
+//        try {
+//            for(int i = 0; i < howMany; i++) {
+//                clients[i].join();
+//            }
+//        } catch (InterruptedException e) {
+//            // boo
+//        }        
+//    }
+    
+//    static class SeparateClient extends Thread{
+//        TransactionContainer container = null;
+//        AbstractTransactionTestCase testCase = null;
+//        
+//        public SeparateClient(TransactionContainer container, AbstractTransactionTestCase testCase) {
+//            this.container = container;
+//            this.testCase = testCase;
+//        }
+//
+//        public void run() {
+//            this.container.runTransaction(this.testCase);
+//        }
+//    }
+    
+    ///////////////////////////////////////////////////////////////////////////////////////////////
+    //  Single Source - Rows below 500 (for insert/update/delete)
+    ///////////////////////////////////////////////////////////////////////////////////////////////
+    
+    /**
+     * Sources = 1
+     * Commands = 1, Select
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testSingleSourceSelect() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceSelect") {
+            public void testCase() throws Exception {
+                execute("select * from pm1.g1 where pm1.g1.e1 < 100");
+                assertRowCount(100);
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);
+        
+        // there is nothing to verify here..
+    }
+    
+    
+    /**
+     * Sources = 1
+     * Commands = 1, Update
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testSingleSourceUpdate() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceUpdate") {
+            public void testCase() throws Exception {
+                execute("insert into pm1.g1 (e1, e2) values(100, '100')");
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);       
+        
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 = 100");
+        test.assertRowCount(1);
+        test.closeConnection();
+    }
+    
+
+    /**
+     * Sources = 1
+     * Commands = 1, Update(prepared statement)
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testSingleSourcePreparedUpdate() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourcePreparedUpdate") {
+            
+            public void testCase() throws Exception {
+                execute("insert into pm1.g1 (e1, e2) values(?, ?)", new Object[] {new Integer(102), "102"});                
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);
+        
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 = 102");
+        test.assertRowCount(1);
+        test.closeConnection();        
+    }    
+    
+    /**
+     * Sources = 1
+     * Commands = multiple - Success
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit
+     */
+    public void testSingleSourceMultipleCommands() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceMultipleCommands") {
+            public void testCase() throws Exception {
+                
+                execute("delete from pm1.g1 where pm1.g1.e1 >= ?", new Object[] {new Integer(100)});
+                
+                execute("select * from pm1.g1");
+                assertRowCount(100);
+                
+                for (int i = 100; i < 110; i++) {
+                    Integer val = new Integer(i);
+                    execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                    execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                }
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);      
+
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 100");
+        test.assertRowCount(10);
+        test.execute("select * from g2 where e1 >= 100");
+        test.assertRowCount(10);        
+        test.closeConnection();        
+    }
+        
+    /**
+     * Sources = 1
+     * Commands = 1, Select
+     * Batching = Partial Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testSingleSourcePartialProcessing() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourcePartialProcessing") {
+            public void testCase() throws Exception {
+                execute("select * from pm1.g1 where pm1.g1.e1 < 100 limit 10");
+                assertRowCount(10);
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);       
+    }    
+    
+    ///////////////////////////////////////////////////////////////////////////////////////////////
+    //  Multiple Sources     - Rows from 500
+    ///////////////////////////////////////////////////////////////////////////////////////////////
+    
+    /**
+     * Sources = 2
+     * Commands = 1, Select
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testMultipleSourceSelect() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceSelect") {
+            public void testCase() throws Exception {
+                execute("select * from pm1.g1 join pm2.g1 on pm1.g1.e1 = pm2.g1.e1 where pm1.g1.e1 < 100");
+                assertRowCount(100);
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);
+    }
+
+    /**
+     * Sources = 2
+     * Commands = 1, Select
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */    
+    public void testMultipleSourceVirtualSelect() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceVirtualSelect") {
+            public void testCase() throws Exception {
+                execute("select * from vm.g1 where vm.g1.pm1e1 < 100");
+                assertRowCount(100);
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);
+    }    
+    
+    /**
+     * Sources = 2
+     * Commands = 1, Update
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testMultipleSourceUpdate() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceUpdate") {
+            public void testCase() throws Exception {
+                execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(500, '500', 500, '500')");
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);       
+        
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e2 = '500'");
+        test.assertRowCount(1);
+        test.closeConnection();
+        
+        test = new QueryExecution(userTxn.getSource("pm2"));
+        test.execute("select * from g1 where e2 = '500'");
+        test.assertRowCount(1);
+        test.closeConnection();
+    }
+    
+    /**
+     * Sources = 2
+     * Commands = 1, Update
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testMultipleSourceSelectInto() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceSelectInto") {
+            public void testCase() throws Exception {
+                execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(501, '501', 501, '501')");
+                execute("select pm1.g1.e1, pm1.g1.e2 into pm2.g2 from pm1.g1 where pm1.g1.e1 = 501");
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);       
+        
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e2 = '501'");
+        test.assertRowCount(1);
+        test.closeConnection();
+        
+        test = new QueryExecution(userTxn.getSource("pm2"));
+        test.execute("select * from g1 where e2 = '501'");
+        test.assertRowCount(1);
+        test.closeConnection();
+    }    
+    
+    /**
+     * Sources = 2
+     * Commands = 1, Update
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testMultipleSourceBulkRowInsert() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceBulkRowInsert") {
+            public void testCase() throws Exception {
+                for (int i = 100; i < 112; i++) {
+                    Integer val = new Integer(i);
+                    execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});
+                }
+                execute("select pm1.g1.e1, pm1.g1.e2 into pm2.g2 from pm1.g1 where pm1.g1.e1 >= 100");
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);       
+        
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 100 and e1 < 112");
+        test.assertRowCount(12);
+        test.closeConnection();
+        
+        test = new QueryExecution(userTxn.getSource("pm2"));
+        test.execute("select * from g1 where e1 >= 100 and e1 < 112");
+        test.assertRowCount(12);
+        test.execute("select * from g2 where e1 >= 100 and e1 < 112");
+        test.assertRowCount(12);        
+        test.closeConnection();
+    }    
+
+    /**
+     * Sources = 2
+     * Commands = 1, Update(prepared statement)
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testMultipleSourcePreparedUpdate() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourcePreparedUpdate") {
+            public void testCase() throws Exception {
+                Integer value = new Integer(500);
+                execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {value, value.toString(), value, value.toString()});
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);       
+        
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 = 500");
+        test.assertRowCount(1);
+        test.closeConnection();
+        
+        test = new QueryExecution(userTxn.getSource("pm2"));
+        test.execute("select * from g1 where e1 = 500");
+        test.assertRowCount(1);
+        test.closeConnection();        
+    }    
+    
+    
+    /**
+     * Sources = 2
+     * Commands = multiple - Success
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit
+     */
+    public void testMultipleSourceMultipleCommands() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleCommands") {
+            public void testCase() throws Exception {
+                execute("delete from pm1.g2 where e1 >= ?", new Object[] {new Integer(100)});
+                execute("delete from pm1.g1 where e1 >= ?", new Object[] {new Integer(100)});
+                execute("delete from pm2.g2 where e1 >= ?", new Object[] {new Integer(100)});
+                execute("delete from pm2.g1 where e1 >= ?", new Object[] {new Integer(100)});
+                
+                execute("select * from pm1.g1");
+                assertRowCount(100);
+                
+                for (int i = 100; i < 115; i++) {
+                    Integer val = new Integer(i);
+                    execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                    execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                    
+                    execute("insert into pm2.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                    execute("insert into pm2.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});                    
+                }
+                
+                execute("update pm1.g1 set e2='blah' where e1 > 100");
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);      
+
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1")) {
+	    protected boolean compareCaseSensitive() {
+		return false;
+	    }
+        };
+        test.execute("select * from g1 where e1 >= 100 and e1 < 115");
+        test.assertRowCount(15);
+        test.execute("select * from g2 where e1 >= 100 and e1 < 115");
+        test.assertRowCount(15);
+        test.execute("select distinct e2 from g1 where e1 > 100");
+        
+        // NOTE:  if this is an oracle source, it failes because it return varchar2
+        if (userTxn.getSource("pm1").getMetaData().getDatabaseProductName().toLowerCase().indexOf("oracle") > -1) {
+            test.assertResultsSetEquals(new String[] {"e2[varchar2]", "blah"});
+        } else {
+            test.assertResultsSetEquals(new String[] {"e2[varchar]", "blah"});
+        }
+        test.closeConnection();        
+    }
+    
+    /**
+     * Sources = 2
+     * Commands = multiple - Success
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit
+     */
+    public void testMultipleSourceMultipleVirtualCommands() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleVirtualCommands") {
+            public void testCase() throws Exception {
+
+                for (int i = 200; i < 207; i++) {
+                    Integer val = new Integer(i);
+                    execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});
+                    execute("insert into vm.g2 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});                    
+                }
+                
+                execute("update vm.g1 set pm1e2='blah' where pm1e1 >= 200");
+                
+                execute("delete from vm.g2 where vm.g2.pm1e1 >= 205");
+                execute("delete from vm.g1 where vm.g1.pm1e1 >= 205");
+                
+                execute("select * from vm.g1 where pm1e1 >= 200 and pm1e1 < 207");
+                assertRowCount(5);
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);      
+
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1")){
+	    protected boolean compareCaseSensitive() {
+		return false;
+	    }
+        };
+        test.execute("select * from g1 where e1 >= 200 and e1 < 207");
+        test.assertRowCount(5);
+        test.execute("select * from g2 where e1 >= 200 and e1 < 207");
+        test.assertRowCount(5);
+        test.execute("select distinct e2 from g1 where e1 >= 200 and e1 < 207");
+        test.assertResultsSetEquals(new String[] {"e2[varchar2]", "blah"});
+        test.closeConnection();        
+    }    
+        
+    /**
+     * Sources = 2
+     * Commands = multiple - Success
+     * Batching = Full Processing, Single Connector Batch
+     * result = rollback
+     */    
+    public void testMultipleSourceMultipleCommandsCancel() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleCommandsCancel") {
+            
+            public void testCase() throws Exception {
+                Thread t = new Thread("Cancel Thread") {
+                    public void run() {
+                        try {
+                            try {
+                                Thread.sleep(500);
+                                cancelQuery();
+                            } catch (SQLException e) {
+                         //       debug(e.getMessage());
+                            }
+                        } catch (InterruptedException e) {}
+                    }
+                };
+                t.start();
+                executeBatch(getMultipleSourceBatch());
+            }
+           
+            /** 
+             * @see com.metamatrix.transaction.test.framework.AbstractQueryTest#exceptionExpected()
+             */
+            public boolean exceptionExpected() {
+                return true;
+            }
+        };
+        getTransactionContainter().runTransaction(userTxn);
+                
+        // now verify the results (this may finish under one second, then this test is not valid)
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 600 and e1 < 650");
+        test.assertRowCount(0);
+        test.execute("select * from g2 where e1 >= 600 and e1 < 650");
+        test.assertRowCount(0);
+        test.execute("select distinct e2 from g1 where e1 >= 600 and e1 < 650");
+        test.assertRowCount(0);
+        test.closeConnection(); 
+    }
+
+    /**
+     * Sources = 2
+     * Commands = multiple - Success
+     * Batching = Full Processing, Single Connector Batch
+     * result = rollback
+     */    
+    public void testMultipleSourceTimeout() throws Exception{
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceTimeout") {
+            public void testCase() throws Exception {
+                executeBatch(getMultipleSourceBatch(), 1); // time out after 1 sec
+            }
+            
+            public boolean exceptionExpected() {
+                return true;
+            }            
+            
+            public void after() {
+                if (!exceptionOccurred()) {
+                    fail("should have failed with time out exception");
+                }
+                else {
+                    assertTrue(getLastException().getMessage().indexOf("Operation timed out before completion") != -1);
+                }
+            }             
+        };
+        getTransactionContainter().runTransaction(userTxn);
+        
+        // now verify the results (this may finish under one second, then this test is not valid)
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 600 and e1 < 750");
+        test.assertRowCount(0);
+        test.execute("select * from g2 where e1 >= 600 and e1 < 750");
+        test.assertRowCount(0);
+        test.execute("select distinct e2 from g1 where e1 >= 600 and e1 < 750");
+        test.assertRowCount(0);
+        test.closeConnection();         
+    }    
+    
+        
+    static String[] getMultipleSourceBatch() {
+        ArrayList list = new ArrayList();
+        
+        for (int i = 600; i < 750; i++) {
+            list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+            list.add("insert into pm1.g2 (e1, e2) values ("+i+",'"+i+"')");
+            list.add("insert into pm2.g1 (e1, e2) values("+i+",'"+i+"')");
+            list.add("insert into pm2.g2 (e1, e2) values ("+i+",'"+i+"')");                                
+        }
+        
+        list.add("update pm1.g1 set e2='blah' where pm1.g1.e1 >= 600");
+        list.add("update pm2.g1 set e2='blah' where pm2.g1.e1 >= 600");
+        
+        list.add("delete from pm1.g2 where pm1.g2.e1 >= 610");
+        list.add("delete from pm1.g1 where pm1.g1.e1 >= 610");
+        list.add("delete from pm2.g2 where pm2.g2.e1 >= 610");
+        list.add("delete from pm2.g1 where pm2.g1.e1 >= 610");
+        
+        return(String[])list.toArray(new String[list.size()]);
+    }
+    
+    
+    /**
+     * Sources = 2
+     * Commands = 1, Select
+     * Batching = Partial Processing, Single Connector Batch
+     * result = commit 
+     * Note: This is producing the below error some times; however this is SQL Server issue.
+     * http://support.microsoft.com/?kbid=834849
+     */
+    public void xtestMultipleSourcePartialProcessingUsingLimit() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourcePartialProcessingUsingLimit") {
+            public void testCase() throws Exception {
+                execute("select * from vm.g1 where pm1e1 < 100 limit 10");
+                assertRowCount(10);
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);       
+    }  
+
+    /**
+     * Sources = 2
+     * Commands = 1, Select
+     * Batching = Partial Processing, Single Connector Batch
+     * result = commit
+     * Note: This is producing the below error some times; however this is SQL Server issue.
+     * http://support.microsoft.com/?kbid=834849
+     */
+    public void xtestMultipleSourcePartialProcessingUsingMakedep() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourcePartialProcessingUsingMakedep") {
+            public void testCase() throws Exception {
+                execute("select pm1.g1.e1, pm1.g1.e2 from pm1.g1 LEFT OUTER JOIN pm2.g1 MAKENOTDEP ON pm1.g1.e2 = pm2.g1.e2 where pm2.g1.e1 >= 50 and pm2.g1.e1 < 100");
+                assertRowCount(50);
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);       
+    }        
+    
+    
+    
+
+}

Copied: branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionTests.java (from rev 1610, trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionTests.java)
===================================================================
--- branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionTests.java	                        (rev 0)
+++ branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionTests.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -0,0 +1,273 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.query.AbstractQueryTransactionTest;
+import org.teiid.test.framework.query.QueryExecution;
+import org.teiid.test.framework.transaction.LocalTransaction;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+
+
+
+/** 
+ * User Transaction Test is where user handles all the transaction boundaries
+ * so, autocmmit = OFF, and No transaction auto wrapping.
+ */
+public class LocalTransactionTests extends CommonTransactionTests {
+
+
+    public LocalTransactionTests(String testName) {
+        super(testName);
+    }
+    
+
+    @Override
+    protected TransactionContainer getTransactionContainter() {
+	// TODO Auto-generated method stub
+	return new LocalTransaction();
+    }
+    
+    /**
+     * Sources = 1
+     * Commands = multiple - Success
+     * Batching = Full Processing, Single Connector Batch
+     * result = rollback
+     */
+    public void testSingleSourceMultipleCommandsExplicitRollback() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceMultipleCommandsExplicitRollback") {
+            public void testCase() throws Exception {
+                for (int i = 200; i < 220; i++) {
+                    execute("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+                    execute("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
+                }                
+            }
+            
+            public boolean rollbackAllways() {
+                return true;
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);      
+
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 200 and e1 < 220");
+        test.assertRowCount(0);
+        test.execute("select * from g2 where e1 >= 200 and e1 < 220");
+        test.assertRowCount(0);        
+        test.closeConnection();        
+    } 
+    
+    /**
+     * Sources = 1
+     * Commands = multiple - Success
+     * Batching = Full Processing, Single Connector Batch
+     * result = rollback
+     */
+    public void testSingleSourceMultipleCommandsReferentialIntegrityRollback() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceMultipleCommandsReferentialIntegrityRollback") {
+            public void testCase() throws Exception {
+                for (int i = 200; i < 220; i++) {
+                    Integer val = new Integer(i);
+                    execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                    execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                }
+                
+                // force the rollback by trying to insert an invalid row.
+                execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
+            }
+            
+            public boolean exceptionExpected() {
+                return true;
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);      
+
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 200 and e1 < 220");
+        test.assertRowCount(0);
+        test.closeConnection();        
+    }    
+    
+    /**
+     * Sources = 2
+     * Commands = multiple - Success
+     * Batching = Full Processing, Single Connector Batch
+     * result = rollback
+     */
+    public void testMultipleSourceMultipleCommandsExplicitRollback() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleCommandsExplicitRollback") {
+            public void testCase() throws Exception {
+
+                for (int i = 700; i < 720; i++) {
+                    Integer val = new Integer(i);
+                    execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                    execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                    
+                    execute("insert into pm2.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                    execute("insert into pm2.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});                    
+                }                
+            }
+            
+            // force the rollback
+            public boolean rollbackAllways() {
+                return true;
+            }
+            
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);      
+
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 700 and e1 < 720");
+        test.assertRowCount(0);        
+        test.closeConnection();
+        
+        test = new QueryExecution(userTxn.getSource("pm2"));
+        test.execute("select * from g1 where e1 >= 700 and e1 < 720");
+        test.assertRowCount(0);        
+        test.closeConnection();        
+    }
+    
+    /**
+     * Sources = 2
+     * Commands = multiple - Success
+     * Batching = Full Processing, Single Connector Batch
+     * result = rollback
+     */
+    public void testMultipleSourceMultipleCommandsReferentialIntegrityRollback() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleCommandsReferentialIntegrityRollback") {
+            public void testCase() throws Exception {
+
+                for (int i = 700; i < 720; i++) {
+                    Integer val = new Integer(i);
+                    execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                    execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                    
+                    execute("insert into pm2.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                    execute("insert into pm2.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});                    
+                }
+                
+                // force the rollback by trying to insert an invalid row.
+                execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
+            }
+            
+            public boolean exceptionExpected() {
+                return true;
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);      
+
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 700 and e1 < 720");
+        test.assertRowCount(0);
+        test.closeConnection();        
+        
+        test = new QueryExecution(userTxn.getSource("pm2"));
+        test.execute("select * from g1 where e1 >= 700 and e1 < 720");
+        test.assertRowCount(0);        
+        test.closeConnection();        
+    }
+    
+    /**
+     * Sources = 2
+     * Commands = 1, Update
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testMultipleSourceBulkRowInsertRollback() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceBulkRowInsertRollback") {
+            public void testCase() throws Exception {
+                for (int i = 100; i < 120; i++) {
+                    Integer val = new Integer(i);
+                    execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});
+                }
+                execute("select pm1.g1.e1, pm1.g1.e2 into pm2.g2 from pm1.g1 where pm1.g1.e1 >= 100");
+                
+                // force the rollback by trying to insert an invalid row.
+                execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});                
+            }
+            
+            public boolean exceptionExpected() {
+                return true;
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);       
+        
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 100 and e1 < 120");
+        test.assertRowCount(0);
+        test.closeConnection();
+        
+        test = new QueryExecution(userTxn.getSource("pm2"));
+        test.execute("select * from g1 where e1 >= 100 and e1 < 120");
+        test.assertRowCount(0);
+        test.execute("select * from g2 where e1 >= 100 and e1 < 120");
+        test.assertRowCount(0);        
+        test.closeConnection();
+    } 
+    
+    /**
+     * Sources = 2
+     * Commands = multiple - Success
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit
+     */
+    public void testMultipleSourceMultipleVirtualCommandsRollback() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleVirtualCommandsRollback") {
+            public void testCase() throws Exception {
+
+                for (int i = 600; i < 615; i++) {
+                    Integer val = new Integer(i);
+                    execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});
+                    execute("insert into vm.g2 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});                    
+                }
+                
+                execute("update vm.g1 set pm1e2='blah' where pm1e1 >= 605");
+                
+                execute("delete from vm.g2 where vm.g2.pm1e1 >= 610");
+                execute("delete from vm.g1 where vm.g1.pm1e1 >= 610");
+                
+                execute("select * from vm.g1 where pm1e1 >= 600 and pm1e1 < 615");
+                assertRowCount(10);
+                
+                // force the rollback by trying to insert an invalid row.
+                execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});                                
+            }
+            
+            public boolean exceptionExpected() {
+                return true;
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);      
+
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 600 and e1 < 615");
+        test.assertRowCount(0);
+        test.execute("select * from g2 where e1 >= 600 and e1 < 615");
+        test.assertRowCount(0);
+        test.execute("select distinct e2 from g1 where e1 >= 600 and e1 < 615");
+        test.assertRowCount(0);
+        test.closeConnection();        
+    }        
+}

Copied: branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/OffWrapTransactionTests.java (from rev 1610, trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OffWrapTransactionTests.java)
===================================================================
--- branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/OffWrapTransactionTests.java	                        (rev 0)
+++ branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/OffWrapTransactionTests.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -0,0 +1,283 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+import java.util.ArrayList;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.query.AbstractQueryTransactionTest;
+import org.teiid.test.framework.query.QueryExecution;
+import org.teiid.test.framework.transaction.OffWrapTransaction;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+
+public class OffWrapTransactionTests extends BaseAbstractTransactionTestCase {
+    
+   
+ 
+    public OffWrapTransactionTests(String testName) {
+        super(testName);
+    }
+
+    @Override
+    protected TransactionContainer getTransactionContainter() {
+	// TODO Auto-generated method stub
+	return new OffWrapTransaction();
+    }
+    
+    
+
+    /**
+     * Sources = 1
+     * Commands = 1, Select
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testSingleSourceSelect() throws Exception {
+
+	AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceSelect") {
+            public void testCase() throws Exception {
+                execute("select * from pm1.g1 where pm1.g1.e1 < 100");
+                assertRowCount(100);
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);
+    }
+
+
+
+    /**
+     * Sources = 1
+     * Commands = 1, Update
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testSingleSourceUpdate() throws Exception {
+	AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceUpdate") {
+            public void testCase() throws Exception {
+                execute("insert into pm1.g1 (e1, e2) values(100, '100')");
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);       
+
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 = 100");
+        test.assertRowCount(1);
+        test.closeConnection();
+    }
+    
+    /**
+     * Sources = 1
+     * Commands = multiple - Success
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit
+     */
+    public void testSingleSourceMultipleCommands() throws Exception {
+	AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceMultipleCommands") {
+            public void testCase() throws Exception {
+                execute("delete from pm1.g1 where pm1.g1.e1 >= ?", new Object[] {new Integer(100)});
+                execute("select * from pm1.g1");
+                assertRowCount(100);
+                for (int i = 100; i < 110; i++) {
+                    Integer val = new Integer(i);
+                    execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                    execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                }
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);      
+
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 100");
+        test.assertRowCount(10);
+        test.execute("select * from g2 where e1 >= 100");
+        test.assertRowCount(10);        
+        test.closeConnection();        
+    }
+    
+    /**
+     * Sources = 1
+     * Commands = multiple - Success
+     * Batching = Full Processing, Single Connector Batch
+     * result = rollback
+     */
+    public void testSingleSourceMultipleCommandsReferentialIntegrityRollback() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+
+                for (int i = 200; i < 210; i++) {
+                    Integer val = new Integer(i);
+                    execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                    execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                }
+                
+                // force the rollback by trying to insert an invalid row.
+                execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
+            }
+            public boolean exceptionExpected() {
+                return true;
+            }            
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);      
+
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 200");
+        test.assertRowCount(10);
+        test.closeConnection();        
+    }
+    
+    ///////////////////////////////////////////////////////////////////////////////////////////////
+    //  Multiple Sources     - Rows from 500
+    ///////////////////////////////////////////////////////////////////////////////////////////////
+    
+    /**
+     * Sources = 2
+     * Commands = 1, Select
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testMultipleSourceSelect() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+                execute("select * from pm1.g1 join pm2.g1 on pm1.g1.e1 = pm2.g1.e1 where pm1.g1.e1 < 100");
+                assertRowCount(100);
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);
+    }
+    
+    /**
+     * Sources = 2
+     * Commands = 1, Update
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testMultipleSourceUpdate() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+                execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(500, '500', 500, '500')");
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);       
+        
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 = 500");
+        test.assertRowCount(1);
+        test.closeConnection();
+        
+        test = new QueryExecution(userTxn.getSource("pm2"));
+        test.execute("select * from g1 where e1 = 500");
+        test.assertRowCount(1);
+        test.closeConnection();
+    }
+    
+    /**
+     * Sources = 2
+     * Commands = multiple - Success
+     * Batching = Full Processing, Single Connector Batch
+     * result = rollback
+     */
+    public void testMultipleSourceMultipleCommandsReferentialIntegrityRollback() throws Exception {
+
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+
+                for (int i = 700; i < 710; i++) {
+                    Integer val = new Integer(i);
+                    execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                    execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                    
+                    execute("insert into pm2.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                    execute("insert into pm2.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});                    
+                }
+                
+                // force the rollback by trying to insert an invalid row.
+                execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
+            }
+            
+            public boolean exceptionExpected() {
+                return true;
+            }            
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);      
+
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 700 and e1 < 710");
+        test.assertRowCount(10);
+        test.closeConnection();        
+        
+        test = new QueryExecution(userTxn.getSource("pm2"));
+        test.execute("select * from g1 where e1 >= 700 and e1 < 710");
+        test.assertRowCount(10);        
+        test.closeConnection();        
+    }     
+    
+    /**
+     * Sources = 2
+     * Commands = 1, Update
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testMultipleSourceBulkRowInsert() throws Exception {
+
+	
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            ArrayList list = new ArrayList();
+            public void testCase() throws Exception {
+                for (int i = 800; i < 807; i++) {
+                    list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+                    list.add("insert into pm2.g1 (e1, e2) values("+i+",'"+i+"')");
+                }
+                list.add("select pm1.g1.e1, pm1.g1.e2 into pm2.g2 from pm1.g1 where pm1.g1.e1 >= 800");
+                
+                // force the rollback by trying to insert an invalid row.
+                list.add("insert into pm1.g2 (e1, e2) values(9999,'9999')");             
+
+ //               execute((String[])list.toArray(new String[list.size()]));
+                executeBatch((String[])list.toArray(new String[list.size()]), -1);
+            }
+            
+            public boolean exceptionExpected() {
+                return true;
+            }            
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);       
+        
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 800 and e1 < 807");
+        test.assertRowCount(7);
+        test.closeConnection();
+        
+        test = new QueryExecution(userTxn.getSource("pm2"));
+        test.execute("select * from g1 where e1 >= 800 and e1 < 807");
+        test.assertRowCount(7);
+        test.execute("select * from g2 where e1 >= 800 and e1 < 807");
+        test.assertRowCount(7);        
+        test.closeConnection();
+    }     
+}

Copied: branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/OnWrapTransactionTests.java (from rev 1610, trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OnWrapTransactionTests.java)
===================================================================
--- branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/OnWrapTransactionTests.java	                        (rev 0)
+++ branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/OnWrapTransactionTests.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+import java.util.ArrayList;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.query.AbstractQueryTransactionTest;
+import org.teiid.test.framework.query.QueryExecution;
+import org.teiid.test.framework.transaction.OnWrapTransaction;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+
+
+
+public class OnWrapTransactionTests extends CommonTransactionTests {
+
+    public OnWrapTransactionTests(String testName) {
+        super(testName);
+    }
+
+    
+    @Override
+    protected TransactionContainer getTransactionContainter() {
+	// TODO Auto-generated method stub
+	return new OnWrapTransaction();
+    }
+    
+    /**
+     * Sources = 1
+     * Commands = multiple - Success
+     * Batching = Full Processing, Single Connector Batch
+     * result = rollback
+     */
+    public void testSingleSourceMultipleCommandsReferentialIntegrityRollback() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+                for (int i = 200; i < 210; i++) {
+                    Integer val = new Integer(i);
+                    execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                    execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                }
+                
+                // try to rollback, however since this autocommit=on above two are already commited
+                execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
+            }
+            
+            public boolean exceptionExpected() {
+                return true;
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);      
+
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 200 and e1 < 210");
+        test.assertRowCount(10);
+        test.execute("select * from g2 where e1 = 9999");
+        test.assertRowCount(0);        
+        test.closeConnection();        
+    }
+
+
+    /**
+     * Sources = 1
+     * Commands = multiple - Success
+     * Batching = Full Processing, Single Connector Batch
+     * result = rollback
+     */
+    public void testSingleSourceBatchCommandReferentialIntegrityRollback() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+                ArrayList list = new ArrayList();
+                for (int i = 200; i < 210; i++) {
+                    list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+                }
+                
+                // try to rollback, since we are in single batch it must rollback
+                list.add("insert into pm1.g2 (e1, e2) values(9999,'9999')");
+                executeBatch((String[])list.toArray(new String[list.size()]));
+            }
+            
+            public boolean exceptionExpected() {
+                return true;
+            }            
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);      
+
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 200 and e1 < 210");
+        test.assertRowCount(0);
+        test.execute("select * from g2 where e1 = 9999");
+        test.assertRowCount(0);        
+        test.closeConnection();        
+    }    
+    
+    /**
+     * Sources = 2
+     * Commands = 1, Update
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testMultipleSourceBulkRowInsertRollback() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            ArrayList list = new ArrayList();
+            public void testCase() throws Exception {
+                for (int i = 100; i < 110; i++) {
+                    list.add("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values("+i+",'"+i+"',"+i+",'"+i+"')");
+                }
+                list.add("select pm1.g1.e1, pm1.g1.e2 into pm2.g2 from pm1.g1 where pm1.g1.e1 >= 100");
+                
+                // force the rollback by trying to insert an invalid row.
+                list.add("insert into pm1.g2 (e1, e2) values(9999,'9999')");
+                
+                executeBatch((String[])list.toArray(new String[list.size()]));
+            }
+            
+            public boolean exceptionExpected() {
+                return true;
+            }            
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);       
+        
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 100 and e1 < 110");
+        test.assertRowCount(0);
+        test.closeConnection();
+        
+        test = new QueryExecution(userTxn.getSource("pm2"));
+        test.execute("select * from g1 where e1 >= 100 and e1 < 110");
+        test.assertRowCount(0);
+        test.execute("select * from g2 where e1 >= 100 and e1 < 110");
+        test.assertRowCount(0);        
+        test.closeConnection();
+    }     
+}

Copied: branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/OptimisticWrapTransactionTests.java (from rev 1610, trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OptimisticWrapTransactionTests.java)
===================================================================
--- branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/OptimisticWrapTransactionTests.java	                        (rev 0)
+++ branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/OptimisticWrapTransactionTests.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -0,0 +1,491 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+import java.util.ArrayList;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.query.AbstractQueryTransactionTest;
+import org.teiid.test.framework.query.QueryExecution;
+import org.teiid.test.framework.transaction.OptimisticWrapTransaction;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+
+
+/** 
+ * The main thing to test in this is, when the single source should is involved it should work
+ * fine, when multiple sources involved it should fail.
+ */
+public class OptimisticWrapTransactionTests extends BaseAbstractTransactionTestCase {
+
+    public OptimisticWrapTransactionTests(String testName) {
+        super(testName);
+    }
+    
+    protected TransactionContainer getTransactionContainter() {
+        return new OptimisticWrapTransaction();
+    }
+        
+    ///////////////////////////////////////////////////////////////////////////////////////////////
+    //  Single Source - Rows below 500 (for insert/update/delete)
+    ///////////////////////////////////////////////////////////////////////////////////////////////
+    
+    /**
+     * Sources = 1
+     * Commands = 1, Select
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testSingleSourceSelect() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+                execute("select * from pm1.g1 where pm1.g1.e1 < 100");
+                assertRowCount(100);
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);
+    }
+    
+    /**
+     * Sources = 1
+     * Commands = 1, Update(prepared statement)
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testSingleSourcePreparedUpdate() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+                execute("insert into pm1.g1 (e1, e2) values(?, ?)", new Object[] {new Integer(102), "102"});
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);
+        
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 = 102");
+        test.assertRowCount(1);
+        test.closeConnection();        
+    }    
+    
+    /**
+     * Sources = 1
+     * Commands = multiple - Success
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit
+     */
+    public void testSingleSourceMultipleCommands() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+                execute("delete from pm1.g2 where pm1.g2.e1 >= ?", new Object[] {new Integer(100)});
+                execute("delete from pm1.g1 where pm1.g1.e1 >= ?", new Object[] {new Integer(100)});
+                
+                execute("select * from pm1.g1");
+                assertRowCount(100);
+                for (int i = 100; i < 120; i++) {
+                    Integer val = new Integer(i);
+                    execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                    execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                }
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);      
+
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 100 and e1 < 120");
+        test.assertRowCount(20);
+        test.execute("select * from g2 where e1 >= 100 and e1 < 120");
+        test.assertRowCount(20);        
+        test.closeConnection();        
+    }    
+    
+    /**
+     * Sources = 1
+     * Commands = multiple - Success
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit
+     */
+    public void testSingleSourceBatchCommand() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+                ArrayList list = new ArrayList();
+                list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
+                list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
+
+                for (int i = 200; i < 205; i++) {
+                    list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+                    list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
+                }
+                executeBatch((String[])list.toArray(new String[list.size()]));
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);      
+
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 200 and e1 < 205");
+        test.assertRowCount(5);
+        test.execute("select * from g2 where e1 >= 200 and e1 < 205");
+        test.assertRowCount(5);        
+        test.closeConnection();        
+    }     
+    
+    /**
+     * Sources = 1
+     * Commands = 1, Update(prepared statement)
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testSingleSourcePreparedUpdateRollback() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+                execute("insert into pm1.g2 (e1, e2) values(?, ?)", new Object[] {new Integer(9999), "9999"});
+            }
+            
+            public boolean exceptionExpected() {
+                return true;
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);
+        
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g2 where e1 = 9999");
+        test.assertRowCount(0);
+        test.closeConnection();        
+    }     
+    
+    
+    /**
+     * Sources = 1
+     * Commands = multiple - Success
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit
+     */
+    public void testSingleSourceMultipleCommandsRollback() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+                execute("delete from pm1.g2 where pm1.g2.e1 >= ?", new Object[] {new Integer(100)});
+                execute("delete from pm1.g1 where pm1.g1.e1 >= ?", new Object[] {new Integer(100)});
+                
+                execute("select * from pm1.g1");
+                assertRowCount(100);
+                
+                for (int i = 300; i < 310; i++) {
+                    Integer val = new Integer(i);
+                    execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                    execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                }
+                
+                // this will make it rollback
+                execute("insert into pm1.g2 (e1, e2) values(?, ?)", new Object[] {new Integer(9999), "9999"});                
+            }
+            
+            public boolean exceptionExpected() {
+                return true;
+            }
+
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);      
+
+        // now verify the results (since they are not bundled in single command they should be treated individually)
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 300 and e1 < 310");
+        test.assertRowCount(10);
+        test.execute("select * from g2 where e1 >= 300 and e1 < 310");
+        test.assertRowCount(10);      
+        test.execute("select * from g2 where e1 = 9999");
+        test.assertRowCount(0);        
+        test.closeConnection();        
+    }     
+    
+    /**
+     * Sources = 1
+     * Commands = multiple - Success
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit
+     */
+    public void testSingleSourceBatchCommandRollback() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+                ArrayList list = new ArrayList();
+                list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
+                list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
+
+                for (int i = 400; i < 410; i++) {
+                    list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+                    list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
+                }
+
+                // this will make it rollback
+                list.add("insert into pm1.g2 (e1, e2) values(9999, '9999')");                
+                
+                executeBatch((String[])list.toArray(new String[list.size()]));
+            }
+            
+            public boolean exceptionExpected() {
+                return true;
+            }
+
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);      
+
+        // now verify the results (all commands will trated as single under single transaction)
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 400 and e1 < 410");
+        test.assertRowCount(0);
+        test.execute("select * from g2 where e1 >= 400 and e1 < 410");
+        test.assertRowCount(0);      
+        test.execute("select * from g2 where e1 = 9999");
+        test.assertRowCount(0);                
+        test.closeConnection();        
+    }     
+    
+    ///////////////////////////////////////////////////////////////////////////////////////////////
+    //  Multiple Sources     - Rows from 500
+    ///////////////////////////////////////////////////////////////////////////////////////////////
+    
+    /**
+     * Sources = 2
+     * Commands = 1, Select
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testMultipleSourceSelect() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+                execute("select * from pm1.g1 join pm2.g1 on pm1.g1.e1 = pm2.g1.e1 where pm1.g1.e1 < 100");
+                assertRowCount(100);
+            }
+            
+            public void after() {
+                // selects are special case as they will not fail to use multiple sources. The transaction
+                // source count only starts when there are updates to db, so this is OK
+                if (exceptionOccurred()) {
+                    fail("should not have failed to involve multiple sources under optimistic txn");
+                }
+            }            
+        };        
+        
+        // run test  
+        getTransactionContainter().runTransaction(userTxn);
+    }
+    
+    /**
+     * Sources = 2
+     * Commands = 1, Select
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testMultipleSourceUpdate() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+                Integer value = new Integer(500);
+                execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {value, value.toString(), value, value.toString()});
+            }
+            
+            public boolean exceptionExpected() {
+                return true;
+            }
+            
+            public void after() {
+                if (!exceptionOccurred()) {
+                    fail("should have failed to involve multiple sources under optimistic txn");
+                }
+                else {
+                    assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+                }                
+            }
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);
+    }
+    
+    /**
+     * Sources = 2
+     * Commands = multiple - Success
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit
+     */
+    public void testMultipleSourcesBatchCommand() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+                ArrayList list = new ArrayList();                
+                list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
+                list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
+                
+                list.add("delete from pm2.g2 where pm2.g2.e1 >= 100");
+                list.add("delete from pm2.g1 where pm2.g1.e1 >= 100");
+                
+                for (int i = 200; i < 210; i++) {
+                    list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+                    list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
+                    
+                    list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+                    list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");                    
+                }
+                executeBatch((String[])list.toArray(new String[list.size()]));
+            }
+            
+            public void after() {
+                if (!exceptionOccurred()) {
+                    fail("should have failed to involve multiple sources under optimistic txn");
+                }
+                else {
+                    assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+                }                
+            } 
+            
+            public boolean exceptionExpected() {
+                return true;
+            }
+
+        };        
+        
+        getTransactionContainter().runTransaction(userTxn);
+    }     
+    
+    /**
+     * Sources = 2
+     * Commands = 1, Select
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testMultipleSourceVirtualSelect() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+                execute("select * from vm.g1");
+            }
+            
+            public void after() {
+                if (exceptionOccurred()) {
+                    fail("should not have failed to involve multiple sources under optimistic txn");
+                }
+            }            
+        };        
+        
+        getTransactionContainter().runTransaction(userTxn);
+    }
+    
+    /**
+     * Sources = 2
+     * Commands = 1, Select
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testMultipleSourceVirtualProceduralSelect() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+                execute("select * from vm.p1");
+            }
+            
+            public void after() {
+                if (exceptionOccurred()) {
+                    fail("should have failed to involve multiple sources under optimistic txn");
+                }
+            }            
+        };        
+        
+        getTransactionContainter().runTransaction(userTxn);
+    }   
+    
+    /**
+     * Sources = 2
+     * Commands = 1, Select
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testMultipleSourceVirtualProcedure() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+                execute("select * from vm.p2 where vm.p2.e1 = ? and vm.p2.e2 = ?", new Object[] {new Integer(200), "200"});
+            }
+            
+            public boolean exceptionExpected() {
+                return true;
+            }
+            
+            public void after() {
+                if (!exceptionOccurred()) {
+                    fail("should have failed to involve multiple sources under optimistic txn");
+                }
+                else {
+                    assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+                }                
+            }                 
+        };        
+        
+        getTransactionContainter().runTransaction(userTxn);
+    }    
+    
+    public void testMultipleSourceVirtualProceduralSelectWithUpdate() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+                execute("exec vm.p2(?, ?)", new Object[] {new Integer(200), "200"});
+            }
+            
+            public boolean exceptionExpected() {
+                return true;
+            }
+            
+            public void after() {
+                if (!exceptionOccurred()) {
+                    fail("should have failed to involve multiple sources under optimistic txn");
+                }
+                else {
+                    assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+                }                
+            }                 
+        };        
+        
+        getTransactionContainter().runTransaction(userTxn);
+    }    
+    
+    /**
+     * Sources = 2
+     * Commands = 1, Select
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testMultipleSourceVirtualUpdate() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+                execute("delete from vm.g1 where vm.g1.pm1e1 > 100");
+            }
+            
+            public void after() {
+                if (!exceptionOccurred()) {
+                    fail("should have failed to involve multiple sources under optimistic txn");
+                }
+                else {
+                    assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+                }
+            } 
+            
+            public boolean exceptionExpected() {
+                return true;
+            }
+
+        };        
+        
+        getTransactionContainter().runTransaction(userTxn);
+    }     
+}

Copied: branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/PessimisticWrapTransactionTests.java (from rev 1610, trunk/test-integration/db/src/test/java/org/teiid/test/testcases/PessimisticWrapTransactionTests.java)
===================================================================
--- branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/PessimisticWrapTransactionTests.java	                        (rev 0)
+++ branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/PessimisticWrapTransactionTests.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+import java.util.ArrayList;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.query.AbstractQueryTransactionTest;
+import org.teiid.test.framework.query.QueryExecution;
+import org.teiid.test.framework.transaction.PessimisticWrapTransaction;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+
+public class PessimisticWrapTransactionTests extends CommonTransactionTests {
+
+    public PessimisticWrapTransactionTests(String testName) {
+        super(testName);
+    }
+    
+    protected TransactionContainer getTransactionContainter() {
+        return new PessimisticWrapTransaction();
+    }
+    
+    /**
+     * Sources = 1
+     * Commands = multiple - Success
+     * Batching = Full Processing, Single Connector Batch
+     * result = rollback
+     */
+    public void testSingleSourceMultipleCommandsReferentialIntegrityRollback() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+                for (int i = 200; i < 210; i++) {
+                    Integer val = new Integer(i);
+                    execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                    execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+                }
+                
+                // try to rollback, however since this pessimistic above two are already commited
+                execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
+            }
+            
+            public boolean exceptionExpected() {
+                return true;
+            }            
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);      
+
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 200 and e1 < 210");
+        test.assertRowCount(10);
+        test.execute("select * from g2 where e1 = 9999");
+        test.assertRowCount(0);        
+        test.closeConnection();        
+    }
+    
+    /**
+     * Sources = 1
+     * Commands = multiple - Success
+     * Batching = Full Processing, Single Connector Batch
+     * result = rollback
+     */
+    public void testSingleSourceBatchCommandReferentialIntegrityRollback() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            public void testCase() throws Exception {
+                ArrayList list = new ArrayList();
+                for (int i = 200; i < 210; i++) {
+                    list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+                }
+                
+                // try to rollback, since we are in single batch it must rollback
+                list.add("insert into pm1.g2 (e1, e2) values(9999,'9999')");
+                executeBatch((String[])list.toArray(new String[list.size()]));
+            }
+            
+            public boolean exceptionExpected() {
+                return true;
+            }            
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);      
+
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 200 and e1 < 210");
+        test.assertRowCount(0);
+        test.execute("select * from g2 where e1 = 9999");
+        test.assertRowCount(0);        
+        test.closeConnection();        
+    }    
+    
+    /**
+     * Sources = 2
+     * Commands = 1, Update
+     * Batching = Full Processing, Single Connector Batch
+     * result = commit 
+     */
+    public void testMultipleSourceBulkRowInsertRollback() throws Exception {
+        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+            ArrayList list = new ArrayList();
+            public void testCase() throws Exception {
+                for (int i = 100; i < 120; i++) {
+                    list.add("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values("+i+",'"+i+"',"+i+",'"+i+"')");
+                }
+                list.add("select pm1.g1.e1, pm1.g1.e2 into pm2.g2 from pm1.g1 where pm1.g1.e1 >= 100");
+                
+                // force the rollback by trying to insert an invalid row.
+                list.add("insert into pm1.g2 (e1, e2) values(9999,'9999')");
+                
+                executeBatch((String[])list.toArray(new String[list.size()]));
+            }
+            
+            public boolean exceptionExpected() {
+                return true;
+            }            
+        };        
+        
+        // run test
+        getTransactionContainter().runTransaction(userTxn);       
+        
+        // now verify the results
+        AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+        test.execute("select * from g1 where e1 >= 100 and e1 < 120");
+        test.assertRowCount(0);
+        test.closeConnection();
+        
+        test = new QueryExecution(userTxn.getSource("pm2"));
+        test.execute("select * from g1 where e1 >= 100 and e1 < 120");
+        test.assertRowCount(0);
+        test.execute("select * from g2 where e1 >= 100 and e1 < 120");
+        test.assertRowCount(0);        
+        test.closeConnection();
+    }     
+}

Copied: branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/StandaloneGlobalTransactionTests.java (from rev 1610, trunk/test-integration/db/src/test/java/org/teiid/test/testcases/StandaloneGlobalTransactionTests.java)
===================================================================
--- branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/StandaloneGlobalTransactionTests.java	                        (rev 0)
+++ branches/JCA/test-integration/db/src/test/java/org/teiid/test/testcases/StandaloneGlobalTransactionTests.java	2009-12-01 19:45:17 UTC (rev 1612)
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.transaction.StandaloneGlobalTransaction;
+
+
+/** 
+ * This is global transaction test to be used when transaction is external
+ * in places like inside app server
+ */
+public class StandaloneGlobalTransactionTests extends LocalTransactionTests {
+
+    public StandaloneGlobalTransactionTests(String testName) {
+        super(testName);
+    }
+    
+    @Override
+    protected TransactionContainer getTransactionContainter() {
+
+	return new StandaloneGlobalTransaction();
+    }
+    
+
+}



More information about the teiid-commits mailing list