[teiid-commits] teiid SVN: r1377 - 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
Fri Sep 18 13:49:14 EDT 2009


Author: vhalbert at redhat.com
Date: 2009-09-18 13:49:14 -0400 (Fri, 18 Sep 2009)
New Revision: 1377

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/connection/ConnectionStrategyFactory.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/TransactionFactory.java
Log:
Teiid 773 - organize integration test

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-09-18 17:45:50 UTC (rev 1376)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java	2009-09-18 17:49:14 UTC (rev 1377)
@@ -16,29 +16,32 @@
 		 * The default config file to use when #CONFIG_FILE system property isn't set
 		 */
 		private static final String DEFAULT_CONFIG_FILE_NAME="default-config.properties";
+		
+		private static Properties props = null;
 
-		public static Properties loadConfigurationProperties() {
-			return loadConfiguration();
-		}
-		
-	    private static Properties loadConfiguration() {
+		public synchronized static void loadConfigurationProperties() {
 	        String filename = System.getProperty(CONFIG_FILE);
 	        if (filename == null) {
 	            filename = DEFAULT_CONFIG_FILE_NAME;
 	        }       
 	        
-	        return loadProperties(filename);
-
-	    } 
+	        loadProperties(filename);		}
+		
+		public static String getProperty(String key) {
+			return getProperties().getProperty(key);
+		}
+		
+		public synchronized static Properties getProperties() {
+			return props;
+		}
 	    
-		private static Properties loadProperties(String filename) {
-			Properties props = null;
+		private static void loadProperties(String filename) {
+			props = null;
 		    try {
-		        InputStream in = ConnectionStrategyFactory.class.getResourceAsStream("/"+ filename);
+		        InputStream in = ConfigPropertyLoader.class.getResourceAsStream("/"+ filename);
 		        if (in != null) {
 		        	props = new Properties();
 		        	props.load(in);
-		        	return props;
 		        }
 		        else {
 		        	throw new RuntimeException("Failed to load properties from file '"+filename+ "' configuration file");
@@ -49,12 +52,13 @@
 		}
 		
 		public static void main(String[] args) {
-			Properties props = ConfigPropertyLoader.loadConfigurationProperties();
-			if (props == null || props.isEmpty()) {
+			ConfigPropertyLoader.loadConfigurationProperties();
+			Properties p = ConfigPropertyLoader.getProperties();
+			if (p == null || p.isEmpty()) {
 	        	throw new RuntimeException("Failed to load config properties file");
 		
 			}
-			System.out.println("Loaded Config Properties " + props.toString());
+			System.out.println("Loaded Config Properties " + p.toString());
 
 		}
 	

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-18 17:45:50 UTC (rev 1376)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java	2009-09-18 17:49:14 UTC (rev 1377)
@@ -19,7 +19,7 @@
 
 public abstract class TransactionContainer {
 	
-		private boolean debug = true;
+		private boolean debug = false;
 		
 	   protected Properties props;
 	   protected ConnectionStrategy connStrategy;
@@ -45,6 +45,24 @@
 	    	}
 	    	return rtn;
 	    } 
+	    
+	    
+	    /**
+	     * Returns true when what the test says it needs, in regards to types of data sources (i.e., mysql, oracle,etc), 
+	     * is found in the list of defined datatypes
+	     * An example of returning false would be the following:
+	     * <li>The defined datasources consist of oracle and sqlserver</li>
+	     * <li>The test says it only supports mysql and oracle</li>
+	     * Then the required datasources for the test are not available and therefore, the
+	     * test cannot run.
+	     * 
+	     * @return true if the required datasources are available
+	     *
+	     * @since
+	     */
+	    protected boolean hasRequiredSources() {
+	    	return true;
+	    }
 	    	    
 	    protected void before(TransactionQueryTest test){}
 	    
@@ -53,9 +71,13 @@
 	    public void runTransaction(TransactionQueryTest test) {
 	    	
 	    	if (turnOffTest(test.getNumberRequiredDataSources())) {
-	    		detail("Transaction test: " + test.getTestName() + " will not be run");
+	    		detail("Turn Off Transaction test: " + test.getTestName() + ", doesn't have the number of required datasources");
 		        return;
 
+	    	} else if (!hasRequiredSources()) {
+	    		detail("Turn Off Transaction test: " + test.getTestName() + ",  required datasource types are not available");
+		        return;
+	    		
 	    	}
 	    	
 	    	detail("Start transaction test: " + test.getTestName());

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-09-18 17:45:50 UTC (rev 1376)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java	2009-09-18 17:49:14 UTC (rev 1377)
@@ -59,6 +59,9 @@
 
      int getNumberRequiredDataSources();
      
+     
+     
+     
      /**
       * Called by the {@link TransactionContainer} prior to testcase processing so that
       * the datasource data can be setup for the specific testcase.

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-18 17:45:50 UTC (rev 1376)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java	2009-09-18 17:49:14 UTC (rev 1377)
@@ -220,7 +220,7 @@
 		        	AdminOptions ao = new AdminOptions(AdminOptions.OnConflict.OVERWRITE);
 		        	ao.addOption(AdminOptions.BINDINGS_IGNORE_DECRYPT_ERROR);
 		        	
-		        	api.addConnectorBinding(ds.getName(), ds.getType(), ds.getProperties(), ao);
+		        	api.addConnectorBinding(ds.getName(), ds.getConnectorType(), ds.getProperties(), ao);
 		        	
 		        	api.assignBindingToModel(ds.getName(), vdb.getName(), vdb.getVDBVersion(), m.getName());
 		        	

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java	2009-09-18 17:45:50 UTC (rev 1376)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java	2009-09-18 17:49:14 UTC (rev 1377)
@@ -4,13 +4,12 @@
  */
 package org.teiid.test.framework.connection;
 
-import java.io.IOException;
-import java.io.InputStream;
 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.exception.QueryTestFailedException;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
 
@@ -28,7 +27,6 @@
 	
 	    private static ConnectionStrategyFactory _instance = null;
 	    private ConnectionStrategy strategy = null;
-	    private Properties config = null;
 	    private static Map<String, ConnectionStrategy> sources = null;
 
     
@@ -39,9 +37,8 @@
 	    public static synchronized ConnectionStrategyFactory getInstance()   {
 	        if (_instance == null) {
 	            _instance = new ConnectionStrategyFactory();
-	            Properties p = _instance.loadConfiguration();
 	            try {
-					_instance.initialize(p);
+					_instance.initialize();
 				} catch (QueryTestFailedException e) {
 					// TODO Auto-generated catch block
 					throw new TransactionRuntimeException(e);
@@ -87,35 +84,17 @@
         	
         	strategy.shutdown();
         	strategy = null;
-        	config = null;
-
+ 
 	    }
 	    
-	    public Properties getConfiguration() {
-	        return this.config;
-	    }
-	    
 	    public ConnectionStrategy getConnectionStrategy() {
 	    	return this.strategy;
 	    }
 	    
-	    private Properties loadConfiguration() {
-	    	init();
-	    	
-	        String filename = System.getProperty(CONFIG_FILE);
-	        if (filename == null) {
-	            filename = DEFAULT_CONFIG_FILE_NAME;
-	        }       
-	        
-	        return loadProperties(filename);
+	    private void initialize() throws QueryTestFailedException  {
+	        init();
+	        this.strategy = create(ConfigPropertyLoader.getProperties());	                     
 
-	    } 
-	    
-	    private void initialize(Properties props) throws QueryTestFailedException  {
-	        this.config = props;
-	        
-	        this.strategy = create(props);	                     
-
 	    }
 	        
 	    private ConnectionStrategy create(Properties props) throws QueryTestFailedException  {
@@ -203,22 +182,22 @@
 	    
 	    }
 	    
-		private final Properties loadProperties(String filename) {
-			Properties props = null;
-		    try {
-		        InputStream in = ConnectionStrategyFactory.class.getResourceAsStream("/"+filename);
-		        if (in != null) {
-		        	props = new Properties();
-		        	props.load(in);
-		        	return props;
-		        }
-		        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());
-		    }
-		}
+//		private final Properties loadProperties(String filename) {
+//			Properties props = null;
+//		    try {
+//		        InputStream in = ConnectionStrategyFactory.class.getResourceAsStream("/"+filename);
+//		        if (in != null) {
+//		        	props = new Properties();
+//		        	props.load(in);
+//		        	return props;
+//		        }
+//		        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());
+//		    }
+//		}
 		
 		public static void main(String[] args) {
 			ConnectionStrategyFactory cf = ConnectionStrategyFactory.getInstance();

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-18 17:45:50 UTC (rev 1376)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java	2009-09-18 17:49:14 UTC (rev 1377)
@@ -15,9 +15,7 @@
 	public static final Connection getSource(String identifier)
 			throws QueryTestFailedException {
 		if (identifier != null) {
-			Properties props = ConfigPropertyLoader
-					.loadConfigurationProperties();
-			String mappedName = props.getProperty(identifier);
+			String mappedName = ConfigPropertyLoader.getProperty(identifier);
 
 			if (mappedName == null) {
 				throw new TransactionRuntimeException("Identifier mapping "
@@ -49,9 +47,7 @@
 	public static final XAConnection getXASource(String identifier)
 			throws QueryTestFailedException {
 		if (identifier != null) {
-			Properties props = ConfigPropertyLoader
-					.loadConfigurationProperties();
-			String mappedName = props.getProperty(identifier);
+			String mappedName = ConfigPropertyLoader.getProperty(identifier);
 
 			if (mappedName == null) {
 				throw new TransactionRuntimeException("Identifier mapping "

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-18 17:45:50 UTC (rev 1376)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java	2009-09-18 17:49:14 UTC (rev 1377)
@@ -1,20 +1,30 @@
 package org.teiid.test.framework.datasource;
 
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Properties;
 
 public class DataSource {
+	public static final String CONNECTOR_TYPE="connectortype";
 	public static final String DIRECTORY="dir";
-	public static final String CONNECTOR_TYPE="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;
 	
 	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();
 	}
 
 	
@@ -26,7 +36,7 @@
 		return group;
 	}
 	
-	public String getType() {
+	public String getConnectorType() {
 		return props.getProperty(CONNECTOR_TYPE);
 	}
 	
@@ -38,6 +48,91 @@
 		return this.props;
 	}
 	
+	public boolean isOfDBType(String type) {
+		return (this.dbtype.equalsIgnoreCase(type));
+	}
 	
+	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";		
+		
+	}
+	
+	
+	/**
+	 * 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
+		
+	}
+	// 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 void setBitMask() {
+		int rtn = ExclusionTypeBitMask.NONE_EXCLUDED;
+		
+		String bitmask = dbtypeBitMaskMap.get(dbtype);
+		if (bitmask == null) {
+			bitMask = rtn;
+		} else {
+			bitMask =  new Integer(bitmask).intValue();
+		}
+	}
+	
 
 }

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-18 17:45:50 UTC (rev 1376)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java	2009-09-18 17:49:14 UTC (rev 1377)
@@ -34,8 +34,10 @@
  * 
  */
 public class DataSourceMgr {
+	
 
-	static final String DIRECTORY = "datasources/";
+
+	static final String RELATIVE_DIRECTORY = "datasources/";
 	static final String DATASOURCE_MAPPING_FILE = "datasource_mapping.xml";
 
 	private static DataSourceMgr _instance = null;
@@ -44,9 +46,11 @@
 
 	private Map<String, DataSource> allDatasourcesMap = new HashMap<String, DataSource>();  // key=datasource name
 	
-	private Map<String, DataSource> modelToDatasourceMap = new HashMap<String, DataSource>();  // key=modelname
+	private Map<String, DataSource> modelToDatasourceMap = new HashMap<String, DataSource>();  // key=modelname + "_" + datasourcename
+																								// key=modelname + "_" + groupname
 	
-	private Set<String> usedDataSources = new HashSet<String>();
+	// this set is use to track datasources that have already been assigned
+	private Set<String> assignedDataSources = new HashSet<String>();
 
 
 	private DataSourceMgr() {
@@ -73,6 +77,55 @@
 		return allDatasourcesMap.size();
 	}
 	
+	/**
+	 * 
+	 * 
+	 * @param dsidentifier is the DataSource identifier that is defined in the config properties
+	 * @param excludeDSBitMask is a bit mask that indicates with DataSources to be excluded
+	 * @param numDSRequired indicates the number of datasources that are required for the test
+	 * @return
+	 *
+	 * @since
+	 */
+	public boolean hasAvailableDataSource(String dsidentifier, int excludeDSBitMask) {
+		
+		// no datasources are excluded
+		if (excludeDSBitMask == DataSource.ExclusionTypeBitMask.NONE_EXCLUDED) {			
+			return true;
+		}
+		
+		if (dstypeMap.containsKey(dsidentifier)) {
+			Map datasources = dstypeMap.get(dsidentifier);
+			Iterator<DataSource> it= datasources.values().iterator();
+			while(it.hasNext()) {
+				DataSource ds = it.next();
+				int dsbitmask = ds.getBitMask();
+				
+				if ((excludeDSBitMask & dsbitmask) == dsbitmask) {
+					
+				} else {
+					return true;
+				}
+				
+			}
+			return false;
+		} else {
+			DataSource ds = allDatasourcesMap.get(dsidentifier);
+			if (ds == null) {
+				return false;
+			}
+			
+			int dsbitmask = ds.getBitMask();
+			if ((excludeDSBitMask & dsbitmask) == dsbitmask) {
+				return false;
+			} 
+			
+			return true;
+			
+		}
+
+	}
+	
 	public DataSource getDatasource(String datasourceid, String modelName)
 			throws QueryTestFailedException {
 		DataSource ds = null;
@@ -81,33 +134,57 @@
 		// 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;
+		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
 		if (modelToDatasourceMap.containsKey(key)) {
 			return modelToDatasourceMap.get(key);
 		} 
+
+		
 		if (dstypeMap.containsKey(datasourceid)) {
 
 			Map datasources = dstypeMap.get(datasourceid);
 			Iterator<DataSource> it= datasources.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 (!usedDataSources.contains(checkit.getName())) {
-					usedDataSources.add(checkit.getName());
-					ds = checkit;
-					break;
+				String dskey = modelName + "_"+checkit.getName();
+				if (modelToDatasourceMap.containsKey(dskey)) {
+					return modelToDatasourceMap.get(dskey);
+				} else if (ds == null) {
+					if (!assignedDataSources.contains(checkit.getName())) {
+						ds = checkit;
+						key = dskey;
+					}
+
 				}
 			}
+			
+			if (ds != null) {
+				assignedDataSources.add(ds.getName());
+				
+				modelToDatasourceMap.put(key, ds);
+				
+			}
 
+
 		} else {
 			ds = allDatasourcesMap.get(datasourceid);
+
 		}
 		if (ds == null) {
 			throw new QueryTestFailedException("DatasourceID " + datasourceid
 					+ " is not a defined datasource in the mappings file ");
 
 		}
-		
+
 		modelToDatasourceMap.put(key, ds);
 		return ds;
 
@@ -145,7 +222,6 @@
 		
 		for (Iterator<Element> it = rootElements.iterator(); it.hasNext();) {
 			Element type = it.next();
-//			System.out.println("Loading ds transactional type  " + type.getName());
 			String typename = type.getAttributeValue(Property.Attributes.NAME);
 
 			List<Element> typeElements = type.getChildren();
@@ -154,7 +230,6 @@
 
 				for (Iterator<Element> typeit = typeElements.iterator(); typeit.hasNext();) {
 					Element e = typeit.next();
-//					System.out.println("Loading ds type  " + e.getName());
 					addDataSource(e, typename, datasources);				
 				}	
 				dstypeMap.put(typename, datasources);
@@ -170,7 +245,7 @@
 					"No Datasources were found in the mappings file");
 		}
 		
-		System.out.println("Number of datasource types loaded " + dstypeMap.size());
+		System.out.println("Number of datasource groups loaded " + dstypeMap.size());
 		System.out.println("Number of total datasource mappings loaded " + allDatasourcesMap.size());
 
 
@@ -182,7 +257,7 @@
 			Properties props = getProperties(element);
 			
 			String dir = props.getProperty(DataSource.DIRECTORY);
-			String dsfile = DIRECTORY + dir + "/connection.properties";
+			String dsfile = RELATIVE_DIRECTORY + dir + "/connection.properties";
 			Properties dsprops = loadProperties(dsfile);
 			if (dsprops != null) {
 				props.putAll(dsprops);
@@ -236,13 +311,13 @@
 	private static InputStream getInputStream() {
 
 		InputStream in = DataSourceMgr.class.getResourceAsStream("/"
-				+ DIRECTORY + DATASOURCE_MAPPING_FILE);
+				+ RELATIVE_DIRECTORY + DATASOURCE_MAPPING_FILE);
 		if (in != null) {
 
 			return in;
 		} else {
 			throw new RuntimeException(
-					"Failed to load datasource mapping file '" + DIRECTORY
+					"Failed to load datasource mapping file '" + RELATIVE_DIRECTORY
 							+ DATASOURCE_MAPPING_FILE + "'");
 		}
 
@@ -270,17 +345,35 @@
 	}
 
 	public static void main(String[] args) {
+		
+		
 		DataSourceMgr mgr = DataSourceMgr.getInstance();
 
 		try {
-			DataSource ds1 = mgr.getDatasource("ds_mysql5", "model1");
+			DataSource ds1 = mgr.getDatasource("ds_mysql", "model1");
 			
-			DataSource ds2 = mgr.getDatasource("ds_mysql5", "model1");
+			DataSource ds2 = mgr.getDatasource("nonxa", "model1");
 			if (ds1 != ds2) {
 				throw new RuntimeException("Datasources are not the same");
 			}
-			System.out.println("Value for ds_mysql5: "
-					+ mgr.getDatasourceProperties("ds_mysql5", "model1"));
+			System.out.println("Value for ds_mysql: "
+					+ mgr.getDatasourceProperties("ds_mysql", "model1"));
+			
+			boolean shouldbeavail = mgr.hasAvailableDataSource("nonxa", DataSource.ExclusionTypeBitMask.ORACLE);
+			if (!shouldbeavail) {
+				throw new RuntimeException("Should have found one available");
+			}
+			
+			shouldbeavail = mgr.hasAvailableDataSource("nonxa", DataSource.ExclusionTypeBitMask.ORACLE | DataSource.ExclusionTypeBitMask.MYSQL);
+			if (!shouldbeavail) {
+				throw new RuntimeException("Should have found one available");
+			}
+
+			
+			boolean shouldnot = mgr.hasAvailableDataSource("nonxa", DataSource.ExclusionTypeBitMask.ORACLE | DataSource.ExclusionTypeBitMask.MYSQL | DataSource.ExclusionTypeBitMask.SQLSERVER);
+			if (shouldnot) {
+				throw new RuntimeException("Should NOT have found one available");
+			}
 		} catch (QueryTestFailedException e) {
 			e.printStackTrace();
 		}

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-18 17:45:50 UTC (rev 1376)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java	2009-09-18 17:49:14 UTC (rev 1377)
@@ -4,6 +4,7 @@
  */
 package org.teiid.test.framework.transaction;
 
+import org.teiid.test.framework.ConfigPropertyLoader;
 import org.teiid.test.framework.TransactionContainer;
 import org.teiid.test.framework.exception.TransactionRuntimeException;
 import org.teiid.test.framework.connection.ConnectionStrategy;
@@ -16,16 +17,11 @@
 	public static final String LOCAL_TRANSACTION = "local";     //$NON-NLS-1$
 	public static final String XATRANSACTION = "xa"; //$NON-NLS-1$
 	public static final String JNDI_TRANSACTION = "jndi"; //$NON-NLS-1$
-//	public static final String OFFWRAP_TRANSACTION = "offwrap"; //$NON-NLS-1$
-//	public static final String ONWRAP_TRANSACTION = "onwrap"; //$NON-NLS-1$
-
-
 	
 	/**
 	 * Transaction Type indicates the type of transaction container to use
 	 */
     public static final String TRANSACTION_TYPE = "transaction-type"; //$NON-NLS-1$
-//    public static final String AUTOCOMMIT = "autocommit"; //$NON-NLS-1$
 
         
     private TransactionFactory(){}
@@ -34,6 +30,10 @@
     public static TransactionContainer create()  {
     	TransactionContainer transacton = null;
     	
+    	// load the configuration properties defined at this time for the test
+    	ConfigPropertyLoader.loadConfigurationProperties();
+
+    	
     	ConnectionStrategy connstrategy = ConnectionStrategyFactory.getInstance().getConnectionStrategy();
              
     	



More information about the teiid-commits mailing list