teiid SVN: r1460 - in trunk/test-integration/db/src/test/java/org/teiid/test: framework/datasource and 1 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-22 18:01:35 -0400 (Tue, 22 Sep 2009)
New Revision: 1460
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/SingleSourceTransactionScenarios.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionScenarios.java
Log:
Teiid 773 - reorganized how datasources are referenced at all stages of a test
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-22 22:00:58 UTC (rev 1459)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java 2009-09-22 22:01:35 UTC (rev 1460)
@@ -5,23 +5,26 @@
package org.teiid.test.framework;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.BufferedReader;
import java.io.IOException;
+import java.sql.Connection;
import java.sql.Statement;
+import java.util.Map;
import java.util.Properties;
import javax.sql.XAConnection;
import org.teiid.test.framework.connection.ConnectionStrategy;
import org.teiid.test.framework.connection.ConnectionStrategyFactory;
+import org.teiid.test.framework.connection.ConnectionUtil;
+import org.teiid.test.framework.datasource.DataSource;
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;
-import com.metamatrix.jdbc.api.ExecutionProperties;
/**
@@ -33,10 +36,12 @@
*
*/
public abstract class AbstractQueryTransactionTest extends AbstractQueryTest implements TransactionQueryTest{
- Properties executionProperties = null;
- String testname = "NA";
+ protected Properties executionProperties = null;
+ protected String testname = "NA";
+ protected Map<String, DataSource> datasources = null;
+
public AbstractQueryTransactionTest() {
super();
}
@@ -50,7 +55,16 @@
return this.testname;
}
+ /**
+ * Called to set the datasources used during this test
+ *
+ * @since
+ */
+ public void setDataSources(Map<String, DataSource> datasources) {
+ this.datasources = datasources;
+ }
+
public void setExecutionProperties(Properties props) {
assertNotNull(props);
this.executionProperties = props;
@@ -85,20 +99,35 @@
return true;
}
- @Override
- public void setupDataSource() {
+
+ /**
+ * Override <code>setupDataSource</code> if there is different mechinism for
+ * setting up the datasources for the testcase
+ *
+ * @since
+ */
+ @Override
+ public void setupDataSources() {
DataSourceSetup dss = null;
try {
- dss = DataSourceSetupFactory.createDataSourceSetup(getNumberRequiredDataSources());
+ dss = DataSourceSetupFactory.createDataSourceSetup(this.datasources);
dss.setup();
} catch(Exception e) {
throw new TransactionRuntimeException(e.getMessage());
}
- }
+ }
+
+
+ public Connection getSource(String identifier) throws QueryTestFailedException {
+ return ConnectionUtil.getConnection(identifier, this.datasources);
+ }
+
+ public XAConnection getXASource(String identifier) throws QueryTestFailedException {
+ return ConnectionUtil.getXAConnection(identifier, this.datasources);
+ }
-
/**
* Implement testCase(), it is the entry point to the execution of the test.
* @throws Exception
@@ -137,7 +166,13 @@
public void after() {
}
+
+ @Override
+ public void validateTestCase() throws Exception {
+
+ }
+
/**
* At end of each test, clean up the connection factory so that it can be
* established at the start of the next test.
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-22 22:00:58 UTC (rev 1459)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/DataSourceSetupFactory.java 2009-09-22 22:01:35 UTC (rev 1460)
@@ -1,24 +1,26 @@
package org.teiid.test.framework.datasource;
+import java.util.Map;
+
import org.teiid.test.framework.DataSourceSetup;
import org.teiid.test.framework.exception.QueryTestFailedException;
public class DataSourceSetupFactory {
- public static DataSourceSetup createDataSourceSetup(int numOfDataSources) throws QueryTestFailedException {
+ public static DataSourceSetup createDataSourceSetup(Map<String, DataSource> datasources) throws QueryTestFailedException {
DataSourceSetup dss = null;
- switch (numOfDataSources) {
+ switch (datasources.size()) {
case 1:
- dss = new SingleDataSourceSetup();
+ dss = new SingleDataSourceSetup(datasources);
break;
case 2:
- dss = new TwoDataSourceSetup();
+ dss = new TwoDataSourceSetup(datasources);
break;
default:
- throw new QueryTestFailedException("Number of datasources " + numOfDataSources + " is not supported");
+ throw new QueryTestFailedException("Number of datasources " + datasources.size() + " 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-22 22:00:58 UTC (rev 1459)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/SingleDataSourceSetup.java 2009-09-22 22:01:35 UTC (rev 1460)
@@ -4,6 +4,8 @@
*/
package org.teiid.test.framework.datasource;
+import java.util.Map;
+
import org.teiid.test.framework.DataSourceSetup;
import org.teiid.test.framework.QueryExecution;
import org.teiid.test.framework.connection.ConnectionUtil;
@@ -16,7 +18,13 @@
* 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 {
@@ -28,7 +36,7 @@
// Only one of the models are needed because pm1 and pm2 point to the same datasource
- AbstractQueryTest test1 = new QueryExecution(ConnectionUtil.getSource("pm1")); //$NON-NLS-1$
+ AbstractQueryTest test1 = new QueryExecution(ConnectionUtil.getConnection("pm1", ds) ); //$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-22 22:00:58 UTC (rev 1459)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java 2009-09-22 22:01:35 UTC (rev 1460)
@@ -4,6 +4,8 @@
*/
package org.teiid.test.framework.datasource;
+import java.util.Map;
+
import org.teiid.test.framework.DataSourceSetup;
import org.teiid.test.framework.QueryExecution;
import org.teiid.test.framework.connection.ConnectionUtil;
@@ -16,7 +18,12 @@
* 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 {
@@ -27,7 +34,8 @@
System.out.println("Run TwoSource Setup...");
- AbstractQueryTest test1 = new QueryExecution(ConnectionUtil.getSource("pm1")); //$NON-NLS-1$
+ AbstractQueryTest test1 = new QueryExecution(ConnectionUtil.getConnection("pm1", ds));//$NON-NLS-1$
+
test1.execute("delete from g2"); //$NON-NLS-1$
test1.execute("delete from g1"); //$NON-NLS-1$
@@ -55,7 +63,7 @@
test1.execute("select * from g2 ");
test1.assertRowCount(100);
- AbstractQueryTest test2 = new QueryExecution(ConnectionUtil.getSource("pm2")); //$NON-NLS-1$
+ AbstractQueryTest test2 = new QueryExecution(ConnectionUtil.getConnection("pm2", ds));//$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-22 22:00:58 UTC (rev 1459)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java 2009-09-22 22:01:35 UTC (rev 1460)
@@ -35,12 +35,12 @@
}
- public Connection getSource(String identifier) throws QueryTestFailedException {
- return ConnectionUtil.getSource(identifier);
- }
-
- public XAConnection getXASource(String identifier) throws QueryTestFailedException {
- return ConnectionUtil.getXASource(identifier);
- }
+// 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/SingleSourceTransactionScenarios.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionScenarios.java 2009-09-22 22:00:58 UTC (rev 1459)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionScenarios.java 2009-09-22 22:01:35 UTC (rev 1460)
@@ -4,8 +4,11 @@
*/
package org.teiid.test.testcases;
+import java.util.Map;
+
import org.teiid.test.framework.AbstractQueryTransactionTest;
import org.teiid.test.framework.QueryExecution;
+import org.teiid.test.framework.datasource.DataSource;
import com.metamatrix.jdbc.api.AbstractQueryTest;
@@ -37,10 +40,8 @@
execute("select * from pm1.g1 where pm1.g1.e1 < 100");
assertRowCount(100);
}
-
- public void validateTestCase() throws Exception {
-
- }
+
+
};
// run test
@@ -68,6 +69,7 @@
test.closeConnection();
}
+
};
// run test
@@ -151,9 +153,7 @@
execute("select * from pm1.g1 where pm1.g1.e1 < 100 limit 10");
assertRowCount(10);
}
-
- public void validateTestCase() throws Exception {
- }
+
};
// run test
@@ -168,15 +168,7 @@
* result = rollback
*/
- public void testSingleSourceMultipleCommandsExplicitRollback() throws Exception {
- // now it's empty
- AbstractQueryTest test = new QueryExecution(getSource("pm1"));
- //getSource("pm1"));
- test.execute("select * from g1 where e1 >= 200 and e1 < 220");
- test.assertRowCount(0);
- test.execute("select * from g2 where e1 >= 200 and e1 < 220");
- test.assertRowCount(0);
- test.closeConnection();
+ public void testSingleSourceMultipleCommandsExplicitRollback() throws Exception {
AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceMultipleCommandsExplicitRollback") {
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-22 22:00:58 UTC (rev 1459)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionScenarios.java 2009-09-22 22:01:35 UTC (rev 1460)
@@ -45,9 +45,7 @@
public int getNumberRequiredDataSources(){
return 2;
}
-
- public void validateTestCase() throws Exception {
- }
+
};
// run test
@@ -70,8 +68,7 @@
public int getNumberRequiredDataSources(){
return 2;
}
- public void validateTestCase() throws Exception {
- }
+
};
15 years, 3 months
teiid SVN: r1459 - in trunk/test-integration/db/src/main/java/org/teiid/test/framework: connection and 2 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-22 18:00:58 -0400 (Tue, 22 Sep 2009)
New Revision: 1459
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/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/ConnectionUtil.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
Log:
Teiid 773 - reorganized how datasources are referenced at all stages of a test
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-22 20:00:09 UTC (rev 1458)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-09-22 22:00:58 UTC (rev 1459)
@@ -6,9 +6,11 @@
import java.sql.Connection;
import java.util.Properties;
+import java.util.Set;
import org.teiid.test.framework.connection.ConnectionStrategy;
import org.teiid.test.framework.datasource.DataSourceMgr;
+import org.teiid.test.framework.datasource.DataSourceSetupFactory;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
@@ -31,36 +33,25 @@
}
- /**
- * Returns <code>true</code> if the test <b>CANNOT</b> be run due to not have the right
- * number of datasources available.
- *
- */
- protected boolean turnOffTest (int numberofDataSources) {
- boolean rtn = DataSourceMgr.getInstance().hasAvailableDataSource(numberofDataSources);
- if (!rtn) {
- return true;
- }
+ protected Set getDataSources() {
+ Set dss = null;
- return false;
- }
-
+
+ return dss;
+ }
+
+
protected void before(TransactionQueryTest test){}
protected void after(TransactionQueryTest test) {}
public void runTransaction(TransactionQueryTest test) {
-
- if (turnOffTest(test.getNumberRequiredDataSources())) {
- detail("Turn Off Transaction test: " + test.getTestName() + ", doesn't have the number of required datasources");
- return;
-
- }
-
+
detail("Start transaction test: " + test.getTestName());
try {
- test.setupDataSource();
+ test.setDataSources(connStrategy.getDataSources());
+ test.setupDataSources();
debug(" setConnection");
test.setConnection(getConnection());
@@ -77,12 +68,6 @@
// run the test
test.testCase();
- }catch(Throwable e) {
- if (!test.exceptionExpected()) {
- e.printStackTrace();
- }
- throw new TransactionRuntimeException(e.getMessage());
- }finally {
debug(" test.after");
test.after();
@@ -92,6 +77,14 @@
detail("End transaction test: " + test.getTestName());
+
+ }catch(Throwable e) {
+ if (!test.exceptionExpected()) {
+ e.printStackTrace();
+ }
+ throw new TransactionRuntimeException(e.getMessage());
+ }finally {
+
}
if (test.exceptionExpected() && !test.exceptionOccurred()) {
@@ -136,6 +129,8 @@
protected void detail(String message) {
System.out.println(message);
}
+
+
}
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-22 20:00:09 UTC (rev 1458)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java 2009-09-22 22:00:58 UTC (rev 1459)
@@ -1,10 +1,13 @@
package org.teiid.test.framework;
import java.sql.Connection;
+import java.util.Map;
import java.util.Properties;
import javax.sql.XAConnection;
+import org.teiid.test.framework.datasource.DataSource;
+
/**
* The TransactionQueryTest interface represents the transaction test framework from which
* the @link TransactionContainer operates.
@@ -30,6 +33,15 @@
/**
+ * Called by the @link TransactionContainer to set the datasoures used to create the connector bindings.
+ * @param datasources
+ *
+ * @since
+ */
+ void setDataSources(Map<String, DataSource> datasources);
+
+
+ /**
* Returns the connection being used in the test.
* @return
*
@@ -64,12 +76,12 @@
/**
* Called by the {@link TransactionContainer} prior to testcase processing so that
- * the datasource data can be setup for the specific testcase.
+ * the datasources can be setup for the specific testcase.
*
*
* @since
*/
- void setupDataSource();
+ void setupDataSources();
/**
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-22 20:00:09 UTC (rev 1458)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java 2009-09-22 22:00:58 UTC (rev 1459)
@@ -9,7 +9,9 @@
import java.lang.reflect.Method;
import java.sql.Connection;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import java.util.Properties;
import javax.sql.XAConnection;
@@ -18,7 +20,7 @@
import org.teiid.adminapi.AdminOptions;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.VDB;
-import org.teiid.connector.jdbc.JDBCPropertyNames;
+import org.teiid.test.framework.datasource.DataSource;
import org.teiid.test.framework.datasource.DataSourceMgr;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
@@ -60,6 +62,9 @@
public static final String FETCH_SIZE = ExecutionProperties.PROP_FETCH_SIZE;
public static final String EXEC_IN_BATCH = "execute.in.batch"; //$NON-NLS-1$
+
+
+ private Map<String, DataSource> datasources = null;
public ConnectionStrategy(Properties props) throws QueryTestFailedException {
@@ -101,6 +106,10 @@
return env;
}
+ public Map<String, DataSource> getDataSources() {
+ return this.datasources;
+ }
+
class CloseInterceptor implements InvocationHandler {
Connection conn;
@@ -123,6 +132,8 @@
void configure() throws QueryTestFailedException {
+ datasources = new HashMap<String, DataSource>(3);
+
String ac = this.env.getProperty(AUTOCOMMIT, "true");
this.autoCommit = Boolean.getBoolean(ac);
@@ -140,16 +151,16 @@
Admin admin = (Admin)c.getAdminAPI();
- boolean update = false;
+ // boolean update = false;
Properties p = new Properties();
if (this.env.getProperty(PROCESS_BATCH) != null) {
p.setProperty("metamatrix.buffer.processorBatchSize", this.env.getProperty(PROCESS_BATCH)); //$NON-NLS-1$
- update = true;
+ // update = true;
}
if (this.env.getProperty(CONNECTOR_BATCH) != null) {
p.setProperty("metamatrix.buffer.connectorBatchSize", this.env.getProperty(CONNECTOR_BATCH)); //$NON-NLS-1$
- update = true;
+ // update = true;
}
// update the system.
@@ -206,6 +217,8 @@
org.teiid.test.framework.datasource.DataSource ds = DataSourceMgr.getInstance().getDatasource(useName, m.getName());
if (ds != null) {
+ datasources.put(m.getName(), ds);
+
System.out.println("Setting up Connector Binding of Type: " + ds.getConnectorType()); //$NON-NLS-1$
AdminOptions ao = new AdminOptions(AdminOptions.OnConflict.OVERWRITE);
@@ -232,21 +245,5 @@
}
- /**
- * The datasource_identifier must match one of the mappings in the file
- * at {@see} src/main/resources/datasources/datasource_mapping.txt
- * @param datasource_identifier
- * @return
- *
- * @since
- */
-// public XAConnection getXASource(String datasource_identifier) {
-// return null;
-// }
-//
-// public Connection getSource(String datasource_identifier) {
-// return null;
-// }
-
}
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-22 20:00:09 UTC (rev 1458)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java 2009-09-22 22:00:58 UTC (rev 1459)
@@ -1,78 +1,112 @@
package org.teiid.test.framework.connection;
import java.sql.Connection;
+import java.util.Map;
import java.util.Properties;
import javax.sql.XAConnection;
import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.datasource.DataSource;
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 {
+ public static final Connection getConnection(String identifier, Map<String, DataSource> datasources) throws QueryTestFailedException {
+ DataSource ds = null;
if (identifier != null) {
- String mappedName = ConfigPropertyLoader.getProperty(identifier);
-
- if (mappedName == null) {
- throw new TransactionRuntimeException("Identifier mapping "
- + identifier
- + " is not defined in the config properties file");
+ ds = datasources.get(identifier);
+ if (ds == null) {
+ throw new TransactionRuntimeException("DataSource is not mapped to Identifier "
+ + identifier);
}
+
+ }
+
+ return ConnectionStrategyFactory.getInstance().createDriverStrategy(identifier,
+ ds.getProperties()).getConnection();
- Properties sourceProps;
- try {
- sourceProps = DataSourceMgr.getInstance()
- .getDatasourceProperties(mappedName, identifier);
- } catch (QueryTestFailedException e) {
- throw new TransactionRuntimeException(e);
- }
-
- if (sourceProps == null) {
- throw new TransactionRuntimeException("Identifier "
- + identifier + " mapped to " + mappedName
- + " has no datasource properties");
- }
-
- return ConnectionStrategyFactory.getInstance().createDriverStrategy(identifier,
- sourceProps).getConnection();
-
- }
- throw new RuntimeException("No Connection by name :" + identifier); //$NON-NLS-1$
}
-
- public static final XAConnection getXASource(String identifier)
- throws QueryTestFailedException {
+
+ public static final XAConnection getXAConnection(String identifier, Map<String, DataSource> datasources) throws QueryTestFailedException {
+ DataSource ds = null;
if (identifier != null) {
- String mappedName = ConfigPropertyLoader.getProperty(identifier);
-
- if (mappedName == null) {
- throw new TransactionRuntimeException("Identifier mapping "
- + identifier
- + " is not defined in the config properties file");
+ ds = datasources.get(identifier);
+ if (ds == null) {
+ throw new TransactionRuntimeException("DataSource is not mapped to Identifier "
+ + identifier);
}
+
+ }
+
+ return ConnectionStrategyFactory.getInstance().createDataSourceStrategy(
+ identifier, ds.getProperties()).getXAConnection();
- Properties sourceProps;
- try {
- sourceProps = DataSourceMgr.getInstance()
- .getDatasourceProperties(mappedName, identifier);
- } catch (QueryTestFailedException e) {
- throw new TransactionRuntimeException(e);
- }
-
- if (sourceProps == null) {
- throw new TransactionRuntimeException("Identifier "
- + identifier + " mapped to " + mappedName
- + " has no datasource properties");
- }
-
- return ConnectionStrategyFactory.getInstance().createDataSourceStrategy(
- identifier, sourceProps).getXAConnection();
- }
- throw new RuntimeException("No Connection by name :" + identifier); //$NON-NLS-1$
}
+
+// public static final Connection getSource(String identifier)
+// throws QueryTestFailedException {
+// if (identifier != null) {
+// String mappedName = ConfigPropertyLoader.getProperty(identifier);
+//
+// if (mappedName == null) {
+// throw new TransactionRuntimeException("Identifier mapping "
+// + identifier
+// + " is not defined in the config properties file");
+// }
+//
+// Properties sourceProps;
+// try {
+// sourceProps = DataSourceMgr.getInstance()
+// .getDatasourceProperties(mappedName, identifier);
+// } catch (QueryTestFailedException e) {
+// throw new TransactionRuntimeException(e);
+// }
+//
+// if (sourceProps == null) {
+// throw new TransactionRuntimeException("Identifier "
+// + identifier + " mapped to " + mappedName
+// + " has no datasource properties");
+// }
+//
+// return ConnectionStrategyFactory.getInstance().createDriverStrategy(identifier,
+// sourceProps).getConnection();
+//
+// }
+// throw new RuntimeException("No Connection by name :" + identifier); //$NON-NLS-1$
+// }
+//
+// public static final XAConnection getXASource(String identifier)
+// throws QueryTestFailedException {
+// if (identifier != null) {
+// String mappedName = ConfigPropertyLoader.getProperty(identifier);
+//
+// if (mappedName == null) {
+// throw new TransactionRuntimeException("Identifier mapping "
+// + identifier
+// + " is not defined in the config properties file");
+// }
+//
+// Properties sourceProps;
+// try {
+// sourceProps = DataSourceMgr.getInstance()
+// .getDatasourceProperties(mappedName, identifier);
+// } catch (QueryTestFailedException e) {
+// throw new TransactionRuntimeException(e);
+// }
+//
+// if (sourceProps == null) {
+// throw new TransactionRuntimeException("Identifier "
+// + identifier + " mapped to " + mappedName
+// + " has no datasource properties");
+// }
+//
+// return ConnectionStrategyFactory.getInstance().createDataSourceStrategy(
+// identifier, sourceProps).getXAConnection();
+// }
+// throw new RuntimeException("No Connection by name :" + identifier); //$NON-NLS-1$
+// }
}
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-22 20:00:09 UTC (rev 1458)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2009-09-22 22:00:58 UTC (rev 1459)
@@ -45,13 +45,14 @@
private static DataSourceMgr _instance = null;
- private Map<String, Map<String, DataSource>>dstypeMap = new HashMap<String, Map<String, DataSource>>(); //key=datasourcetype
+ private Map<String, Map<String, DataSource>>dsGroupMap = new HashMap<String, Map<String, DataSource>>(); //key=datasourcetype
private Map<String, DataSource> allDatasourcesMap = new HashMap<String, DataSource>(); // key=datasource name
private Map<String, DataSource> modelToDatasourceMap = new HashMap<String, DataSource>(); // key=modelname + "_" + datasourcename
// key=modelname + "_" + groupname
+ private Set<String> dbTypes = new HashSet<String>();
// this set is use to track datasources that have already been assigned
private Set<String> assignedDataSources = new HashSet<String>();
@@ -87,7 +88,7 @@
* @since
*/
public static synchronized void reset() {
-
+ if (_instance == null) return;
//
_instance.modelToDatasourceMap.clear();
_instance.assignedDataSources.clear();
@@ -98,26 +99,21 @@
return allDatasourcesMap.size();
}
- public boolean hasAvailableDataSource(int numRequiredDataSources) {
- // reset the mapping at the start of each test
- _instance.modelToDatasourceMap.clear();
-
- Set excludedDBTypes = getExcludedDBTypes();
-
- int cntexcluded = 0;
- Iterator<DataSource> it= allDatasourcesMap.values().iterator();
- while(it.hasNext()) {
- DataSource ds = it.next();
- if (excludedDBTypes.contains(ds.getDBType())) {
- cntexcluded++;
- }
- }
-
- return(numRequiredDataSources <= (numberOfAvailDataSources() - cntexcluded));
-
- }
+// public boolean hasAvailableDataSource(int numRequiredDataSources) {
+// // reset the mapping at the start of each test
+// _instance.modelToDatasourceMap.clear();
+//
+// Set<String>excludedDBTypes = getExcludedDBTypes();
+//
+// Set<String> xSet = new HashSet<String>(dbTypes);
+//
+// xSet.removeAll(excludedDBTypes);
+//
+// return(numRequiredDataSources <= (xSet.size()));
+//
+// }
- private Set getExcludedDBTypes() {
+ private Set<String> getExcludedDBTypes() {
String excludeprop = ConfigPropertyLoader.getProperty(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP);
@@ -154,9 +150,9 @@
Set excludedDBTypes = getExcludedDBTypes();
- if (dstypeMap.containsKey(datasourceid)) {
+ if (dsGroupMap.containsKey(datasourceid)) {
- Map datasources = dstypeMap.get(datasourceid);
+ Map datasources = dsGroupMap.get(datasourceid);
Iterator<DataSource> it= datasources.values().iterator();
// need to go thru all the datasources to know if any has already been assigned
@@ -219,14 +215,7 @@
}
- public Properties getDatasourceProperties(String datasourceid, String modelname)
- throws QueryTestFailedException {
- DataSource ds = getDatasource(datasourceid, modelname);
- return ds.getProperties();
-
- }
-
private void loadDataSourceMappings()
throws QueryTestFailedException {
@@ -259,7 +248,7 @@
for (Iterator<Element> it = rootElements.iterator(); it.hasNext();) {
Element type = it.next();
- String typename = type.getAttributeValue(Property.Attributes.NAME);
+ String groupname = type.getAttributeValue(Property.Attributes.NAME);
List<Element> typeElements = type.getChildren();
if (typeElements != null) {
@@ -267,9 +256,9 @@
for (Iterator<Element> typeit = typeElements.iterator(); typeit.hasNext();) {
Element e = typeit.next();
- addDataSource(e, typename, datasources, limitds);
+ addDataSource(e, groupname, datasources, limitds);
}
- dstypeMap.put(typename, datasources);
+ dsGroupMap.put(groupname, datasources);
allDatasourcesMap.putAll(datasources);
}
@@ -277,19 +266,19 @@
}
- if (dstypeMap == null || dstypeMap.isEmpty()) {
+ if (dsGroupMap == null || dsGroupMap.isEmpty()) {
throw new TransactionRuntimeException(
"No Datasources were found in the mappings file");
}
- System.out.println("Number of datasource groups loaded " + dstypeMap.size());
+ System.out.println("Number of datasource groups loaded " + dsGroupMap.size());
System.out.println("Number of total datasource mappings loaded " + allDatasourcesMap.size());
}
- private static void addDataSource(Element element, String group, Map<String, DataSource> datasources, Set<String> include) {
+ private void addDataSource(Element element, String group, Map<String, DataSource> datasources, Set<String> include) {
String name = element.getAttributeValue(Property.Attributes.NAME);
Properties props = getProperties(element);
@@ -312,7 +301,7 @@
group,
props);
-
+ dbTypes.add(ds.getDBType());
datasources.put(ds.getName(), ds);
System.out.println("Loaded datasource " + ds.getName());
@@ -406,7 +395,7 @@
throw new RuntimeException("Datasources are not the same");
}
System.out.println("Value for ds_mysql: "
- + mgr.getDatasourceProperties("ds_oracle", "model1"));
+ + mgr.getDatasource("ds_oracle", "model1").getProperties());
// boolean shouldbeavail = mgr.hasAvailableDataSource("nonxa", DataSource.ExclusionTypeBitMask.ORACLE);
// if (!shouldbeavail) {
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-22 20:00:09 UTC (rev 1458)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java 2009-09-22 22:00:58 UTC (rev 1459)
@@ -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);
+// }
+// }
}
}
15 years, 3 months
teiid SVN: r1458 - in trunk/test-integration/db/src/main/java/org/teiid/test/framework: connection and 1 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-22 16:00:09 -0400 (Tue, 22 Sep 2009)
New Revision: 1458
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/connection/ConnectionStrategyFactory.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
Log:
Teiid 773 - setting up the xa transaction tests
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-22 19:59:09 UTC (rev 1457)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2009-09-22 20:00:09 UTC (rev 1458)
@@ -49,6 +49,13 @@
}
}
+ public static void cleanup() {
+ Properties p = System.getProperties();
+ p.remove(ConfigPropertyNames.CONFIG_FILE);
+ p.remove(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP);
+
+ }
+
public static void main(String[] args) {
System.setProperty("test", "value");
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-22 19:59:09 UTC (rev 1457)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java 2009-09-22 20:00:09 UTC (rev 1458)
@@ -47,9 +47,7 @@
}
private void shutdown() {
- Properties p = System.getProperties();
- p.remove(ConfigPropertyNames.CONFIG_FILE);
-
+ ConfigPropertyLoader.cleanup();
if (driversources != null) {
shutDownSources(driversources);
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-22 19:59:09 UTC (rev 1457)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2009-09-22 20:00:09 UTC (rev 1458)
@@ -6,6 +6,7 @@
import java.io.IOException;
import java.io.InputStream;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -55,7 +56,6 @@
private Set<String> assignedDataSources = new HashSet<String>();
private int lastassigned = 0;
- private Set<String> excludedDBTypes = null;
private DataSourceMgr() {
@@ -78,15 +78,20 @@
return _instance;
}
+ /**
+ * reset is called when a predetermined set of datasources are going to be set
+ * This is to ensure any exclusions / inclusions are considered for the
+ * next executed set of test.
+ *
+ *
+ * @since
+ */
public static synchronized void reset() {
-
- _instance.dstypeMap.clear();
- _instance.allDatasourcesMap.clear();
+
+ //
_instance.modelToDatasourceMap.clear();
_instance.assignedDataSources.clear();
- _instance = null;
-
}
public int numberOfAvailDataSources() {
@@ -95,18 +100,9 @@
public boolean hasAvailableDataSource(int numRequiredDataSources) {
// reset the mapping at the start of each test
- _instance.modelToDatasourceMap.clear();
- excludedDBTypes = new HashSet<String>(3);
+ _instance.modelToDatasourceMap.clear();
-
- String excludeprop = ConfigPropertyLoader.getProperty(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP);
-
- if (excludeprop == null || excludeprop.length() == 0) {
- return (numRequiredDataSources <= numberOfAvailDataSources());
- }
-
- List<String> eprops = StringUtil.split(excludeprop, ",");
- excludedDBTypes.addAll(eprops);
+ Set excludedDBTypes = getExcludedDBTypes();
int cntexcluded = 0;
Iterator<DataSource> it= allDatasourcesMap.values().iterator();
@@ -121,7 +117,22 @@
}
+ private Set getExcludedDBTypes() {
+
+ String excludeprop = ConfigPropertyLoader.getProperty(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP);
+
+ if (excludeprop == null || excludeprop.length() == 0) {
+ return Collections.EMPTY_SET;
+ }
+ Set<String> excludedDBTypes = new HashSet<String>(3);
+
+ List<String> eprops = StringUtil.split(excludeprop, ",");
+ excludedDBTypes.addAll(eprops);
+ return excludedDBTypes;
+ }
+
+
public DataSource getDatasource(String datasourceid, String modelName)
throws QueryTestFailedException {
DataSource ds = null;
@@ -141,7 +152,8 @@
return modelToDatasourceMap.get(key);
}
-
+ Set excludedDBTypes = getExcludedDBTypes();
+
if (dstypeMap.containsKey(datasourceid)) {
Map datasources = dstypeMap.get(datasourceid);
15 years, 3 months
teiid SVN: r1457 - trunk/test-integration/db/src/test/java/org/teiid/test/testcases.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-22 15:59:09 -0400 (Tue, 22 Sep 2009)
New Revision: 1457
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/XATransactionDatasourceFalseOffTest.java
Log:
Teiid 773 - setting up the xa transaction tests
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-22 19:32:10 UTC (rev 1456)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java 2009-09-22 19:59:09 UTC (rev 1457)
@@ -14,6 +14,7 @@
import org.teiid.test.framework.TransactionContainer;
import org.teiid.test.framework.connection.ConnectionUtil;
+import org.teiid.test.framework.datasource.DataSourceMgr;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.transaction.TransactionFactory;
@@ -24,6 +25,11 @@
super(name);
}
+ @Override
+ protected void setUp() throws Exception {
+ DataSourceMgr.reset();
+ }
+
protected TransactionContainer getTransactionContainter() throws QueryTestFailedException {
return TransactionFactory.create();
}
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-22 19:32:10 UTC (rev 1456)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/XATransactionDatasourceFalseOffTest.java 2009-09-22 19:59:09 UTC (rev 1457)
@@ -30,6 +30,7 @@
@Override
protected void setUp() throws Exception {
+ super.setUp();
//XATransactions currently doesn't support using sqlserver
//{@see TEIID-559}
15 years, 3 months
teiid SVN: r1456 - trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-22 15:32:10 -0400 (Tue, 22 Sep 2009)
New Revision: 1456
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
Log:
Teiid 773 - setting up the xa transaction tests
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-22 19:09:08 UTC (rev 1455)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2009-09-22 19:32:10 UTC (rev 1456)
@@ -94,8 +94,11 @@
}
public boolean hasAvailableDataSource(int numRequiredDataSources) {
-
+ // reset the mapping at the start of each test
+ _instance.modelToDatasourceMap.clear();
excludedDBTypes = new HashSet<String>(3);
+
+
String excludeprop = ConfigPropertyLoader.getProperty(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP);
if (excludeprop == null || excludeprop.length() == 0) {
15 years, 3 months
teiid SVN: r1455 - trunk/test-integration.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-22 15:09:08 -0400 (Tue, 22 Sep 2009)
New Revision: 1455
Modified:
trunk/test-integration/pom.xml
Log:
Teiid 773 - setting up the xa transaction tests
Modified: trunk/test-integration/pom.xml
===================================================================
--- trunk/test-integration/pom.xml 2009-09-22 19:08:41 UTC (rev 1454)
+++ trunk/test-integration/pom.xml 2009-09-22 19:09:08 UTC (rev 1455)
@@ -79,6 +79,10 @@
<artifactId>teiid-engine</artifactId>
<type>test-jar</type>
</dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-txn-jbossts</artifactId>
+ </dependency>
<!-- internal dependencies that are only used by integration testing -->
<dependency>
15 years, 3 months
teiid SVN: r1454 - in trunk/test-integration/db/src/test/java/org/teiid/test: testcases and 1 other directory.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-22 15:08:41 -0400 (Tue, 22 Sep 2009)
New Revision: 1454
Modified:
trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionScenarios.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 - setting up the xa transaction tests
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-22 19:08:03 UTC (rev 1453)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java 2009-09-22 19:08:41 UTC (rev 1454)
@@ -138,10 +138,14 @@
}
+ /**
+ * At end of each test, clean up the connection factory so that it can be
+ * established at the start of the next test.
+ */
public void cleanup() {
ConnectionStrategyFactory.destroyInstance();
- this.closeConnection();
+ // this.closeConnection();
}
@Override
Modified: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionScenarios.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionScenarios.java 2009-09-22 19:08:03 UTC (rev 1453)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionScenarios.java 2009-09-22 19:08:41 UTC (rev 1454)
@@ -45,11 +45,7 @@
// run test
getTransactionContainter().runTransaction(userTxn);
-
- // there is nothing to verify here..
-
- System.out.println("Complete testSingleSourceSelect");
-
+
}
@@ -76,9 +72,6 @@
// run test
getTransactionContainter().runTransaction(userTxn);
-
-
- System.out.println("Complete testSingleSourceUpdate");
}
@@ -105,10 +98,7 @@
// run test
getTransactionContainter().runTransaction(userTxn);
-
-
- System.out.println("Complete testSingleSourcePreparedUpdate");
-
+
}
/**
@@ -147,9 +137,6 @@
// run test
getTransactionContainter().runTransaction(userTxn);
-
- System.out.println("Complete testSingleSourceMultipleCommands");
-
}
/**
@@ -171,8 +158,6 @@
// run test
getTransactionContainter().runTransaction(userTxn);
-
- System.out.println("Complete testSingleSourcePartialProcessing");
}
@@ -223,9 +208,7 @@
// run test
getTransactionContainter().runTransaction(userTxn);
-
- System.out.println("Complete testSingleSourceMultipleCommandsExplicitRollback");
-
+
}
/**
@@ -264,8 +247,6 @@
// run test
getTransactionContainter().runTransaction(userTxn);
-
- System.out.println("Complete testSingleSourceMultipleCommandsReferentialIntegrityRollback");
}
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-22 19:08:03 UTC (rev 1453)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionScenarios.java 2009-09-22 19:08:41 UTC (rev 1454)
@@ -52,9 +52,7 @@
// run test
getTransactionContainter().runTransaction(userTxn);
-
- System.out.println("Complete testMultipleSourceSelect");
-
+
}
/**
@@ -64,7 +62,7 @@
* result = commit
*/
public void testMultipleSourceViewSelect() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceVirtualSelect") {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceViewSelect") {
public void testCase() throws Exception {
execute("select * from vm.g1 where vm.g1.pm1e1 < 100");
assertRowCount(100);
@@ -80,9 +78,7 @@
// run test
getTransactionContainter().runTransaction(userTxn);
-
- System.out.println("Complete testMultipleSourceVirtualSelect");
-
+
}
/**
@@ -92,7 +88,7 @@
* result = commit
*/
public void testMultipleSourceViewUpdate() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceUpdate") {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceViewUpdate") {
public void testCase() throws Exception {
execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(500, '500', 500, '500')");
}
@@ -120,9 +116,7 @@
// run test
getTransactionContainter().runTransaction(userTxn);
-
- System.out.println("Complete testMultipleSourceUpdate");
-
+
}
/**
@@ -161,8 +155,6 @@
// run test
getTransactionContainter().runTransaction(userTxn);
-
- System.out.println("Complete testMultipleSourceViewSelectInto");
}
@@ -209,10 +201,7 @@
// run test
getTransactionContainter().runTransaction(userTxn);
-
- System.out.println("Complete testMultipleSourceViewBulkRowInsert");
-
- }
+ }
/**
* Sources = 2
@@ -261,10 +250,7 @@
// run test
getTransactionContainter().runTransaction(userTxn);
-
-
- System.out.println("Complete testMultipleSourceViewBulkRowInsertRollback");
-
+
}
@@ -303,9 +289,7 @@
// run test
getTransactionContainter().runTransaction(userTxn);
-
- System.out.println("Complete testMultipleSourceViewPreparedUpdate");
-
+
}
@@ -368,10 +352,7 @@
// run test
getTransactionContainter().runTransaction(userTxn);
-
- System.out.println("Complete testMultipleSourceMultipleCommands");
-
-
+
}
/**
@@ -421,9 +402,7 @@
// run test
getTransactionContainter().runTransaction(userTxn);
- System.out.println("Complete testMultipleSourceViewMultipleCommands");
-
}
/**
@@ -484,9 +463,6 @@
// run test
getTransactionContainter().runTransaction(userTxn);
-
- System.out.println("Complete testMultipleSourceViewMultipleCommandsRollback");
-
}
@@ -544,8 +520,6 @@
};
getTransactionContainter().runTransaction(userTxn);
-
- System.out.println("Complete testMultipleSourceMultipleCommandsCancel");
}
@@ -604,8 +578,6 @@
// run test
getTransactionContainter().runTransaction(userTxn);
- System.out.println("Complete testMultipleSourceMultipleCommandsExplicitRollback");
-
}
/**
@@ -658,9 +630,6 @@
// run test
getTransactionContainter().runTransaction(userTxn);
-
- System.out.println("Complete testMultipleSourceMultipleCommandsReferentialIntegrityRollback");
-
}
@@ -713,10 +682,7 @@
};
getTransactionContainter().runTransaction(userTxn);
-
-
- System.out.println("Complete testMultipleSourceTimeout");
-
+
}
@@ -769,9 +735,7 @@
// run test
getTransactionContainter().runTransaction(userTxn);
-
- System.out.println("Complete testMultipleSourceViewPartialProcessingUsingLimit");
-
+
}
/**
@@ -801,9 +765,7 @@
// run test
getTransactionContainter().runTransaction(userTxn);
-
- System.out.println("Complete testMultipleSourcePartialProcessingUsingMakedep");
-
+
}
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-22 19:08:03 UTC (rev 1453)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/XATransactionDatasourceFalseOffTest.java 2009-09-22 19:08:41 UTC (rev 1454)
@@ -18,19 +18,28 @@
* - Autocommit = True
* - TxnAutoWrap = Off
*/
-public class XATransactionDatasourceFalseOffTest extends TwoSourceTransactionScenarios {
-
+//public class XATransactionDatasourceFalseOffTest extends SingleSourceTransactionScenarios {
+
+ public class XATransactionDatasourceFalseOffTest extends TwoSourceTransactionScenarios {
+
+
+
public XATransactionDatasourceFalseOffTest(String name) {
super(name);
}
@Override
protected void setUp() throws Exception {
+
+ //XATransactions currently doesn't support using sqlserver
+ //{@see TEIID-559}
+ System.setProperty(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP, "sqlserver");
+
System.setProperty(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, "off");
+ // System.setProperty(ConnectionStrategy.TXN_AUTO_WRAP, "on");
}
15 years, 3 months
teiid SVN: r1453 - trunk/test-integration/db/src/main/resources.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-22 15:08:03 -0400 (Tue, 22 Sep 2009)
New Revision: 1453
Modified:
trunk/test-integration/db/src/main/resources/default-config.properties
trunk/test-integration/db/src/main/resources/xa-config.properties
Log:
Teiid 773 - setting up the xa transaction tests
Modified: trunk/test-integration/db/src/main/resources/default-config.properties
===================================================================
--- trunk/test-integration/db/src/main/resources/default-config.properties 2009-09-22 19:07:41 UTC (rev 1452)
+++ trunk/test-integration/db/src/main/resources/default-config.properties 2009-09-22 19:08:03 UTC (rev 1453)
@@ -18,9 +18,9 @@
##########################################
#driver=org.teiid.jdbc.TeiidDriver
driver=com.metamatrix.jdbc.EmbeddedDataSource
-URL=jdbc:metamatrix:Transaction@target/classes/transactions/transaction.properties
-User=metamatrixadmin
-Password=mm
+URL=jdbc:metamatrix:Transaction@target/classes/transactions/transaction.properties;user=admin;password=teiid
+User=admin
+Password=teiid
databasename=Transaction
servername=target/classes/transactions/transaction.properties
portnumber=0
Modified: trunk/test-integration/db/src/main/resources/xa-config.properties
===================================================================
--- trunk/test-integration/db/src/main/resources/xa-config.properties 2009-09-22 19:07:41 UTC (rev 1452)
+++ trunk/test-integration/db/src/main/resources/xa-config.properties 2009-09-22 19:08:03 UTC (rev 1453)
@@ -15,9 +15,9 @@
# properties for Teiid connection
##########################################
driver=com.metamatrix.jdbc.EmbeddedDataSource
-URL=jdbc:metamatrix:Transaction@target/classes/transactions/transaction.properties
-User=metamatrixadmin
-Password=mm
+URL=jdbc:metamatrix:Transaction@target/classes/transactions/transaction.properties;user=admin;password=teiid
+User=admin
+Password=teiid
databasename=Transaction
servername=target/classes/transactions/transaction.properties
portnumber=0
15 years, 3 months
teiid SVN: r1452 - trunk/test-integration/db/src/main/resources/transactions.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-22 15:07:41 -0400 (Tue, 22 Sep 2009)
New Revision: 1452
Modified:
trunk/test-integration/db/src/main/resources/transactions/transaction.properties
Log:
Teiid 773 - setting up the xa transaction tests
Modified: trunk/test-integration/db/src/main/resources/transactions/transaction.properties
===================================================================
--- trunk/test-integration/db/src/main/resources/transactions/transaction.properties 2009-09-22 19:06:54 UTC (rev 1451)
+++ trunk/test-integration/db/src/main/resources/transactions/transaction.properties 2009-09-22 19:07:41 UTC (rev 1452)
@@ -16,6 +16,8 @@
processName=integrationTest
+#xa.txnstore_dir=./txndir
+
#dqp.workdir=./tmp/
#only for testing, as this takes more time to start and shutdown
15 years, 3 months
teiid SVN: r1451 - in trunk/test-integration/db/src/main/java/org/teiid/test/framework: connection and 2 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-22 15:06:54 -0400 (Tue, 22 Sep 2009)
New Revision: 1451
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.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/connection/ConnectionStrategyFactory.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.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/java/org/teiid/test/framework/transaction/XATransaction.java
Log:
Teiid 773 - setting up the xa transaction tests
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java 2009-09-22 14:08:53 UTC (rev 1450)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java 2009-09-22 19:06:54 UTC (rev 1451)
@@ -38,13 +38,25 @@
/**
* The USE_DATASOURCES_PROP is a comma delimited system property that can be used to limit the
- * datasources that are in use for the tests. Use the name defined in the datasource_mapping.xml.
- * This enables one to test between certain datasources without having to remove
+ * datasources that are in use for the tests. Use the directory name defined in the ddl directory.
+ * This enables a developers to test a certain datasource without having to remove
* connection.properties files.
*/
public static final String USE_DATASOURCES_PROP = "usedatasources";
+
+ /**
+ * The EXCLUDE_DATASOURCES_PROP is a comma delimited system property that can be used to exclude
+ * certain database types.
+ * This is done so that whole sets of tests can be excluded when a datasource has been defined
+ * for a specific database type.
+ * Example of this is the XATransactions currently doesn't support using sqlserver (@see TEIID-559)
+ */
+ public static final String EXCLUDE_DATASBASE_TYPES_PROP = "excludedatasources";
+
+
+
/**
* Connection Type indicates the type of connection (strategy) to use
* Options are {@link CONNECTION_TYPES}
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-22 14:08:53 UTC (rev 1450)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-09-22 19:06:54 UTC (rev 1451)
@@ -7,12 +7,10 @@
import java.sql.Connection;
import java.util.Properties;
-import javax.sql.XAConnection;
-
+import org.teiid.test.framework.connection.ConnectionStrategy;
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;
@@ -39,31 +37,14 @@
*
*/
protected boolean turnOffTest (int numberofDataSources) {
- boolean rtn = (numberofDataSources > DataSourceMgr.getInstance().numberOfAvailDataSources());
- if (rtn) {
- System.out.println("Required Number of DataSources is " + numberofDataSources + " but availables sources is " + DataSourceMgr.getInstance().numberOfAvailDataSources());
+ boolean rtn = DataSourceMgr.getInstance().hasAvailableDataSource(numberofDataSources);
+ if (!rtn) {
+ return true;
}
- return rtn;
+
+ return false;
}
-
-
- /**
- * 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){}
protected void after(TransactionQueryTest test) {}
@@ -74,11 +55,7 @@
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());
@@ -112,9 +89,6 @@
debug(" after(test)");
after(test);
- debug(" test.cleanup");
-
- test.cleanup();
detail("End transaction test: " + test.getTestName());
@@ -134,18 +108,20 @@
}catch(Exception e) {
throw new TransactionRuntimeException(e);
}
+
+ debug(" test.cleanup");
+
+ test.cleanup();
+
+ detail("Completed transaction test: " + test.getTestName());
+
+
}
-
protected Connection getConnection() throws QueryTestFailedException {
return this.connStrategy.getConnection();
- }
-
- protected XAConnection getXAConnection() throws QueryTestFailedException {
- return this.connStrategy.getXAConnection();
- }
+ }
-
public Properties getEnvironmentProperties() {
return props;
}
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-22 14:08:53 UTC (rev 1450)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java 2009-09-22 19:06:54 UTC (rev 1451)
@@ -17,8 +17,14 @@
public class ConnectionStrategyFactory {
private static ConnectionStrategyFactory _instance = null;
+ /**
+ * this strategy represents the connection strategy used to connect to Teiid
+ * and is based on the properties loaded by the {@link ConfigPropertyLoader}
+ */
private ConnectionStrategy strategy = null;
- private Map<String, ConnectionStrategy> sources = null;
+ private Map<String, ConnectionStrategy> driversources = null;
+ private Map<String, ConnectionStrategy> datasourcesources = null;
+ private Map<String, ConnectionStrategy> jeesources = null;
private ConnectionStrategyFactory(){
@@ -27,22 +33,10 @@
public static synchronized ConnectionStrategyFactory getInstance() {
if (_instance == null) {
_instance = new ConnectionStrategyFactory();
-
- _instance. init();
- // TODO Auto-generated catch block
-// _instance = null;
-// throw new TransactionRuntimeException(e);
-// }
}
return _instance;
}
-
- private void init() {
- if (sources == null) {
- sources = new HashMap<String, ConnectionStrategy>();
- }
- }
-
+
public static synchronized void destroyInstance() {
if (_instance != null) {
@@ -57,24 +51,45 @@
p.remove(ConfigPropertyNames.CONFIG_FILE);
- for (Iterator it=sources.keySet().iterator(); it.hasNext(); ){
+ if (driversources != null) {
+ shutDownSources(driversources);
+ driversources = null;
+ }
+
+ if (datasourcesources != null) {
+ shutDownSources(datasourcesources);
+ datasourcesources = null;
+ }
+
+ if (jeesources != null) {
+ shutDownSources(jeesources);
+ jeesources = null;
+ }
+
+ try {
+ strategy.shutdown();
+ } catch (Exception e) {
- ConnectionStrategy cs = sources.get(it.next());
- try {
- cs.shutdown();
- } catch (Exception e) {
-
- }
-
+ } finally {
+ strategy = null;
}
- sources.clear();
- sources = null;
-
- strategy.shutdown();
- strategy = null;
}
+ private void shutDownSources(Map<String, ConnectionStrategy> sources) {
+ for (Iterator it=sources.keySet().iterator(); it.hasNext(); ){
+ ConnectionStrategy cs = sources.get(it.next());
+ try {
+ cs.shutdown();
+ } catch (Exception e) {
+
+ }
+
+ }
+ sources.clear();
+
+ }
+
public synchronized ConnectionStrategy getConnectionStrategy() throws QueryTestFailedException {
if (strategy == null) {
this.strategy = create(ConfigPropertyLoader.getProperties());
@@ -93,6 +108,7 @@
}
if (type.equalsIgnoreCase(ConfigPropertyNames.CONNECTION_TYPES.DRIVER_CONNECTION)) {
+ // pass in null to create new strategy
strategy = createDriverStrategy(null, props);
System.out.println("Created Driver Strategy");
}
@@ -115,16 +131,20 @@
}
public synchronized ConnectionStrategy createDriverStrategy(String identifier, Properties props) throws QueryTestFailedException {
+ if (driversources == null) {
+ driversources = new HashMap<String, ConnectionStrategy>();
+ }
+
if (identifier == null) {
- return new DriverConnection(props);
+ return new DriverConnection(props);
}
ConnectionStrategy strategy = null;
- if (sources.containsKey(identifier)) {
- strategy = sources.get(identifier);
+ if (driversources.containsKey(identifier)) {
+ strategy = driversources.get(identifier);
} else {
strategy = new DriverConnection(props);
- sources.put(identifier, strategy);
+ driversources.put(identifier, strategy);
}
return strategy;
@@ -132,16 +152,20 @@
}
public synchronized ConnectionStrategy createDataSourceStrategy(String identifier, Properties props) throws QueryTestFailedException {
+ if (datasourcesources == null) {
+ datasourcesources = new HashMap<String, ConnectionStrategy>();
+ }
+
if (identifier == null) {
return new DataSourceConnection(props);
}
ConnectionStrategy strategy = null;
- if (sources.containsKey(identifier)) {
- strategy = sources.get(identifier);
+ if (datasourcesources.containsKey(identifier)) {
+ strategy = datasourcesources.get(identifier);
} else {
strategy = new DataSourceConnection(props);
- sources.put(identifier, strategy);
+ datasourcesources.put(identifier, strategy);
}
return strategy;
@@ -149,38 +173,26 @@
}
public synchronized ConnectionStrategy createJEEStrategy(String identifier, Properties props) throws QueryTestFailedException {
+ if (jeesources == null) {
+ jeesources = new HashMap<String, ConnectionStrategy>();
+ }
+
if (identifier == null) {
return new JEEConnection(props);
}
ConnectionStrategy strategy = null;
- if (sources.containsKey(identifier)) {
- strategy = sources.get(identifier);
+ if (jeesources.containsKey(identifier)) {
+ strategy = jeesources.get(identifier);
} else {
strategy = new JEEConnection(props);
- sources.put(identifier, strategy);
+ jeesources.put(identifier, strategy);
}
return strategy;
}
-// 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/DataSourceConnection.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java 2009-09-22 14:08:53 UTC (rev 1450)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java 2009-09-22 19:06:54 UTC (rev 1451)
@@ -18,12 +18,7 @@
import com.metamatrix.jdbc.BaseDataSource;
import com.metamatrix.jdbc.EmbeddedDataSource;
-import com.metamatrix.jdbc.MMDataSource;
-import com.metamatrix.jdbc.api.ExecutionProperties;
-/**
-*
-*/
public class DataSourceConnection extends ConnectionStrategy {
public static final String DS_USER = "user"; //$NON-NLS-1$
@@ -130,10 +125,13 @@
((TeiidDataSource)dataSource).setPortNumber(Integer.parseInt(this.portNumber));
}
- if (this.username != null) {
- dataSource.setUser(this.username);
- dataSource.setPassword(this.pwd);
- }
+ dataSource.setUser("admin");
+ dataSource.setPassword("teiid");
+
+// if (this.username != null) {
+// dataSource.setUser(this.username);
+// dataSource.setPassword(this.pwd);
+// }
return ((XADataSource)dataSource).getXAConnection();
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-22 14:08:53 UTC (rev 1450)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2009-09-22 19:06:54 UTC (rev 1451)
@@ -53,6 +53,9 @@
// this set is use to track datasources that have already been assigned
private Set<String> assignedDataSources = new HashSet<String>();
+
+ private int lastassigned = 0;
+ private Set<String> excludedDBTypes = null;
private DataSourceMgr() {
@@ -90,55 +93,32 @@
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) {
+ public boolean hasAvailableDataSource(int numRequiredDataSources) {
+
+ excludedDBTypes = new HashSet<String>(3);
+ String excludeprop = ConfigPropertyLoader.getProperty(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP);
- // no datasources are excluded
- if (excludeDSBitMask == DataSource.ExclusionTypeBitMask.NONE_EXCLUDED) {
- return true;
+ if (excludeprop == null || excludeprop.length() == 0) {
+ return (numRequiredDataSources <= numberOfAvailDataSources());
}
- 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;
- }
-
+ List<String> eprops = StringUtil.split(excludeprop, ",");
+ excludedDBTypes.addAll(eprops);
+
+ int cntexcluded = 0;
+ Iterator<DataSource> it= allDatasourcesMap.values().iterator();
+ while(it.hasNext()) {
+ DataSource ds = it.next();
+ if (excludedDBTypes.contains(ds.getDBType())) {
+ cntexcluded++;
}
- 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;
-
}
-
+
+ return(numRequiredDataSources <= (numberOfAvailDataSources() - cntexcluded));
+
}
+
public DataSource getDatasource(String datasourceid, String modelName)
throws QueryTestFailedException {
DataSource ds = null;
@@ -168,28 +148,49 @@
// because the datasourceid passed in was a group name
while(it.hasNext()) {
DataSource checkit = it.next();
- 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 (excludedDBTypes.contains(checkit.getDBType())) {
+ continue;
+ }
- }
+ if (!assignedDataSources.contains(checkit.getName())) {
+ ds = checkit;
+ assignedDataSources.add(ds.getName());
+ break;
+ }
+
}
- if (ds != null) {
- assignedDataSources.add(ds.getName());
+
+ if (ds == null) {
+ int cnt = 0;
+ Iterator<DataSource> itds= datasources.values().iterator();
- modelToDatasourceMap.put(key, ds);
-
- }
+ // when all the datasources have been assigned, but a new model datasource id is
+ // passed in, need to reassign a previously assigned datasource
+ // This case will happen when more models are defined than there are defined datasources.
+ while(itds.hasNext()) {
+ DataSource datasource = itds.next();
+ if (cnt == this.lastassigned) {
+ ds = datasource;
+
+ this.lastassigned++;
+ if (lastassigned >= datasources.size()) {
+ this.lastassigned = 0;
+ }
+
+ break;
+ }
+ }
+ }
} else {
ds = allDatasourcesMap.get(datasourceid);
+
+ if (excludedDBTypes.contains(ds.getDBType())) {
+ ds = null;
+ }
}
if (ds == null) {
@@ -222,7 +223,6 @@
limitds.addAll(dss);
}
-
Document doc = null;
XMLReaderWriter readerWriter = new XMLReaderWriterImpl();
@@ -277,22 +277,27 @@
private static void addDataSource(Element element, String group, Map<String, DataSource> datasources, Set<String> include) {
String name = element.getAttributeValue(Property.Attributes.NAME);
+ Properties props = getProperties(element);
+
+ String dir = props.getProperty(DataSource.DIRECTORY);
+
if (include.size() > 0) {
- if (!include.contains(name)) {
- System.out.println("Excluded datasource: " + name);
+ if (!include.contains(dir)) {
+// System.out.println("Excluded datasource: " + name);
return;
}
}
- Properties props = getProperties(element);
- String dir = props.getProperty(DataSource.DIRECTORY);
String dsfile = RELATIVE_DIRECTORY + dir + "/connection.properties";
Properties dsprops = loadProperties(dsfile);
+
if (dsprops != null) {
props.putAll(dsprops);
DataSource ds = new DataSource(name,
group,
props);
+
+
datasources.put(ds.getName(), ds);
System.out.println("Loaded datasource " + ds.getName());
@@ -388,21 +393,21 @@
System.out.println("Value for ds_mysql: "
+ mgr.getDatasourceProperties("ds_oracle", "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");
- }
+// 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/LocalTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java 2009-09-22 14:08:53 UTC (rev 1450)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java 2009-09-22 19:06:54 UTC (rev 1451)
@@ -4,10 +4,12 @@
*/
package org.teiid.test.framework.transaction;
+import java.sql.Connection;
import java.sql.SQLException;
import org.teiid.test.framework.TransactionContainer;
import org.teiid.test.framework.TransactionQueryTest;
+import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
import org.teiid.test.framework.connection.ConnectionStrategy;
@@ -54,7 +56,7 @@
} finally {
- // if an exceptio occurs and the autocommit is set to true - while doing a transaction
+ // 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 {
@@ -65,4 +67,7 @@
}
}
}
+
+
+
}
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-22 14:08:53 UTC (rev 1450)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java 2009-09-22 19:06:54 UTC (rev 1451)
@@ -36,6 +36,8 @@
throw new RuntimeException("Property " + ConfigPropertyNames.TRANSACTION_TYPE + " was specified");
}
+ System.out.println("Create TransactionContainer: " + type);
+
if (type.equalsIgnoreCase(ConfigPropertyNames.TRANSACTION_TYPES.LOCAL_TRANSACTION)) {
transacton = new LocalTransaction(connstrategy);
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java 2009-09-22 14:08:53 UTC (rev 1450)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java 2009-09-22 19:06:54 UTC (rev 1451)
@@ -6,12 +6,14 @@
import java.util.Random;
+import javax.sql.XAConnection;
import javax.transaction.xa.XAResource;
import org.teiid.test.framework.TransactionContainer;
import org.teiid.test.framework.TransactionQueryTest;
+import org.teiid.test.framework.connection.ConnectionStrategy;
+import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
-import org.teiid.test.framework.connection.ConnectionStrategy;
import com.metamatrix.common.xa.MMXid;
@@ -77,4 +79,9 @@
}
}
}
+
+
+ protected XAConnection getXAConnection() throws QueryTestFailedException {
+ return this.connStrategy.getXAConnection();
+ }
}
15 years, 3 months