[teiid-commits] teiid SVN: r1353 - in trunk/test-integration/db/src: main/java/org/teiid/test/framework/connection and 7 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Mon Sep 14 23:45:39 EDT 2009


Author: vhalbert at redhat.com
Date: 2009-09-14 23:45:38 -0400 (Mon, 14 Sep 2009)
New Revision: 1353

Modified:
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DatasourceMgr.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java
   trunk/test-integration/db/src/main/resources/datasources/readme.txt
   trunk/test-integration/db/src/main/resources/default-config.properties
   trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java
   trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/SingleDataSourceSetup.java
   trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java
   trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionTest.java
Log:
Teiid 773 - organize integration test - changes to support multiple datasources

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java	2009-09-15 03:08:00 UTC (rev 1352)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java	2009-09-15 03:45:38 UTC (rev 1353)
@@ -9,7 +9,7 @@
 
 import javax.sql.XAConnection;
 
-import org.teiid.test.framework.datasource.DatasourceMgr;
+import org.teiid.test.framework.datasource.DataSourceMgr;
 import org.teiid.test.framework.exception.QueryTestFailedException;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
 import org.teiid.test.framework.connection.ConnectionStrategy;
@@ -19,7 +19,7 @@
 
 public abstract class TransactionContainer {
 	
-		private boolean debug = false;
+		private boolean debug = true;
 		
 	   protected Properties props;
 	   protected ConnectionStrategy connStrategy;
@@ -29,6 +29,7 @@
 	        this.props = new Properties();
 	        this.props.putAll(this.connStrategy.getEnvironment());
 	        
+
 	    }
 	    
 	    
@@ -38,9 +39,9 @@
 	     *
 	     */
 	    protected boolean turnOffTest (int numberofDataSources) {
-	    	boolean rtn =  (numberofDataSources > DatasourceMgr.getInstance().numberOfAvailDataSources());
+	    	boolean rtn =  (numberofDataSources > DataSourceMgr.getInstance().numberOfAvailDataSources());
 	    	if (rtn) {
-	    		System.out.println("Required Number of DataSources is " + numberofDataSources + " but availables sources is " + DatasourceMgr.getInstance().numberOfAvailDataSources());
+	    		System.out.println("Required Number of DataSources is " + numberofDataSources + " but availables sources is " + DataSourceMgr.getInstance().numberOfAvailDataSources());
 	    	}
 	    	return rtn;
 	    } 

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java	2009-09-15 03:08:00 UTC (rev 1352)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java	2009-09-15 03:45:38 UTC (rev 1353)
@@ -14,14 +14,12 @@
 
 import javax.sql.XAConnection;
 
-import org.teiid.test.framework.datasource.DataSource;
-import org.teiid.test.framework.datasource.DatasourceMgr;
 import org.teiid.adminapi.Admin;
 import org.teiid.adminapi.AdminOptions;
-import org.teiid.adminapi.ConnectorBinding;
 import org.teiid.adminapi.Model;
 import org.teiid.adminapi.VDB;
 import org.teiid.connector.jdbc.JDBCPropertyNames;
+import org.teiid.test.framework.datasource.DataSourceMgr;
 import org.teiid.test.framework.exception.QueryTestFailedException;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
 
@@ -215,8 +213,7 @@
 	        		useName = mappedName;
 	        	}
 
-	        	org.teiid.test.framework.datasource.DataSource ds = DatasourceMgr.getInstance().getDatasource(useName);
-//	        	Properties sourceProps = DatasourceMgr.getInstance().getDatasourceProperties(useName);
+	        	org.teiid.test.framework.datasource.DataSource ds = DataSourceMgr.getInstance().getDatasource(useName, m.getName());
 	        	
 	        	if (ds != null) {
 
@@ -233,34 +230,6 @@
 
     		}
     		
-//	        Collection<ConnectorBinding> bindings = api.getConnectorBindingsInVDB("*");
-//	        
-//	        for (Iterator<ConnectorBinding> it=bindings.iterator(); it.hasNext();) {
-//	        	ConnectorBinding cb = it.next();
-//	        	
-//	        	cb.
-//	        	
-//	        	String mappedName = this.env.getProperty(cb.getName());
-//	        	
-//	        	String useName = cb.getName();
-//	        	if(mappedName != null) {
-//	        		useName = mappedName;
-//	        	}
-//	        	
-//	        	Properties sourceProps = DatasourceMgr.getInstance().getDatasourceProperties(useName);
-//	        	
-//	        	if (sourceProps != null) {
-//		        	Properties newprops = new Properties(cb.getProperties());
-//		        	newprops.putAll(sourceProps);
-//		        	api.updateProperties(cb.getName(), "org.teiid.adminapi.ConnectorBinding", newprops);
-//
-//	        	} else {
-//	        		System.err.println("WARNING: ConnectorBinding : " + cb.getName() + " was not updated, the mapped name " + useName + " had no datasource properties defined");
-//	        	}
-//	        	
-//	        	
-//	        	
-//	        }
     	} catch (QueryTestFailedException qt) {
     		throw qt;
     	} catch (Exception t) {

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java	2009-09-15 03:08:00 UTC (rev 1352)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java	2009-09-15 03:45:38 UTC (rev 1353)
@@ -6,10 +6,11 @@
 import javax.sql.XAConnection;
 
 import org.teiid.test.framework.ConfigPropertyLoader;
-import org.teiid.test.framework.datasource.DatasourceMgr;
+import org.teiid.test.framework.datasource.DataSourceMgr;
 import org.teiid.test.framework.exception.QueryTestFailedException;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
 
+// identifier should be the model name that is identfied in the config properties
 public class ConnectionUtil {
 	public static final Connection getSource(String identifier)
 			throws QueryTestFailedException {
@@ -26,8 +27,8 @@
 
 			Properties sourceProps;
 			try {
-				sourceProps = DatasourceMgr.getInstance()
-						.getDatasourceProperties(mappedName);
+				sourceProps = DataSourceMgr.getInstance()
+						.getDatasourceProperties(mappedName, identifier);
 			} catch (QueryTestFailedException e) {
 				throw new TransactionRuntimeException(e);
 			}
@@ -60,8 +61,8 @@
 
 			Properties sourceProps;
 			try {
-				sourceProps = DatasourceMgr.getInstance()
-						.getDatasourceProperties(mappedName);
+				sourceProps = DataSourceMgr.getInstance()
+						.getDatasourceProperties(mappedName, identifier);
 			} catch (QueryTestFailedException e) {
 				throw new TransactionRuntimeException(e);
 			}

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java	2009-09-15 03:08:00 UTC (rev 1352)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java	2009-09-15 03:45:38 UTC (rev 1353)
@@ -22,6 +22,10 @@
 		return name;
 	}
 	
+	public String getGroup() {
+		return group;
+	}
+	
 	public String getType() {
 		return props.getProperty(CONNECTOR_TYPE);
 	}

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DatasourceMgr.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DatasourceMgr.java	2009-09-15 03:08:00 UTC (rev 1352)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DatasourceMgr.java	2009-09-15 03:45:38 UTC (rev 1353)
@@ -6,20 +6,17 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.sql.Connection;
 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 javax.sql.XAConnection;
-
 import org.jdom.Document;
 import org.jdom.Element;
 import org.jdom.JDOMException;
-import org.teiid.test.framework.ConfigPropertyLoader;
-import org.teiid.test.framework.connection.ConnectionStrategyFactory;
 import org.teiid.test.framework.exception.QueryTestFailedException;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
 
@@ -27,7 +24,7 @@
 import com.metamatrix.common.xml.XMLReaderWriterImpl;
 
 /**
- * The DatasourceMgr is responsible for loading and managing the datasource
+ * The DataSourceMgr is responsible for loading and managing the datasource
  * mapping properties file {@see #DATASOURCE_MAPPING_FILE} and the mapped
  * datasource properties files. The {@link #getDatasourceProperties(String)}
  * returns the properties defined for that datasourceid, which is mapped in the
@@ -36,23 +33,28 @@
  * @author vanhalbert
  * 
  */
-public class DatasourceMgr {
+public class DataSourceMgr {
 
 	static final String DIRECTORY = "datasources/";
 	static final String DATASOURCE_MAPPING_FILE = "datasource_mapping.xml";
 
-	private static DatasourceMgr _instance = null;
+	private static DataSourceMgr _instance = null;
 	
-	private Map<String, Map<String, DataSource>>dstypeMap = new HashMap<String, Map<String, DataSource>>();
+	private Map<String, Map<String, DataSource>>dstypeMap = new HashMap<String, Map<String, DataSource>>();  //key=datasourcetype
 
-	private Map<String, DataSource> allDatasourcesMap = new HashMap<String, DataSource>();
+	private Map<String, DataSource> allDatasourcesMap = new HashMap<String, DataSource>();  // key=datasource name
+	
+	private Map<String, DataSource> modelToDatasourceMap = new HashMap<String, DataSource>();  // key=modelname
+	
+	private Set<String> usedDataSources = new HashSet<String>();
 
-	private DatasourceMgr() {
+
+	private DataSourceMgr() {
 	}
 
-	public static synchronized DatasourceMgr getInstance() {
+	public static synchronized DataSourceMgr getInstance() {
 		if (_instance == null) {
-			_instance = new DatasourceMgr();
+			_instance = new DataSourceMgr();
 			try {
 				_instance.loadDataSourceMappings();
 			} catch (QueryTestFailedException e) {
@@ -71,13 +73,31 @@
 		return allDatasourcesMap.size();
 	}
 	
-	public org.teiid.test.framework.datasource.DataSource getDatasource(String datasourceid)
+	public 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 = modelName + "_"+datasourceid;
+		
+		if (modelToDatasourceMap.containsKey(key)) {
+			return modelToDatasourceMap.get(key);
+		} 
 		if (dstypeMap.containsKey(datasourceid)) {
 
 			Map datasources = dstypeMap.get(datasourceid);
-			ds = (DataSource) datasources.values().iterator().next();
+			Iterator<DataSource> it= datasources.values().iterator();
+			while(it.hasNext()) {
+				DataSource checkit = it.next();
+				if (!usedDataSources.contains(checkit.getName())) {
+					usedDataSources.add(checkit.getName());
+					ds = checkit;
+					break;
+				}
+			}
 
 		} else {
 			ds = allDatasourcesMap.get(datasourceid);
@@ -87,26 +107,16 @@
 					+ " is not a defined datasource in the mappings file ");
 
 		}
+		
+		modelToDatasourceMap.put(key, ds);
 		return ds;
 
 	}
 
-	public Properties getDatasourceProperties(String datasourceid)
+	public Properties getDatasourceProperties(String datasourceid, String modelname)
 			throws QueryTestFailedException {
-		DataSource ds = null;
-		if (dstypeMap.containsKey(datasourceid)) {
-			
-			Map datasources = dstypeMap.get(datasourceid);
-			ds = (DataSource)datasources.values().iterator().next();
-			
-		} else {
-			ds = allDatasourcesMap.get(datasourceid);
-		}
-		if (ds == null) {
-			throw new QueryTestFailedException("DatasourceID " + datasourceid
-					+ " is not a defined datasource in the mappings file ");
+		DataSource ds = getDatasource(datasourceid, modelname);
 
-		}
 		return ds.getProperties();
 		
 	}
@@ -183,9 +193,6 @@
 				System.out.println("Loaded datasource " + ds.getName());
 
 			} 
-//			else {
-//				System.out.println("Did not load datasource " + name);
-//			}
 
 	}
 
@@ -194,7 +201,7 @@
 			Properties props = null;
 	
 			try {
-				InputStream in = DatasourceMgr.class.getResourceAsStream("/"
+				InputStream in = DataSourceMgr.class.getResourceAsStream("/"
 						+ filename);
 				if (in != null) {
 					props = new Properties();
@@ -228,7 +235,7 @@
 
 	private static InputStream getInputStream() {
 
-		InputStream in = DatasourceMgr.class.getResourceAsStream("/"
+		InputStream in = DataSourceMgr.class.getResourceAsStream("/"
 				+ DIRECTORY + DATASOURCE_MAPPING_FILE);
 		if (in != null) {
 
@@ -244,16 +251,6 @@
 	static final String DSCONFIG = "datasourceconfig";
 	static final String DATASOURCETYPE = "datasourcetype";
 	static final String DATASOURCE = "datasource";
-	
-//	static class DS_TYPE {
-//
-//		/**
-//		 * This is the name of the Property Element.
-//		 */
-//		public static final String XA_ELEMENT = "xa"; //$NON-NLS-1$
-//		public static final String NONXA_ELEMENT = "nonxa"; //$NON-NLS-1$
-//	
-//	}
 
 	static class Property {
 
@@ -273,11 +270,17 @@
 	}
 
 	public static void main(String[] args) {
-		DatasourceMgr mgr = DatasourceMgr.getInstance();
+		DataSourceMgr mgr = DataSourceMgr.getInstance();
 
 		try {
+			DataSource ds1 = mgr.getDatasource("ds_mysql5", "model1");
+			
+			DataSource ds2 = mgr.getDatasource("ds_mysql5", "model1");
+			if (ds1 != ds2) {
+				throw new RuntimeException("Datasources are not the same");
+			}
 			System.out.println("Value for ds_mysql5: "
-					+ mgr.getDatasourceProperties("ds_mysql5"));
+					+ mgr.getDatasourceProperties("ds_mysql5", "model1"));
 		} catch (QueryTestFailedException e) {
 			e.printStackTrace();
 		}

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java	2009-09-15 03:08:00 UTC (rev 1352)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java	2009-09-15 03:45:38 UTC (rev 1353)
@@ -21,11 +21,11 @@
     public LocalTransaction(ConnectionStrategy strategy) {
         super(strategy);
         
-//        this.props.setProperty(ConnectionStrategy.TXN_AUTO_WRAP, ConnectionStrategy.AUTO_WRAP_OFF);
     }
     
     protected void before(TransactionQueryTest test) {
         try {
+        	debug("Autocommit: " + this.connStrategy.getAutocommit());
             test.getConnection().setAutoCommit(this.connStrategy.getAutocommit());
         } catch (SQLException e) {
             throw new RuntimeException(e);
@@ -33,6 +33,7 @@
     }
     
     protected void after(TransactionQueryTest test) {
+    	boolean exception = false;
         try {            
             if (test.rollbackAllways()|| test.exceptionOccurred()) {
                 test.getConnection().rollback();
@@ -41,14 +42,27 @@
             else {
                 test.getConnection().commit();
             }
-        } catch (SQLException e) {
-            throw new TransactionRuntimeException(e);
+        } catch (SQLException se) {
+        	exception =  true;
+        	// if exception, try to trigger the rollback
+        	try {
+        		test.getConnection().rollback();
+        	} catch (Exception e) {
+        		// do nothing
+        	}
+            throw new TransactionRuntimeException(se);
+            
+            
         } finally {
-            try {
-                test.getConnection().setAutoCommit(true);
-            } catch (SQLException e) {
-                throw new RuntimeException(e);
-            }
+        	// if an exceptio 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);
+	            }
+        	}
         }
     }   
 }

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java	2009-09-15 03:08:00 UTC (rev 1352)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java	2009-09-15 03:45:38 UTC (rev 1353)
@@ -52,9 +52,9 @@
         	transacton = new JNDITransaction(connstrategy);
 
         } else {
-        	new TransactionRuntimeException("Invalid property value of " + type + " for " + TRANSACTION_TYPE );
+        	throw new TransactionRuntimeException("Invalid property value of " + type + " for " + TRANSACTION_TYPE );
         }
-        
+
         return transacton;
     }
     

Modified: trunk/test-integration/db/src/main/resources/datasources/readme.txt
===================================================================
--- trunk/test-integration/db/src/main/resources/datasources/readme.txt	2009-09-15 03:08:00 UTC (rev 1352)
+++ trunk/test-integration/db/src/main/resources/datasources/readme.txt	2009-09-15 03:45:38 UTC (rev 1353)
@@ -8,4 +8,29 @@
 1.	create the directory (if it doesn't exist)
 2.	create (or place) a connection.properties file in the newly created directory.  See the 
 	example_connection.properties in the derby directory as a starting point.
-	
\ No newline at end of file
+
+
+NOTE:  The datasource_mapping.xml has groupings by datasource type.   This is also a mechinism for creating groupings 
+for special usecases.   An example would be to do the following:
+
+-  add 2 different groups to datasource_mapping.xml 
+
+	<datasourcetype name="TestIT">
+		<datasource  name="mysqlmyA">
+			<property name="dir">mysql</property>
+			<property name="connectortype">MySQL JDBC XA Connector</property>		
+		</datasource>
+
+		<datasource  name="oraclemyB">
+			<property name="dir">oracle</property>
+			<property name="connectortype">Oracle JDBC XA Connector</property>		
+		</datasource>
+	</datasourcetype>
+		
+
+-  then, in the config properties file, map the models to each datasourcetype
+
+pm1=mysqlmyA
+pm2=oraclemyB
+
+This force the association between the model and datasource.  
\ No newline at end of file

Modified: trunk/test-integration/db/src/main/resources/default-config.properties
===================================================================
--- trunk/test-integration/db/src/main/resources/default-config.properties	2009-09-15 03:08:00 UTC (rev 1352)
+++ trunk/test-integration/db/src/main/resources/default-config.properties	2009-09-15 03:45:38 UTC (rev 1353)
@@ -25,7 +25,7 @@
 # AUTO_WRAP_PESSIMISTIC = "PESSIMISTIC"
 # AUTO_WRAP_OPTIMISTIC = "OPTIMISTIC"
 
-# txnAutoWrap=
+txnAutoWrap=off
 
 ##########################################
 # properties for MetaMatrix connection
@@ -59,9 +59,12 @@
 #
 #
 
-pm1=nonxa
-pm2=nonxa
+#pm1=nonxa
+#pm2=nonxa
 
+pm1=mysqlA
+pm2=mysqlB
 
 
 
+

Modified: trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java	2009-09-15 03:08:00 UTC (rev 1352)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java	2009-09-15 03:45:38 UTC (rev 1353)
@@ -52,11 +52,13 @@
     }
     
     @Override protected void assignExecutionProperties(Statement stmt) {
-        if (this.executionProperties != null) {           
-            if (stmt instanceof com.metamatrix.jdbc.api.Statement) {
+        if (this.executionProperties != null) {  
+             if (stmt instanceof com.metamatrix.jdbc.api.Statement) {
                 com.metamatrix.jdbc.api.Statement statement = (com.metamatrix.jdbc.api.Statement)stmt;
-                if (this.executionProperties.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP) != null) {
-                    statement.setExecutionProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP, this.executionProperties.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP));
+                String txnautowrap = this.executionProperties.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP);
+                if (txnautowrap != null) {
+                	System.out.println("txnAutoWrap: " + txnautowrap);
+                    statement.setExecutionProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP, txnautowrap);
                 }
                 
                 if (this.executionProperties.getProperty(ExecutionProperties.PROP_FETCH_SIZE) != null) {

Modified: trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/SingleDataSourceSetup.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/SingleDataSourceSetup.java	2009-09-15 03:08:00 UTC (rev 1352)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/SingleDataSourceSetup.java	2009-09-15 03:45:38 UTC (rev 1353)
@@ -59,8 +59,7 @@
         test1.assertRowCount(100);
         test1.execute("select * from g2 ");
         test1.assertRowCount(100);        
-
-         
+        
         System.out.println("SingleDataSourceSetup Completed");
 
         

Modified: trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java	2009-09-15 03:08:00 UTC (rev 1352)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java	2009-09-15 03:45:38 UTC (rev 1353)
@@ -44,11 +44,20 @@
         }
         
         test1.executeBatch(sql1);
+
+        
+        for (int i = 0; i < 100; i++) {
+            sql1[i] = "insert into g2 (e1, e2) values("+i+",'"+i+"')" ;
+        }
+        
+        test1.executeBatch(sql1);
         test1.execute("select * from g1 ");
         test1.assertRowCount(100);
         test1.execute("select * from g2 ");
-        test1.assertRowCount(0);        
+        test1.assertRowCount(100);  
         
+        test1.closeConnection();
+        
         AbstractQueryTest test2 = new QueryExecution(ConnectionUtil.getSource("pm2")); //$NON-NLS-1$
         test2.execute("delete from g2"); //$NON-NLS-1$
         test2.execute("delete from g1");         //$NON-NLS-1$
@@ -61,15 +70,23 @@
         String[] sql2 = new String[100];
         
         for (int i = 0; i < 100; i++) {
+            sql2[i] = "insert into g1 (e1, e2) values("+i+",'"+i+"')" ;
+        }
+        
+        test2.executeBatch(sql2);
+
+        
+        for (int i = 0; i < 100; i++) {
             sql2[i] = "insert into g2 (e1, e2) values("+i+",'"+i+"')" ;
         }
         
         test2.executeBatch(sql2);
         test2.execute("select * from g1 ");
-        test2.assertRowCount(0);
+        test2.assertRowCount(100);
         test2.execute("select * from g2 ");
         test2.assertRowCount(100);        
-        
+ 
+        test2.closeConnection();
         System.out.println("TwoSource Setup Completed");
 
         

Modified: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionTest.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionTest.java	2009-09-15 03:08:00 UTC (rev 1352)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionTest.java	2009-09-15 03:45:38 UTC (rev 1353)
@@ -15,7 +15,7 @@
 
 
 /** 
- * A common SingleSource test case among many different transaction stuff. 
+ * Test cases that require 2 datasources 
  */
 public class TwoSourceTransactionTest extends BaseAbstractTransactionTestCase {
     
@@ -41,6 +41,10 @@
                 assertRowCount(100);
             }
             
+            public int getNumberRequiredDataSources(){
+            	return 2;
+            }
+            
           	public void validateTestCase() throws Exception {
           	}
         };        
@@ -289,7 +293,7 @@
                 test.execute("select * from g2 where e1 >= 100 and e1 < 115");
                 test.assertRowCount(15);
                 test.execute("select distinct e2 from g1 where e1 > 100");
-                test.assertResultsSetEquals(new String[] {"e2[varchar]", "blah"});
+                test.assertResultsSetEquals(new String[] {"e2[VARCHAR]", "blah"});
                 test.closeConnection();  
          	}
  



More information about the teiid-commits mailing list