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

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Tue Oct 6 11:15:16 EDT 2009


Author: vhalbert at redhat.com
Date: 2009-10-06 11:15:15 -0400 (Tue, 06 Oct 2009)
New Revision: 1526

Modified:
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.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/datasource/DataSource.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java
Log:
Teiid 773 -  updated logic to support fine grain control over which datasource type is assigned to which model

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java	2009-10-06 15:13:18 UTC (rev 1525)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java	2009-10-06 15:15:15 UTC (rev 1526)
@@ -1,5 +1,7 @@
 package org.teiid.test.framework;
 
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Properties;
 
 import org.teiid.test.framework.exception.TransactionRuntimeException;
@@ -13,7 +15,7 @@
  * 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 option can be maintained for the duration of a set of tests. 
+ * 		-Dusedatasources ( {@link ConfigPropertyNames#USE_DATASOURCES_PROP} ) option can be maintained for the duration of a set of tests. 
  * 
  * 
  * @author vanhalbert
@@ -28,6 +30,8 @@
 	public static final String DEFAULT_CONFIG_FILE_NAME = "default-config.properties";
 
 	private Properties props = null;
+	
+	private Map<String, String>modelAssignedDatabaseType = new HashMap<String, String>(5);
 
 	private ConfigPropertyLoader() {
 	}
@@ -66,6 +70,14 @@
 	public Properties getProperties() {
 		return props;
 	}
+	
+	public Map getModelAssignedDatabaseTypes() {
+		return this.modelAssignedDatabaseType;
+	}
+	
+	public void setModelAssignedToDatabaseType(String modelname, String dbtype) {
+		this.modelAssignedDatabaseType.put(modelname, dbtype);
+	}
 
 	private void loadProperties(String filename) {
 		

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-10-06 15:13:18 UTC (rev 1525)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java	2009-10-06 15:15:15 UTC (rev 1526)
@@ -61,12 +61,14 @@
 			    	
 			   		// cleanup all defined datasources for the last test and
 	        		// any overrides regarding inclusions and exclusions.
-		    		this.dsfactory.cleanup();
-
+	        		if (dsfactory != null) {
+	        			this.dsfactory.cleanup();
+	        		}
 			    	
 		    		// cleanup all connections created for this test.
-		    		connStrategy.shutdown();
-	        		
+		    		if (connStrategy != null) {
+		    			connStrategy.shutdown();
+		    		}
 	        	}
 	        }
 
@@ -79,15 +81,16 @@
 	        try {  
 	        	
 	           	setUp(test);
+		    	test.setConnectionStrategy(connStrategy);
+
 		    	
-		    	if (test.getNumberRequiredDataSources() > this.dsfactory.getNumberAvailableDataSources()) {
-		    		detail(test.getTestName() + " will not be run, it requires " + test.getNumberRequiredDataSources() + 
-		    				" datasources, but only available is " + this.dsfactory.getNumberAvailableDataSources());
+		    	if (!test.hasRequiredDataSources()) {
 		    		return;
 		    	}
+		    	
+		    	
     	
-		    	test.setConnectionStrategy(connStrategy);
-		       	test.setupDataSource();
+		    	test.setupDataSource();
 
 	        	
 	        	debug("	setConnection");

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java	2009-10-06 15:13:18 UTC (rev 1525)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java	2009-10-06 15:15:15 UTC (rev 1526)
@@ -62,18 +62,16 @@
      void setConnectionStrategy(ConnectionStrategy connStrategy);
      
      /**
-      * The test case has to specify how many sources its using so that the correct
-      * data setup is performed.
-      * @return int is the number of datasources in use
+      * Indicates if the test has the required datasources in order to execute.
+      * If it doesn't have the required datasources, it will be bypassed for execution.
+      * @return true if the test has the required sources to execute
       *
       * @since
       */
-
-     int getNumberRequiredDataSources();
      
+     boolean hasRequiredDataSources();
+   
      
-     
-     
      /**
       * Called by the {@link TransactionContainer} prior to testcase processing so that
       * the responsibility for performing datasource setup can be done

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-10-06 15:13:18 UTC (rev 1525)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java	2009-10-06 15:15:15 UTC (rev 1526)
@@ -79,7 +79,7 @@
     }
     
     private void shutDownSources(Map<String, ConnectionStrategy> sources) {
-       	for (Iterator it=sources.keySet().iterator(); it.hasNext();  ){	        		
+       	for (Iterator<String> it=sources.keySet().iterator(); it.hasNext();  ){	        		
         		ConnectionStrategy cs = sources.get(it.next());
         		try {
         			cs.shutdown();
@@ -114,6 +114,10 @@
     	return env;
     }
     
+    public int getNumberAvailableDataSources() {
+    	return this.dsFactory.getNumberAvailableDataSources();
+    }
+    
     public Map<String, DataSource> getDataSources() {
     	return this.datasources;
     }

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-10-06 15:13:18 UTC (rev 1525)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java	2009-10-06 15:15:15 UTC (rev 1526)
@@ -49,23 +49,7 @@
 		return this.dbtype;
 	}
 	
-	
-	/**
-	 * 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";		
+
 		
-	}
-		
 
 }

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java	2009-10-06 15:13:18 UTC (rev 1525)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java	2009-10-06 15:15:15 UTC (rev 1526)
@@ -16,32 +16,73 @@
 
 /**
  * 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.
- * Otherwise, validation may be validating against a source for which the test didn't run.
+ * 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>
  * 
- * A test has the option of specifying the following properties to control which data sources are / or not used
+ * <p>
+ * Use the {@link ConfigPropertyNames#USE_DATASOURCES_PROP} property to specify a comma delimited ordered list to control which data sources to use. 
  * 
- * <li>{@link ConfigPropertyNames#USE_DATASOURCES_PROP} : is a comma delimited ordered list to control which data sources to use</li>
+ * <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 is an ordered list because based on the model:order mapping in the config.properties file will map to the ordered list
- * respectfully.
+ * 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.
  * 
- * Example:  in the config.properties may specify:
- * 			pm1=1
- * 			pm2=2
+ * 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>
  * 
- * Set ConfigPropertyNames.USE_DATASOURCES_PROP=oracle,sqlserver
+ * Then set property: ConfigPropertyNames.USE_DATASOURCES_PROP=oracle,sqlserver
  * 
- * This indicates that when a datasource is requested for "pm1", then oracle datasource will be returned.  And when a data source
- * for "pm2" is requested, then a data source representing sqlserver will be returned. 
+ * 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.
  * 
- * <li>{@link ConfigPropertyNames#EXCLUDE_DATASBASE_TYPES_PROP} : is a comma delimited list indicating which data sources not use
- * during that specific test.
- * 
+ * 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}";
@@ -50,24 +91,31 @@
 	// contains the names of the datasources when the -Dusedatasources option is used
 	private Map<String, String> useDS = null;
 	
-	private Map<String, DataSource> useDataSources = null;
+	// contains all the datasources available to be used
+	private Map<String, DataSource> availDS = null;
 
 	// map of the datasources assigned to with model
-	private Map<String, DataSource> modelToDatasourceMap = new HashMap<String, DataSource>(); // key
-																								// =
-																								// modelname
-																								// +
-																								// "_"
-																								// +
-																								// datasourceid
+	private Map<String, DataSource> modelToDatasourceMap = new HashMap<String, DataSource>(); // key = modelname 
+	
+	// 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 = config;
+		this.requiredDataBaseTypes = config.getModelAssignedDatabaseTypes();
 		config();
 	}
 
@@ -88,8 +136,21 @@
 		
 		Map<String, DataSource> availDatasources = DataSourceMgr.getInstance().getDataSources();
 		
-		useDataSources = new HashMap<String, DataSource>(availDatasources.size());
+		availDS = new HashMap<String, DataSource>(availDatasources.size());
 		
+		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);
+		}
+
+		
 		String limitdsprop = configprops
 				.getProperty(ConfigPropertyNames.USE_DATASOURCES_PROP);
 		if (limitdsprop != null && limitdsprop.length() > 0 && ! limitdsprop.equalsIgnoreCase(DO_NOT_USE_DEFAULT)) {
@@ -102,46 +163,100 @@
 			int i = 1;
 			for (Iterator<String> it = dss.iterator(); it.hasNext(); i++) {
 				String dssName = it.next();
-				useDS.put(String.valueOf(i), dssName);
 				ds = availDatasources.get(dssName);
 				
-				useDataSources.put(dssName, ds);
+				if (!excludedDBTypes.contains(ds.getDBType())) {
 				
+					useDS.put(String.valueOf(i), dssName);
+				
+					availDS.put(dssName, ds);
+				}
+				
 			}
 
 		} else {
-			useDataSources.putAll(availDatasources);
+			for (Iterator<DataSource> it = availDatasources.values().iterator(); it.hasNext(); ) {
+				DataSource ds = it.next();
+				if (!excludedDBTypes.contains(ds.getDBType())) {
+					availDS.put(ds.getName(), ds);
+			
+				//	availDS.putAll(availDatasources);
+				}
+			}
 		}
 
-		String excludeprop = configprops
-				.getProperty(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP);
+//		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);
+//			
+//			Iterator<DataSource> it = availDS.values().iterator();
+//
+//			// go thru all the datasources and remove those that are excluded
+//			while (it.hasNext()) {
+//				DataSource checkit = it.next();
+//
+//				if (excludedDBTypes.contains(checkit.getDBType())) {
+//					it.remove();
+//					
+//					if (useDS != null) {
+//						useDS
+//					}
+//				} 
+//				
+//				
+//			}
+//			
+//		}
 		
-		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);
+		
+		if (requiredDataBaseTypes != null) {
+			this.hasRequiredDBTypes = true;
 			
-			Iterator<DataSource> it = useDataSources.values().iterator();
+			Iterator<String> rit = this.requiredDataBaseTypes.keySet().iterator();
 
 			// go thru all the datasources and remove those that are excluded
-			while (it.hasNext()) {
-				DataSource checkit = it.next();
+				while (rit.hasNext()) {
+					String modelName = rit.next();
+					String rdbtype = this.requiredDataBaseTypes.get(modelName);
+					
+					Iterator<DataSource> ait = availDS.values().iterator();
 
-				if (excludedDBTypes.contains(checkit.getDBType())) {
-					it.remove();
+					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());
+
+							modelToDatasourceMap.put(modelName, ds);
+							metDBRequiredTypes = true;
+				
+						}
+						
+					}
+					
+					if (!metDBRequiredTypes) {
+						// did find a required dbtype, no need going any further
+						break;
+					}
+					
 				}
-			}
-			
+								
 		}
 		
 		
 	}
 	
 	public int getNumberAvailableDataSources() {
-		return this.useDataSources.size();
+		return (metDBRequiredTypes ? this.availDS.size() :0);
 	}
 
 	public synchronized DataSource getDatasource(String datasourceid,
@@ -155,7 +270,8 @@
 		// corresponds to the same datasource
 		String key = null;
 
-		key = modelName + "_" + datasourceid;
+		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
@@ -164,49 +280,64 @@
 		if (modelToDatasourceMap.containsKey(key)) {
 			return modelToDatasourceMap.get(key);
 		}
+		
+		if (this.hasRequiredDBTypes) {
+			if (this.requiredDataBaseTypes.containsKey(modelName)) {
+				String dbtype = this.requiredDataBaseTypes.get(modelName);
+				
+				Iterator<DataSource> it = availDS.values().iterator();
 
-		if (useDS != null) {
-			String dsname = useDS.get(datasourceid);
-			if (dsname != null) {
-				ds = useDataSources.get(dsname);
-				if (ds == null) {
-					throw new QueryTestFailedException("Datasource name "
-							+ dsname
-							+ " was not found in the allDatasources map");
+				// 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 {
-				throw new QueryTestFailedException("Model:id " + modelName
-						+ ":" + datasourceid
-						+ " did not map to the  usedatasources: "
-						+ useDS.toString());
 
+				
 			}
+			
+		} 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 {
+					throw new QueryTestFailedException("Model:id " + modelName
+							+ ":" + datasourceid
+							+ " did not map to the  usedatasources: "
+							+ useDS.toString());
+	
+				}
+	
 
-			modelToDatasourceMap.put(key, ds);
-			return ds;
-
-		}
-
-		Iterator<DataSource> it = useDataSources.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 (excludedDBTypes != null
-//					&& excludedDBTypes.contains(checkit.getDBType())) {
-//				continue;
-//			}
-
-			if (!assignedDataSources.contains(checkit.getName())) {
-				ds = checkit;
-				assignedDataSources.add(ds.getName());
-				break;
+		} 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) {
@@ -223,7 +354,7 @@
 
 				if (cnt == this.lastassigned) {
 
-					ds = useDataSources.get(dsname);
+					ds = availDS.get(dsname);
 
 					this.lastassigned++;
 					if (lastassigned >= assignedDataSources.size()) {
@@ -243,6 +374,8 @@
 
 		}
 
+		assignedDataSources.add(ds.getName());
+
 		modelToDatasourceMap.put(key, ds);
 		return ds;
 
@@ -287,7 +420,7 @@
 
 		try {
 			
-			DataSource dsfind = factory.getDatasource("2", "model1");
+			DataSource dsfind = factory.getDatasource("2", "model2");
 			if (dsfind == null) {
 				throw new RuntimeException("No datasource was not found as the 2nd datasource");
 				
@@ -335,6 +468,8 @@
 				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");
 				}
 			}
 				
@@ -346,7 +481,71 @@
 					throw new RuntimeException("The process was not able to reassign an already used datasource");
 					
 				}
+				
+				factory.cleanup();
+				
+				
+				// test required database types
+				// test 1 source
 
+				config = ConfigPropertyLoader.createInstance();
+				
+				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();
+				
+				// test required database types
+				// test 2 sources, 1 required and other ANY
+				config = ConfigPropertyLoader.createInstance();
+			
+				
+				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();
+				
+				
+				// test required database types
+				// test 2 sources, 2 required 
+				config = ConfigPropertyLoader.createInstance();
+			
+				
+				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();
 		}

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-10-06 15:13:18 UTC (rev 1525)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java	2009-10-06 15:15:15 UTC (rev 1526)
@@ -35,7 +35,7 @@
     }
     
     protected void after(TransactionQueryTest test) {
- //   	boolean exception = false;
+    	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);
+	            }
+        	}
         }
     }   
     



More information about the teiid-commits mailing list