[teiid-commits] teiid SVN: r1500 - in trunk/test-integration/db/src/test/java/org/teiid/test: framework/datasource and 1 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Wed Sep 30 12:08:18 EDT 2009


Author: vhalbert at redhat.com
Date: 2009-09-30 12:08:14 -0400 (Wed, 30 Sep 2009)
New Revision: 1500

Added:
   trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/DataSourceSetup.java
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/datasource/DataSourceSetupFactory.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/BaseAbstractTransactionTestCase.java
   trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionDriverFalseOffTest.java
   trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionDriverTrueOffTest.java
   trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionScenarios.java
   trunk/test-integration/db/src/test/java/org/teiid/test/testcases/XATransactionDatasourceFalseOffTest.java
Log:
Teiid 773 -  changed the following:
-  the testcase will not use system property to pass in overrides/additions to the loaded config.properties file.   Now will use an addProperty() method provided on the abstract testcase that will apply the properties per test.
-  remove the  datasource_mapping.xml.    There is no need to distinquish between xa and nonxa connector types.    The connector type will be specified in the connection.properties file.
-  if using the -DuserDataSources property to control datasource, it will imply order based on whats specified.    The config.properties file will now map the model to order (i.e., pm1:1), where this order determines which datasource it will correspond to based on the userDataSources property.    This mapping is done so that the nightly testing process can control which datasources are being used and can ensure retestability.

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-30 16:07:17 UTC (rev 1499)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java	2009-09-30 16:08:14 UTC (rev 1500)
@@ -16,12 +16,13 @@
 
 import javax.sql.XAConnection;
 
+import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
 import org.teiid.test.framework.connection.ConnectionStrategy;
 import org.teiid.test.framework.connection.ConnectionUtil;
 import org.teiid.test.framework.datasource.DataSource;
+import org.teiid.test.framework.datasource.DataSourceSetup;
 import org.teiid.test.framework.datasource.DataSourceSetupFactory;
 import org.teiid.test.framework.exception.QueryTestFailedException;
-import org.teiid.test.framework.exception.TransactionRuntimeException;
 
 import com.metamatrix.jdbc.api.AbstractQueryTest;
 
@@ -40,7 +41,9 @@
 	
 	protected Map<String, DataSource> datasources = null;
 	
+	protected ConnectionStrategy connStrategy;
 	
+	
 	public AbstractQueryTransactionTest() {
 		super();
 	}
@@ -53,18 +56,16 @@
 	public String getTestName() {
 		return this.testname;
 	}
+		
 	
-    /**
-     * Called to set the datasources used during this test
-     * 
-     * @since
-     */
-	public void setDataSources(Map<String, DataSource> datasources) {
-		this.datasources = datasources;
+    @Override
+	public void setConnectionStrategy(ConnectionStrategy connStrategy) {
+		this.connStrategy = connStrategy;
+		this.datasources = this.connStrategy.getDataSources();
+		
 	}
-	
-	
-    public void setExecutionProperties(Properties props) {
+
+	public void setExecutionProperties(Properties props) {
        	assertNotNull(props);
         this.executionProperties = props;        
     }
@@ -77,13 +78,13 @@
         if (this.executionProperties != null) {  
              if (stmt instanceof com.metamatrix.jdbc.api.Statement) {
                 com.metamatrix.jdbc.api.Statement statement = (com.metamatrix.jdbc.api.Statement)stmt;
-                String txnautowrap = this.executionProperties.getProperty(ConnectionStrategy.TXN_AUTO_WRAP);
+                String txnautowrap = this.executionProperties.getProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP);
                 if (txnautowrap != null) {
-                     statement.setExecutionProperty(ConnectionStrategy.TXN_AUTO_WRAP, txnautowrap);
+                     statement.setExecutionProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, txnautowrap);
                 }
                 
-                if (this.executionProperties.getProperty(ConnectionStrategy.FETCH_SIZE) != null) {
-                    statement.setExecutionProperty(ConnectionStrategy.FETCH_SIZE, this.executionProperties.getProperty(ConnectionStrategy.FETCH_SIZE));
+                if (this.executionProperties.getProperty(CONNECTION_STRATEGY_PROPS.FETCH_SIZE) != null) {
+                    statement.setExecutionProperty(CONNECTION_STRATEGY_PROPS.FETCH_SIZE, this.executionProperties.getProperty(CONNECTION_STRATEGY_PROPS.FETCH_SIZE));
                 }
             }
         }
@@ -102,28 +103,26 @@
     /**
      * Override <code>setupDataSource</code> if there is different mechinism for
      * setting up the datasources for the testcase
+     * @throws QueryTestFailedException 
+     * @throws QueryTestFailedException 
      * 
      * @since
      */
     @Override
-	public void setupDataSources() {
-    	DataSourceSetup dss = null;
-    	try {
-    		
-    		dss = DataSourceSetupFactory.createDataSourceSetup(this.datasources);
-    		dss.setup();
-    	} catch(Exception e) {
-    		throw new TransactionRuntimeException(e.getMessage());
-    	}
+    public void setupDataSource() throws QueryTestFailedException {
+    	
+    	DataSourceSetup dss = DataSourceSetupFactory.createDataSourceSetup(this.getNumberRequiredDataSources());
+    	dss.setup(datasources, connStrategy);
+
     }	
 
 
 	public Connection getSource(String identifier) throws QueryTestFailedException {
-    	return ConnectionUtil.getConnection(identifier, this.datasources);
+    	return ConnectionUtil.getConnection(identifier, this.datasources, this.connStrategy);
     }    
     
     public XAConnection getXASource(String identifier) throws QueryTestFailedException {
-       	return ConnectionUtil.getXAConnection(identifier, this.datasources);
+       	return ConnectionUtil.getXAConnection(identifier, this.datasources, this.connStrategy);
      }   
 	
     
@@ -173,7 +172,7 @@
     
     
     /**
-     * At end of each test, perfrom any cleanup that your test requires.
+     * At end of each test, perfoom any cleanup that your test requires.
      * Note:  Do not cleanup any connections.   That is performed by
      * the {@link TransactionContainer#runTransaction(TransactionQueryTest)} at the end of the test.
      */

Copied: trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/DataSourceSetup.java (from rev 1482, trunk/test-integration/db/src/main/java/org/teiid/test/framework/DataSourceSetup.java)
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/DataSourceSetup.java	                        (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/DataSourceSetup.java	2009-09-30 16:08:14 UTC (rev 1500)
@@ -0,0 +1,22 @@
+package org.teiid.test.framework.datasource;
+
+import java.util.Map;
+
+import org.teiid.test.framework.connection.ConnectionStrategy;
+import org.teiid.test.framework.datasource.DataSource;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+
+/**
+ * The DataSourceSetup 
+ * @author vanhalbert
+ *
+ */
+public interface DataSourceSetup {
+	
+	
+	void setup(Map<String, DataSource> datasources, ConnectionStrategy connStrategy) throws QueryTestFailedException;
+	
+
+	int getDataSourceCnt();
+	
+}


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

Modified: trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/DataSourceSetupFactory.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/DataSourceSetupFactory.java	2009-09-30 16:07:17 UTC (rev 1499)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/DataSourceSetupFactory.java	2009-09-30 16:08:14 UTC (rev 1500)
@@ -1,26 +1,23 @@
 package org.teiid.test.framework.datasource;
 
-import java.util.Map;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
 
-import org.teiid.test.framework.DataSourceSetup;
-import org.teiid.test.framework.exception.QueryTestFailedException;
-
 public class DataSourceSetupFactory {
 	
-	public static DataSourceSetup createDataSourceSetup(Map<String, DataSource> datasources) throws QueryTestFailedException {
+	public static DataSourceSetup createDataSourceSetup(int numofsources)  {
 		DataSourceSetup dss = null;
 		
-		switch (datasources.size()) {
+		switch (numofsources) {
 		case 1:
-			dss = new SingleDataSourceSetup(datasources);
+			dss = new SingleDataSourceSetup();
 			break;
 			
 		case 2:
-			dss = new TwoDataSourceSetup(datasources);
+			dss = new TwoDataSourceSetup();
 			break;
 			
 		default:
-			throw new QueryTestFailedException("Number of datasources " + datasources.size() + " is not supported");
+			throw new TransactionRuntimeException("Number of datasources " + numofsources + " is not supported");
 
 		}
 		

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-30 16:07:17 UTC (rev 1499)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/SingleDataSourceSetup.java	2009-09-30 16:08:14 UTC (rev 1500)
@@ -6,9 +6,10 @@
 
 import java.util.Map;
 
-import org.teiid.test.framework.DataSourceSetup;
 import org.teiid.test.framework.QueryExecution;
+import org.teiid.test.framework.connection.ConnectionStrategy;
 import org.teiid.test.framework.connection.ConnectionUtil;
+import org.teiid.test.framework.exception.QueryTestFailedException;
 
 import com.metamatrix.jdbc.api.AbstractQueryTest;
 
@@ -18,16 +19,10 @@
  * This performs the data setup for SingleSource test cases  
  */
 public class SingleDataSourceSetup implements DataSourceSetup {
-	
-	private Map ds=null;
-    
-	public SingleDataSourceSetup(Map datasources) {
-		this.ds = datasources;
-	}
-	
+		
    
 	@Override
-	public void setup() throws Exception {
+	public void setup(Map<String, DataSource> datasources, ConnectionStrategy connStrategy) throws QueryTestFailedException  {
     // NOTE:  dont close the connections here because in most cases they are reused
     //			to validate the results
     //		The connections will be closed at teardown
@@ -36,7 +31,7 @@
         
     	
         // Only one of the models are needed because pm1 and pm2 point to the same datasource
-        AbstractQueryTest test1 = new QueryExecution(ConnectionUtil.getConnection("pm1", ds) ); //$NON-NLS-1$
+        AbstractQueryTest test1 = new QueryExecution(ConnectionUtil.getConnection("pm1", datasources, connStrategy) ); //$NON-NLS-1$
         test1.execute("delete from g2"); //$NON-NLS-1$
         test1.execute("delete from g1");         //$NON-NLS-1$
         

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-30 16:07:17 UTC (rev 1499)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java	2009-09-30 16:08:14 UTC (rev 1500)
@@ -6,9 +6,10 @@
 
 import java.util.Map;
 
-import org.teiid.test.framework.DataSourceSetup;
 import org.teiid.test.framework.QueryExecution;
+import org.teiid.test.framework.connection.ConnectionStrategy;
 import org.teiid.test.framework.connection.ConnectionUtil;
+import org.teiid.test.framework.exception.QueryTestFailedException;
 
 import com.metamatrix.jdbc.api.AbstractQueryTest;
 
@@ -18,22 +19,18 @@
  * This performs the data setup for SingleSource test cases  
  */
 public class TwoDataSourceSetup implements DataSourceSetup {
-	private Map ds=null;
-    
-	public TwoDataSourceSetup(Map datasources) {
-		this.ds = datasources;
-	}
 
+
    
 	@Override
-	public void setup() throws Exception {   	
+	public void setup(Map<String, DataSource> datasources, ConnectionStrategy connStrategy) throws QueryTestFailedException {   	
 	    // NOTE:  dont close the connections here because in most cases they are reused
 	    //			to validate the results
 	    //		The connections will be closed at teardown
      	
        System.out.println("Run TwoSource Setup...");
    	
-        AbstractQueryTest test1 = new QueryExecution(ConnectionUtil.getConnection("pm1", ds));//$NON-NLS-1$
+        AbstractQueryTest test1 = new QueryExecution(ConnectionUtil.getConnection("pm1", datasources, connStrategy));//$NON-NLS-1$
 
         test1.execute("delete from g2"); //$NON-NLS-1$
         test1.execute("delete from g1");         //$NON-NLS-1$
@@ -63,7 +60,7 @@
         test1.assertRowCount(100);  
 
  
-        AbstractQueryTest test2 = new QueryExecution(ConnectionUtil.getConnection("pm2", ds));//$NON-NLS-1$
+        AbstractQueryTest test2 = new QueryExecution(ConnectionUtil.getConnection("pm2", datasources, connStrategy));//$NON-NLS-1$
         test2.execute("delete from g2"); //$NON-NLS-1$
         test2.execute("delete from g1");         //$NON-NLS-1$
         

Modified: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java	2009-09-30 16:07:17 UTC (rev 1499)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java	2009-09-30 16:08:14 UTC (rev 1500)
@@ -8,34 +8,38 @@
 
 import junit.framework.TestCase;
 
+import org.teiid.test.framework.ConfigPropertyLoader;
 import org.teiid.test.framework.TransactionContainer;
-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  {
 
+	protected ConfigPropertyLoader config = null;
 	
     public BaseAbstractTransactionTestCase(String name) {
         super(name);
     }
     
-	@Override
+    
+    
+    @Override
 	protected void setUp() throws Exception {
-		DataSourceMgr.reset();
+		// TODO Auto-generated method stub
+		super.setUp();
+		
+		config = ConfigPropertyLoader.createInstance();
+
 	}
+
+
+
+	protected void addProperty(String key, String value) {
+    	config.setProperty(key, value);
+    }
     
     protected TransactionContainer getTransactionContainter() throws QueryTestFailedException {
-    	return TransactionFactory.create(); 
-    }
+    	return TransactionFactory.create(config); 
+    }    
 
-
-//    public Connection getSource(String identifier) throws QueryTestFailedException {
-//    	return ConnectionUtil.getSource(identifier);
-//    }    
-//    
-//    public XAConnection getXASource(String identifier) throws QueryTestFailedException {
-//       	return ConnectionUtil.getXASource(identifier);
-//     }     
-
 }

Modified: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionDriverFalseOffTest.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionDriverFalseOffTest.java	2009-09-30 16:07:17 UTC (rev 1499)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionDriverFalseOffTest.java	2009-09-30 16:08:14 UTC (rev 1500)
@@ -5,7 +5,7 @@
 package org.teiid.test.testcases;
 
 import org.teiid.test.framework.ConfigPropertyNames;
-import org.teiid.test.framework.connection.ConnectionStrategy;
+import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
 
 
 /** 
@@ -25,10 +25,14 @@
 
 	@Override
 	protected void setUp() throws Exception {
+		super.setUp();
+		
+		this.addProperty(ConfigPropertyNames.USE_DATASOURCES_PROP, "oracle,sqlserver");
     	
-    	System.setProperty(ConfigPropertyNames.CONNECTION_TYPE, ConfigPropertyNames.CONNECTION_TYPES.DRIVER_CONNECTION);
-    	System.setProperty(ConnectionStrategy.AUTOCOMMIT, "false");
-    	System.setProperty(ConnectionStrategy.TXN_AUTO_WRAP, "off");
+		this.addProperty(ConfigPropertyNames.CONNECTION_TYPE, ConfigPropertyNames.CONNECTION_TYPES.DRIVER_CONNECTION);
+		
+		this.addProperty(CONNECTION_STRATEGY_PROPS.AUTOCOMMIT, "false");
+		this.addProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, "off");
     	
 		
 	}

Modified: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionDriverTrueOffTest.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionDriverTrueOffTest.java	2009-09-30 16:07:17 UTC (rev 1499)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionDriverTrueOffTest.java	2009-09-30 16:08:14 UTC (rev 1500)
@@ -5,7 +5,7 @@
 package org.teiid.test.testcases;
 
 import org.teiid.test.framework.ConfigPropertyNames;
-import org.teiid.test.framework.connection.ConnectionStrategy;
+import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
 
 
 /** 
@@ -25,11 +25,12 @@
 
 	@Override
 	protected void setUp() throws Exception {
+		super.setUp();
+		
+		this.addProperty(ConfigPropertyNames.CONNECTION_TYPE, ConfigPropertyNames.CONNECTION_TYPES.DRIVER_CONNECTION);
+		this.addProperty(CONNECTION_STRATEGY_PROPS.AUTOCOMMIT, "true");
+		this.addProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, "off");
     	
-    	System.setProperty(ConfigPropertyNames.CONNECTION_TYPE, ConfigPropertyNames.CONNECTION_TYPES.DRIVER_CONNECTION);
-    	System.setProperty(ConnectionStrategy.AUTOCOMMIT, "true");
-    	System.setProperty(ConnectionStrategy.TXN_AUTO_WRAP, "off");
-    	
 		
 	}      
       

Modified: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionScenarios.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionScenarios.java	2009-09-30 16:07:17 UTC (rev 1499)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionScenarios.java	2009-09-30 16:08:14 UTC (rev 1500)
@@ -296,7 +296,7 @@
      * Batching = Full Processing, Single Connector Batch
      * result = commit
      */
-    public void testMultipleSourceMultipleCommands() throws Exception {
+    public void lookat_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)});

Modified: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/XATransactionDatasourceFalseOffTest.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/XATransactionDatasourceFalseOffTest.java	2009-09-30 16:07:17 UTC (rev 1499)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/XATransactionDatasourceFalseOffTest.java	2009-09-30 16:08:14 UTC (rev 1500)
@@ -5,7 +5,7 @@
 package org.teiid.test.testcases;
 
 import org.teiid.test.framework.ConfigPropertyNames;
-import org.teiid.test.framework.connection.ConnectionStrategy;
+import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
 
 
 /** 
@@ -34,13 +34,13 @@
 		
 		//XATransactions currently doesn't support using sqlserver 
 		//{@see TEIID-559} 
-		System.setProperty(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP, "sqlserver");
+		this.addProperty(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP, "sqlserver");
 		
-    	System.setProperty(ConfigPropertyNames.CONFIG_FILE, "xa-config.properties");
+		this.addProperty(ConfigPropertyNames.CONFIG_FILE, "xa-config.properties");
 		
-    	System.setProperty(ConfigPropertyNames.CONNECTION_TYPE, ConfigPropertyNames.CONNECTION_TYPES.DATASOURCE_CONNECTION);
-    	System.setProperty(ConnectionStrategy.AUTOCOMMIT, "false");
- //   	System.setProperty(ConnectionStrategy.TXN_AUTO_WRAP, "on");
+		this.addProperty(ConfigPropertyNames.CONNECTION_TYPE, ConfigPropertyNames.CONNECTION_TYPES.DATASOURCE_CONNECTION);
+		this.addProperty(CONNECTION_STRATEGY_PROPS.AUTOCOMMIT, "false");
+ //   	this.addProperty(ConnectionStrategy.TXN_AUTO_WRAP, "on");
     	
 		
 	}



More information about the teiid-commits mailing list