teiid SVN: r1564 - trunk/test-integration/db/src/test/java/org/teiid/test/framework.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-11-16 16:06:03 -0500 (Mon, 16 Nov 2009)
New Revision: 1564
Removed:
trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java
trunk/test-integration/db/src/test/java/org/teiid/test/framework/QueryExecution.java
Log:
Teiid 773 - refactored back in the way jbedsp transaction classes where defined
Deleted: 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-11-16 21:03:58 UTC (rev 1563)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java 2009-11-16 21:06:03 UTC (rev 1564)
@@ -1,192 +0,0 @@
-/*
- * Copyright (c) 2000-2007 MetaMatrix, Inc.
- * All rights reserved.
- */
-package org.teiid.test.framework;
-
-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.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 com.metamatrix.jdbc.api.AbstractQueryTest;
-
-
-/**
- * The AbstractQueryTransactionTest is the class that should be extended when
- * a testcase is being created to validate certain behavior
- *
- * @see QueryExecution for use when direct queries to the source are used
- * to validate the results of the testcase.
- *
- */
-public abstract class AbstractQueryTransactionTest extends AbstractQueryTest implements TransactionQueryTest{
- protected Properties executionProperties = null;
- protected String testname = "NA";
-
- protected Map<String, DataSource> datasources = null;
-
- protected ConnectionStrategy connStrategy;
-
-
- public AbstractQueryTransactionTest() {
- super();
- }
-
- public AbstractQueryTransactionTest(String testname) {
- super();
- this.testname = testname;
- }
-
- public String getTestName() {
- return this.testname;
- }
-
-
- @Override
- public void setConnectionStrategy(ConnectionStrategy connStrategy) {
- this.connStrategy = connStrategy;
- this.datasources = this.connStrategy.getDataSources();
-
- }
-
- public void setExecutionProperties(Properties props) {
- assertNotNull(props);
- this.executionProperties = props;
- }
- @Override
- protected void compareResults(BufferedReader resultReader, BufferedReader expectedReader) throws IOException {
- assertEquals(read(expectedReader, compareResultsCaseSensitive()) , read(resultReader, compareResultsCaseSensitive()));
- }
-
- @Override protected void assignExecutionProperties(Statement stmt) {
- 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(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP);
- if (txnautowrap != null) {
- statement.setExecutionProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, txnautowrap);
- }
-
- 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));
- }
- }
- }
-
- }
-
- public int getNumberRequiredDataSources() {
- return 1;
- }
-
- public boolean compareResultsCaseSensitive() {
- return true;
- }
-
-
- /**
- * 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 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, this.connStrategy);
- }
-
- public XAConnection getXASource(String identifier) throws QueryTestFailedException {
- return ConnectionUtil.getXAConnection(identifier, this.datasources, this.connStrategy);
- }
-
-
- /**
- * Implement testCase(), it is the entry point to the execution of the test.
- * @throws Exception
- *
- * @since
- */
- public abstract void testCase() throws Exception;
-
- /**
- * Indicates what should be done when a failure occurs in {@link #testCase()}
- * @return
- *
- * @since
- */
- public boolean rollbackAllways() {
- return false;
- }
-
- /**
- * Override <code>before</code> if there is behavior that needs to be performed
- * prior to {@link #testCase()} being called.
- *
- *
- * @since
- */
- public void before() {
- }
-
- /**
- * Override <code>after</code> if there is behavior that needs to be performed
- * after {@link #testCase()} being called.
- *
- *
- * @since
- */
- public void after() {
- }
-
-
- @Override
- public void validateTestCase() throws Exception {
-
- }
-
-
- /**
- * 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.
- */
- public void cleanup() {
-
- }
-
- @Override
- public XAConnection getXAConnection() {
- // TODO Auto-generated method stub
- return null;
- }
-
-
-
-
-}
Deleted: trunk/test-integration/db/src/test/java/org/teiid/test/framework/QueryExecution.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/framework/QueryExecution.java 2009-11-16 21:03:58 UTC (rev 1563)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/QueryExecution.java 2009-11-16 21:06:03 UTC (rev 1564)
@@ -1,21 +0,0 @@
-package org.teiid.test.framework;
-
-import java.sql.Connection;
-
-import com.metamatrix.jdbc.api.AbstractQueryTest;
-
-/**
- * The QueryExecution class can be used to query the source directly. The intended use
- * of this class is for validating results after the execution of a test case.
- *
- * @see AbstractQueryTransactionTest regarding creating a testcase to validate behavior.
- * @author vanhalbert
- *
- */
-public class QueryExecution extends AbstractQueryTest {
-
- public QueryExecution(Connection conn) {
- super(conn);
- }
-
-}
15 years, 1 month
teiid SVN: r1562 - trunk/test-integration/db/src/main/resources/ddl/mysql.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-11-16 16:02:32 -0500 (Mon, 16 Nov 2009)
New Revision: 1562
Modified:
trunk/test-integration/db/src/main/resources/ddl/mysql/create_tables.sql
Log:
Teiid 773 - fixed the create table statements for MySQL
Modified: trunk/test-integration/db/src/main/resources/ddl/mysql/create_tables.sql
===================================================================
--- trunk/test-integration/db/src/main/resources/ddl/mysql/create_tables.sql 2009-11-16 21:01:58 UTC (rev 1561)
+++ trunk/test-integration/db/src/main/resources/ddl/mysql/create_tables.sql 2009-11-16 21:02:32 UTC (rev 1562)
@@ -3,4 +3,8 @@
create Table g1 (e1 NUMERIC(5) PRIMARY KEY, e2 varchar(50));
create Table g2 (e1 NUMERIC(5) REFERENCES g1 (e1), e2 varchar(50));
+
+create Table g1 (e1 NUMERIC(5) PRIMARY KEY, e2 varchar(50))ENGINE=INNODB;
+create Table g2 (e1 NUMERIC(5), e2 varchar(50), FOREIGN KEY (e1) REFERENCES g1(e1))ENGINE=INNODB;
+
\ No newline at end of file
15 years, 1 month
teiid SVN: r1561 - trunk/test-integration/db/src/main/resources.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-11-16 16:01:58 -0500 (Mon, 16 Nov 2009)
New Revision: 1561
Modified:
trunk/test-integration/db/src/main/resources/default-config.properties
Log:
Teiid 773 - refactored back in the way jbedsp transaction classes where defined
Modified: trunk/test-integration/db/src/main/resources/default-config.properties
===================================================================
--- trunk/test-integration/db/src/main/resources/default-config.properties 2009-11-16 21:01:11 UTC (rev 1560)
+++ trunk/test-integration/db/src/main/resources/default-config.properties 2009-11-16 21:01:58 UTC (rev 1561)
@@ -2,10 +2,6 @@
# Common Properties for everybody
##########################################
-
-# local, xa, jndi
-#transaction-type=local
-
process-batch = 20
connector-batch = 20
@@ -41,7 +37,7 @@
#
# By providing the numerical order, it indicates which datasource to assign based on the order in the usedatasources property.
#
-# If -Dusedatasources is not set, then the datasource will be assigned in the order they are calling to obtain a datasource.
+# If -Dusedatasources is not set, then the datasource will be assigned randomly when obtaining a datasource.
#
#
@@ -49,29 +45,5 @@
pm2=2
-##########################################
-# For default design of testcases, these properties are in the setup method of the testcase.
-# However, you can create your own version of the config properties file
-# and specify these properties in the config file
-# NOTE: will need to set the Sytem "config" property in order to override the default-config.properties file
-##########################################
-#available types (datasource, driver, jndi)
-#connection-type=datasource
-#connection-type=driver
-
-# autocommit applies to local transaction-type only
-# default is true
-#autocommit=false
-
-# AUTO_WRAP_OFF = "OFF"
-# AUTO_WRAP_ON = "ON"
-# AUTO_WRAP_PESSIMISTIC = "PESSIMISTIC"
-# AUTO_WRAP_OPTIMISTIC = "OPTIMISTIC"
-
-#txnAutoWrap=off
-
-#-----------------------------
-
-
15 years, 1 month
teiid SVN: r1560 - trunk/test-integration/db/src/test/java/org/teiid/test/testcases.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-11-16 16:01:11 -0500 (Mon, 16 Nov 2009)
New Revision: 1560
Removed:
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/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 - refactored back in the way jbedsp transaction classes where defined
Deleted: 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-11-16 20:59:49 UTC (rev 1559)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionDriverFalseOffTest.java 2009-11-16 21:01:11 UTC (rev 1560)
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2000-2007 MetaMatrix, Inc.
- * All rights reserved.
- */
-package org.teiid.test.testcases;
-
-import org.teiid.test.framework.ConfigPropertyLoader;
-import org.teiid.test.framework.ConfigPropertyNames;
-import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
-
-
-/**
- * Local Transaction Test
- *
- * Settings:
- *
- * - Using Driver
- * - Autocommit = False
- * - TxnAutoWrap = Off
- */
-public class LocalTransactionDriverFalseOffTest extends TwoSourceTransactionScenarios {
-
- public LocalTransactionDriverFalseOffTest(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- 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");
- this.addProperty(ConfigPropertyNames.CONFIG_FILE, ConfigPropertyLoader.DEFAULT_CONFIG_FILE_NAME);
-
-
- }
-
-
-
-
-
-
-
-
-}
Deleted: 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-11-16 20:59:49 UTC (rev 1559)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionDriverTrueOffTest.java 2009-11-16 21:01:11 UTC (rev 1560)
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2000-2007 MetaMatrix, Inc.
- * All rights reserved.
- */
-package org.teiid.test.testcases;
-
-import org.teiid.test.framework.ConfigPropertyLoader;
-import org.teiid.test.framework.ConfigPropertyNames;
-import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
-
-
-/**
- * Local Transaction Test
- *
- * Settings:
- *
- * - Using Driver
- * - Autocommit = True
- * - TxnAutoWrap = Off
- */
-public class LocalTransactionDriverTrueOffTest extends TwoSourceTransactionScenarios {
-
- public LocalTransactionDriverTrueOffTest(String name) {
- super(name);
- }
-
- @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");
- this.addProperty(ConfigPropertyNames.CONFIG_FILE, ConfigPropertyLoader.DEFAULT_CONFIG_FILE_NAME);
-
-
- }
-
-}
Deleted: 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-11-16 20:59:49 UTC (rev 1559)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionScenarios.java 2009-11-16 21:01:11 UTC (rev 1560)
@@ -1,247 +0,0 @@
-/*
- * Copyright (c) 2000-2007 MetaMatrix, Inc.
- * All rights reserved.
- */
-package org.teiid.test.testcases;
-
-
-
-import org.teiid.test.framework.query.AbstractQueryTransactionTest;
-import org.teiid.test.framework.query.QueryExecution;
-
-import com.metamatrix.jdbc.api.AbstractQueryTest;
-
-
-
-/**
- * A common SingleSource test case among many different transaction stuff.
- */
-public class SingleSourceTransactionScenarios extends BaseAbstractTransactionTestCase {
-
- public SingleSourceTransactionScenarios(String name) {
- super(name);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////////////////////////
- // Single Source - Rows below 500 (for insert/update/delete)
- ///////////////////////////////////////////////////////////////////////////////////////////////
-
- /**
- * Sources = 1
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourceSelect() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceSelect") {
- public void testCase() throws Exception {
- execute("select * from pm1.g1 where pm1.g1.e1 < 100");
- assertRowCount(100);
- }
-
-
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- }
-
-
- /**
- * Sources = 1
- * Commands = 1, Update
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourceUpdate() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceUpdate") {
- public void testCase() throws Exception {
- execute("insert into pm1.g1 (e1, e2) values(100, '100')");
- }
- public void validateTestCase() throws Exception {
- // now verify the results
- AbstractQueryTest test = new QueryExecution(getSource("pm1"));
- test.execute("select * from g1 where e1 = 100");
- test.assertRowCount(1);
- test.closeConnection();
-
- }
-
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- }
-
-
- /**
- * Sources = 1
- * Commands = 1, Update(prepared statement)
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourcePreparedUpdate() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourcePreparedUpdate") {
- public void testCase() throws Exception {
- execute("insert into pm1.g1 (e1, e2) values(?, ?)", new Object[] {new Integer(102), "102"});
- }
- public void validateTestCase() throws Exception {
- // now verify the results
- AbstractQueryTest test = new QueryExecution(getSource("pm1"));
- test.execute("select * from g1 where e1 = 102");
- test.assertRowCount(1);
- test.closeConnection();
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- }
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourceMultipleCommands() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceMultipleCommands") {
- public void testCase() throws Exception {
-
- execute("delete from pm1.g1 where pm1.g1.e1 >= ?", new Object[] {new Integer(100)});
-
- execute("select * from pm1.g1");
- assertRowCount(100);
-
- for (int i = 100; i < 110; i++) {
- Integer val = new Integer(i);
- execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- }
- }
-
- public void validateTestCase() throws Exception {
- // now verify the results
- AbstractQueryTest test = new QueryExecution(getSource("pm1"));
- test.execute("select * from g1 where e1 >= 100");
- test.assertRowCount(10);
- test.execute("select * from g2 where e1 >= 100");
- test.assertRowCount(10);
- test.closeConnection();
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- }
-
- /**
- * Sources = 1
- * Commands = 1, Select
- * Batching = Partial Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourcePartialProcessing() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourcePartialProcessing") {
- public void testCase() throws Exception {
- execute("select * from pm1.g1 where pm1.g1.e1 < 100 limit 10");
- assertRowCount(10);
- }
-
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- }
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = rollback
- */
-
- public void testSingleSourceMultipleCommandsExplicitRollback() throws Exception {
-
-
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceMultipleCommandsExplicitRollback") {
- public void testCase() throws Exception {
- for (int i = 200; i < 220; i++) {
- execute("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
- execute("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
- }
- }
-
- public boolean rollbackAllways() {
- return true;
- }
-
- public void validateTestCase() throws Exception {
- // now verify the results
- 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();
- }
-
-
- };
-
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- }
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = rollback
- */
- public void testSingleSourceMultipleCommandsReferentialIntegrityRollback() throws Exception {
-
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceMultipleCommandsReferentialIntegrityRollback") {
- public void testCase() throws Exception {
- for (int i = 200; i < 220; i++) {
- Integer val = new Integer(i);
- execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- }
-
- // force the rollback by trying to insert an invalid row.
- execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- public void validateTestCase() throws Exception {
- // now verify the results
- AbstractQueryTest test = new QueryExecution(getSource("pm1"));
- test.execute("select * from g1 where e1 >= 200 and e1 < 220");
- test.assertRowCount(0);
- test.closeConnection();
- }
- };
-
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- }
-
-
-
-
-}
Deleted: 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-11-16 20:59:49 UTC (rev 1559)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionScenarios.java 2009-11-16 21:01:11 UTC (rev 1560)
@@ -1,779 +0,0 @@
-/*
- * Copyright (c) 2000-2007 MetaMatrix, Inc.
- * All rights reserved.
- */
-package org.teiid.test.testcases;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.ArrayList;
-
-import org.teiid.test.framework.ConfigPropertyNames;
-import org.teiid.test.framework.query.AbstractQueryTransactionTest;
-import org.teiid.test.framework.query.QueryExecution;
-
-import com.metamatrix.jdbc.api.AbstractQueryTest;
-
-
-
-/**
- * Test cases that require 2 datasources
- */
-public class TwoSourceTransactionScenarios extends SingleSourceTransactionScenarios {
-
- public TwoSourceTransactionScenarios(String name) {
- super(name);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////////////////////////
- // Multiple Sources - Rows from 500
- ///////////////////////////////////////////////////////////////////////////////////////////////
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceSelect() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceSelect") {
- public void testCase() throws Exception {
- execute("select * from pm1.g1 join pm2.g1 on pm1.g1.e1 = pm2.g1.e1 where pm1.g1.e1 < 100");
- assertRowCount(100);
- }
-
- public int getNumberRequiredDataSources(){
- return 2;
- }
-
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- }
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceViewSelect() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceViewSelect") {
- public void testCase() throws Exception {
- execute("select * from vm.g1 where vm.g1.pm1e1 < 100");
- assertRowCount(100);
- }
- public int getNumberRequiredDataSources(){
- return 2;
- }
-
-
- };
-
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- }
-
- /**
- * Sources = 2
- * Commands = 1, Update
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceViewUpdate() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceViewUpdate") {
- public void testCase() throws Exception {
- execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(500, '500', 500, '500')");
- }
-
- public int getNumberRequiredDataSources(){
- return 2;
- }
-
- public void validateTestCase() throws Exception {
-
- // now verify the results
- AbstractQueryTest test = new QueryExecution(getSource("pm1"));
- test.execute("select * from g1 where e2 = '500'");
- test.assertRowCount(1);
- test.closeConnection();
-
- test = new QueryExecution(getSource("pm2"));
- test.execute("select * from g1 where e2 = '500'");
- test.assertRowCount(1);
- test.closeConnection();
- }
-
- };
-
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- }
-
- /**
- * Sources = 2
- * Commands = 1, Update
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceViewSelectInto() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceViewSelectInto") {
- public void testCase() throws Exception {
- execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(501, '501', 501, '501')");
- execute("select pm1.g1.e1, pm1.g1.e2 into pm2.g2 from pm1.g1 where pm1.g1.e1 = 501");
- }
-
- public int getNumberRequiredDataSources(){
- return 2;
- }
-
- public void validateTestCase() throws Exception {
-
- // now verify the results
- AbstractQueryTest test = new QueryExecution(getSource("pm1"));
- test.execute("select * from g1 where e2 = '501'");
- test.assertRowCount(1);
- test.closeConnection();
-
- test = new QueryExecution(getSource("pm2"));
- test.execute("select * from g1 where e2 = '501'");
- test.assertRowCount(1);
- test.closeConnection();
-
- }
-
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- }
-
- /**
- * Sources = 2
- * Commands = 1, Update
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceViewBulkRowInsert() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceViewBulkRowInsert") {
- public void testCase() throws Exception {
- for (int i = 100; i < 112; i++) {
- Integer val = new Integer(i);
- execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});
- }
- execute("select pm1.g1.e1, pm1.g1.e2 into pm2.g2 from pm1.g1 where pm1.g1.e1 >= 100");
- }
-
- public int getNumberRequiredDataSources(){
- return 2;
- }
- public void validateTestCase() throws Exception {
-
- // now verify the results
- Connection ds = getSource("pm1");
- System.out.println("Datasource: " + ds.getMetaData().getDatabaseProductName());
- AbstractQueryTest test = new QueryExecution(ds);
- test.execute("select * from g1 where e1 >= 100 and e1 < 112");
- test.assertRowCount(12);
- test.closeConnection();
-
- test = new QueryExecution(getSource("pm2"));
- test.execute("select * from g1 where e1 >= 100 and e1 < 112");
- test.assertRowCount(12);
- test.execute("select * from g2 where e1 >= 100 and e1 < 112");
- test.assertRowCount(12);
- test.closeConnection();
- }
-
-
- };
-
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
- }
-
- /**
- * Sources = 2
- * Commands = 1, Update
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceViewBulkRowInsertRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceViewBulkRowInsertRollback") {
- public void testCase() throws Exception {
- for (int i = 100; i < 120; i++) {
- Integer val = new Integer(i);
- execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});
- }
- execute("select pm1.g1.e1, pm1.g1.e2 into pm2.g2 from pm1.g1 where pm1.g1.e1 >= 100");
-
- // force the rollback by trying to insert an invalid row.
- execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- public int getNumberRequiredDataSources(){
- return 2;
- }
-
-
- public void validateTestCase() throws Exception {
- // now verify the results
- AbstractQueryTest test = new QueryExecution(getSource("pm1"));
- test.execute("select * from g1 where e1 >= 100 and e1 < 120");
- test.assertRowCount(0);
- test.closeConnection();
-
- test = new QueryExecution(getSource("pm2"));
- test.execute("select * from g1 where e1 >= 100 and e1 < 120");
- test.assertRowCount(0);
- test.execute("select * from g2 where e1 >= 100 and e1 < 120");
- test.assertRowCount(0);
- test.closeConnection();
- }
-
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- }
-
-
- /**
- * Sources = 2
- * Commands = 1, Update(prepared statement)
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceViewPreparedUpdate() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceViewPreparedUpdate") {
- public void testCase() throws Exception {
- Integer value = new Integer(500);
- execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {value, value.toString(), value, value.toString()});
- }
- public int getNumberRequiredDataSources(){
- return 2;
- }
-
- public void validateTestCase() throws Exception {
-
- // now verify the results
- AbstractQueryTest test = new QueryExecution(getSource("pm1"));
- test.execute("select * from g1 where e1 = 500");
- test.assertRowCount(1);
- test.closeConnection();
-
- test = new QueryExecution(getSource("pm2"));
- test.execute("select * from g1 where e1 = 500");
- test.assertRowCount(1);
- test.closeConnection();
- }
-
- };
-
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- }
-
-
- /**
- * Sources = 2
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- 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)});
- execute("delete from pm1.g1 where e1 >= ?", new Object[] {new Integer(100)});
- execute("delete from pm2.g2 where e1 >= ?", new Object[] {new Integer(100)});
- execute("delete from pm2.g1 where e1 >= ?", new Object[] {new Integer(100)});
-
- execute("select * from pm1.g1");
- assertRowCount(100);
-
- for (int i = 100; i < 115; i++) {
- Integer val = new Integer(i);
- execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
-
- execute("insert into pm2.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- execute("insert into pm2.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- }
-
- execute("update pm1.g1 set e2='blah' where e1 > 100");
- }
- public int getNumberRequiredDataSources(){
- return 2;
- }
-
- // because different databases return "varchar" in all caps "VARCHAR"
- // the comparison is being done in a noncasesensitive manner
- public boolean compareResultsCaseSensitive() {
- return false;
- }
-
- public void validateTestCase() throws Exception {
-
- // now verify the results
- AbstractQueryTest test = new QueryExecution(getSource("pm1"));
- test.execute("select * from g1 where e1 >= 100 and e1 < 115");
- test.assertRowCount(15);
- test.execute("select * from g2 where e1 >= 100 and e1 < 115");
- test.assertRowCount(15);
- test.execute("select distinct e2 from g1 where e1 > 100");
-
- // assertResultsSetEquals(this.internalResultSet., new String[] {"e2[varchar]", "blah"});
-
- test.assertResultsSetEquals(new String[] {"e2[varchar]", "blah"});
- test.closeConnection();
- }
-
- };
-
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- }
-
- /**
- * Sources = 2
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceViewMultipleCommands() throws Exception {
- // this.setAssignModelToDatabaseType("pm1", DataSourceFactory.DataBaseTypes.);
-
- this.addProperty(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP, "oracle");
-
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceViewMultipleCommands") {
- public void testCase() throws Exception {
-
- for (int i = 200; i < 207; i++) {
- Integer val = new Integer(i);
- execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});
- execute("insert into vm.g2 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});
- }
-
- execute("update vm.g1 set pm1e2='blah' where pm1e1 >= 200");
-
- execute("delete from vm.g2 where vm.g2.pm1e1 >= 205");
- execute("delete from vm.g1 where vm.g1.pm1e1 >= 205");
-
- execute("select * from vm.g1 where pm1e1 >= 200 and pm1e1 < 207");
- assertRowCount(5);
- }
- public int getNumberRequiredDataSources(){
- return 2;
- }
-
- public void validateTestCase() throws Exception {
- // now verify the results
- AbstractQueryTest test = new QueryExecution(getSource("pm1"));
- test.execute("select * from g1 where e1 >= 200 and e1 < 207");
- test.assertRowCount(5);
- test.execute("select * from g2 where e1 >= 200 and e1 < 207");
- test.assertRowCount(5);
- test.execute("select distinct e2 from g1 where e1 >= 200 and e1 < 207");
- test.assertResultsSetEquals(new String[] {"e2[varchar]", "blah"});
- test.closeConnection();
-
- }
-
- };
-
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
-
- }
-
- /**
- * Sources = 2
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceViewMultipleCommandsRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceViewMultipleCommandsRollback") {
- public void testCase() throws Exception {
-
- for (int i = 600; i < 615; i++) {
- Integer val = new Integer(i);
- execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});
- execute("insert into vm.g2 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});
- }
-
- execute("select * from vm.g1 where pm1e1 >= 600 and pm1e1 < 615");
- assertRowCount(15);
-
-
- execute("update vm.g1 set pm1e2='blah' where pm1e1 >= 605");
-
- execute("delete from vm.g2 where vm.g2.pm1e1 >= 610");
- execute("delete from vm.g1 where vm.g1.pm1e1 >= 610");
-
- execute("select * from vm.g1 where pm1e1 >= 600 and pm1e1 < 615");
- assertRowCount(10);
-
- // force the rollback by trying to insert an invalid row.
- execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- public int getNumberRequiredDataSources(){
- return 2;
- }
-
-
- public void validateTestCase() throws Exception {
- // now verify the results
- AbstractQueryTest test = new QueryExecution(getSource("pm1"));
- test.execute("select * from g1 where e1 >= 600 and e1 < 615");
- test.assertRowCount(0);
- test.execute("select * from g2 where e1 >= 600 and e1 < 615");
- test.assertRowCount(0);
- test.execute("select distinct e2 from g1 where e1 >= 600 and e1 < 615");
- test.assertRowCount(0);
- test.closeConnection();
- }
-
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- }
-
-
- /**
- * Sources = 2
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = rollback
- */
- public void testMultipleSourceMultipleCommandsCancel() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleCommandsCancel") {
-
- public void testCase() throws Exception {
- Thread t = new Thread("Cancel Thread") {
- public void run() {
- try {
- try {
- Thread.sleep(500);
- cancelQuery();
- } catch (SQLException e) {
- print(e);
- // debug(e.getMessage());
- }
- } catch (InterruptedException e) {}
- }
- };
- t.start();
- executeBatch(getMultipleSourceBatch());
- }
-
- /**
- * @see com.metamatrix.transaction.test.framework.AbstractQueryTest#exceptionExpected()
- */
- public boolean exceptionExpected() {
- return true;
- }
-
- public int getNumberRequiredDataSources(){
- return 2;
- }
-
-
- public void validateTestCase() throws Exception {
- // now verify the results (this may finish under one second, then this test is not valid)
- AbstractQueryTest test = new QueryExecution(getSource("pm1"));
- test.execute("select * from g1 where e1 >= 600 and e1 < 650");
- test.assertRowCount(0);
- test.execute("select * from g2 where e1 >= 600 and e1 < 650");
- test.assertRowCount(0);
- test.execute("select distinct e2 from g1 where e1 >= 600 and e1 < 650");
- test.assertRowCount(0);
- test.closeConnection();
-
- }
-
- };
- getTransactionContainter().runTransaction(userTxn);
-
- }
-
-
- /**
- * Sources = 2
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = rollback
- */
- public void testMultipleSourceMultipleCommandsExplicitRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleCommandsExplicitRollback") {
- public void testCase() throws Exception {
-
- for (int i = 700; i < 720; i++) {
- Integer val = new Integer(i);
- execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
-
- execute("insert into pm2.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- execute("insert into pm2.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- }
- }
-
- // force the rollback
- public boolean rollbackAllways() {
- return true;
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- public int getNumberRequiredDataSources(){
- return 2;
- }
-
-
- public void validateTestCase() throws Exception {
- // now verify the results
- AbstractQueryTest test = new QueryExecution(getSource("pm1"));
- test.execute("select * from g1 where e1 >= 700 and e1 < 720");
- test.assertRowCount(0);
- test.closeConnection();
-
- test = new QueryExecution(getSource("pm2"));
- test.execute("select * from g1 where e1 >= 700 and e1 < 720");
- test.assertRowCount(0);
- test.closeConnection();
-
- }
-
-
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- }
-
- /**
- * Sources = 2
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = rollback
- */
- public void testMultipleSourceMultipleCommandsReferentialIntegrityRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleCommandsReferentialIntegrityRollback") {
- public void testCase() throws Exception {
-
- for (int i = 700; i < 720; i++) {
- Integer val = new Integer(i);
- execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
-
- execute("insert into pm2.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- execute("insert into pm2.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
- }
-
- // force the rollback by trying to insert an invalid row.
- execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- public int getNumberRequiredDataSources(){
- return 2;
- }
-
-
- public void validateTestCase() throws Exception {
- // now verify the results
- AbstractQueryTest test = new QueryExecution(getSource("pm1"));
- test.execute("select * from g1 where e1 >= 700 and e1 < 720");
- test.assertRowCount(0);
- test.closeConnection();
-
- test = new QueryExecution(getSource("pm2"));
- test.execute("select * from g1 where e1 >= 700 and e1 < 720");
- test.assertRowCount(0);
- test.closeConnection();
- }
-
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- }
-
-
-
- /**
- * Sources = 2
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = rollback
- */
- public void testMultipleSourceTimeout() throws Exception{
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceTimeout") {
- public void testCase() throws Exception {
- executeBatch(getMultipleSourceBatch(), 1); // time out after 1 sec
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- public void after() {
- if (!exceptionOccurred()) {
- fail("should have failed with time out exception");
- }
- else if (getLastException() != null){
- if (getLastException().getMessage().indexOf("Operation timed out before completion") != -1) {
- assertTrue(false);
- }
- } else {
- fail("The expected exception was not saved.");
- }
- }
-
- public int getNumberRequiredDataSources(){
- return 2;
- }
-
-
- public void validateTestCase() throws Exception {
- // now verify the results (this may finish under one second, then this test is not valid)
- AbstractQueryTest test = new QueryExecution(getSource("pm1"));
- test.execute("select * from g1 where e1 >= 600 and e1 < 750");
- test.assertRowCount(0);
- test.execute("select * from g2 where e1 >= 600 and e1 < 750");
- test.assertRowCount(0);
- test.execute("select distinct e2 from g1 where e1 >= 600 and e1 < 750");
- test.assertRowCount(0);
- test.closeConnection();
- }
-
- };
- getTransactionContainter().runTransaction(userTxn);
-
- }
-
-
- static String[] getMultipleSourceBatch() {
- ArrayList<String> list = new ArrayList<String>();
-
- for (int i = 600; i < 750; i++) {
- list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
- list.add("insert into pm1.g2 (e1, e2) values ("+i+",'"+i+"')");
- list.add("insert into pm2.g1 (e1, e2) values("+i+",'"+i+"')");
- list.add("insert into pm2.g2 (e1, e2) values ("+i+",'"+i+"')");
- }
-
- list.add("update pm1.g1 set e2='blah' where pm1.g1.e1 >= 600");
- list.add("update pm2.g1 set e2='blah' where pm2.g1.e1 >= 600");
-
- list.add("delete from pm1.g2 where pm1.g2.e1 >= 610");
- list.add("delete from pm1.g1 where pm1.g1.e1 >= 610");
- list.add("delete from pm2.g2 where pm2.g2.e1 >= 610");
- list.add("delete from pm2.g1 where pm2.g1.e1 >= 610");
-
- return(String[])list.toArray(new String[list.size()]);
- }
-
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Partial Processing, Single Connector Batch
- * result = commit
- * Note: This is producing the below error some times; however this is SQL Server issue.
- * http://support.microsoft.com/?kbid=834849
- */
- public void testMultipleSourceViewPartialProcessingUsingLimit() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceViewPartialProcessingUsingLimit") {
- public void testCase() throws Exception {
- execute("select * from vm.g1 where pm1e1 < 100 limit 10");
- assertRowCount(10);
- }
-
- public int getNumberRequiredDataSources(){
- return 2;
- }
-
-
- public void validateTestCase() throws Exception {
- }
-
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- }
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Partial Processing, Single Connector Batch
- * result = commit
- * Note: This is producing the below error some times; however this is SQL Server issue.
- * http://support.microsoft.com/?kbid=834849
- */
- public void testMultipleSourcePartialProcessingUsingMakedep() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourcePartialProcessingUsingMakedep") {
- public void testCase() throws Exception {
- execute("select pm1.g1.e1, pm1.g1.e2 from pm1.g1 LEFT OUTER JOIN pm2.g1 MAKENOTDEP ON pm1.g1.e2 = pm2.g1.e2 where pm2.g1.e1 >= 50 and pm2.g1.e1 < 100");
- assertRowCount(50);
- }
-
- public int getNumberRequiredDataSources(){
- return 2;
- }
-
-
- public void validateTestCase() throws Exception {
- }
-
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- }
-
-
-
-
-
-
-
-}
Deleted: 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-11-16 20:59:49 UTC (rev 1559)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/XATransactionDatasourceFalseOffTest.java 2009-11-16 21:01:11 UTC (rev 1560)
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2000-2007 MetaMatrix, Inc.
- * All rights reserved.
- */
-package org.teiid.test.testcases;
-
-import org.teiid.test.framework.ConfigPropertyNames;
-import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
-
-
-/**
- * Local Transaction Test
- *
- * Settings:
- *
- * - Transaction Type = local
- * - Using Driver
- * - Autocommit = True
- * - TxnAutoWrap = Off
- */
-//public class XATransactionDatasourceFalseOffTest extends SingleSourceTransactionScenarios {
-
- public class XATransactionDatasourceFalseOffTest extends TwoSourceTransactionScenarios {
-
-
-
- public XATransactionDatasourceFalseOffTest(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- //XATransactions currently doesn't support using sqlserver
- //{@see TEIID-559}
- this.addProperty(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP, "sqlserver");
-
- this.addProperty(ConfigPropertyNames.CONFIG_FILE, "xa-config.properties");
-
- this.addProperty(ConfigPropertyNames.CONNECTION_TYPE, ConfigPropertyNames.CONNECTION_TYPES.DATASOURCE_CONNECTION);
- this.addProperty(CONNECTION_STRATEGY_PROPS.AUTOCOMMIT, "false");
- // this.addProperty(ConnectionStrategy.TXN_AUTO_WRAP, "on");
-
-
- }
-
-
-
-}
15 years, 1 month
teiid SVN: r1559 - trunk/test-integration/db/src/test/java/org/teiid/test/testcases.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-11-16 15:59:49 -0500 (Mon, 16 Nov 2009)
New Revision: 1559
Added:
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OffWrapTransactionTests.java
Log:
Teiid 773 - refactored back in the way jbedsp transaction classes where defined
Added: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OffWrapTransactionTests.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OffWrapTransactionTests.java (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OffWrapTransactionTests.java 2009-11-16 20:59:49 UTC (rev 1559)
@@ -0,0 +1,283 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+import java.util.ArrayList;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.query.AbstractQueryTransactionTest;
+import org.teiid.test.framework.query.QueryExecution;
+import org.teiid.test.framework.transaction.OffWrapTransaction;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+
+public class OffWrapTransactionTests extends BaseAbstractTransactionTestCase {
+
+
+
+ public OffWrapTransactionTests(String testName) {
+ super(testName);
+ }
+
+ @Override
+ protected TransactionContainer getTransactionContainter() {
+ // TODO Auto-generated method stub
+ return new OffWrapTransaction();
+ }
+
+
+
+ /**
+ * Sources = 1
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceSelect() throws Exception {
+
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceSelect") {
+ public void testCase() throws Exception {
+ execute("select * from pm1.g1 where pm1.g1.e1 < 100");
+ assertRowCount(100);
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+
+
+ /**
+ * Sources = 1
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceUpdate") {
+ public void testCase() throws Exception {
+ execute("insert into pm1.g1 (e1, e2) values(100, '100')");
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 = 100");
+ test.assertRowCount(1);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceMultipleCommands() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceMultipleCommands") {
+ public void testCase() throws Exception {
+ execute("delete from pm1.g1 where pm1.g1.e1 >= ?", new Object[] {new Integer(100)});
+ execute("select * from pm1.g1");
+ assertRowCount(100);
+ for (int i = 100; i < 110; i++) {
+ Integer val = new Integer(i);
+ execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ }
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 100");
+ test.assertRowCount(10);
+ test.execute("select * from g2 where e1 >= 100");
+ test.assertRowCount(10);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = rollback
+ */
+ public void testSingleSourceMultipleCommandsReferentialIntegrityRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+
+ for (int i = 200; i < 210; i++) {
+ Integer val = new Integer(i);
+ execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ }
+
+ // force the rollback by trying to insert an invalid row.
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
+ }
+ public boolean exceptionExpected() {
+ return true;
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 200");
+ test.assertRowCount(10);
+ test.closeConnection();
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+ // Multiple Sources - Rows from 500
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from pm1.g1 join pm2.g1 on pm1.g1.e1 = pm2.g1.e1 where pm1.g1.e1 < 100");
+ assertRowCount(100);
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(500, '500', 500, '500')");
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 = 500");
+ test.assertRowCount(1);
+ test.closeConnection();
+
+ test = new QueryExecution(userTxn.getSource("pm2"));
+ test.execute("select * from g1 where e1 = 500");
+ test.assertRowCount(1);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = rollback
+ */
+ public void testMultipleSourceMultipleCommandsReferentialIntegrityRollback() throws Exception {
+
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+
+ for (int i = 700; i < 710; i++) {
+ Integer val = new Integer(i);
+ execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+
+ execute("insert into pm2.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm2.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ }
+
+ // force the rollback by trying to insert an invalid row.
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 700 and e1 < 710");
+ test.assertRowCount(10);
+ test.closeConnection();
+
+ test = new QueryExecution(userTxn.getSource("pm2"));
+ test.execute("select * from g1 where e1 >= 700 and e1 < 710");
+ test.assertRowCount(10);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceBulkRowInsert() throws Exception {
+
+
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ ArrayList list = new ArrayList();
+ public void testCase() throws Exception {
+ for (int i = 800; i < 807; i++) {
+ list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+ list.add("insert into pm2.g1 (e1, e2) values("+i+",'"+i+"')");
+ }
+ list.add("select pm1.g1.e1, pm1.g1.e2 into pm2.g2 from pm1.g1 where pm1.g1.e1 >= 800");
+
+ // force the rollback by trying to insert an invalid row.
+ list.add("insert into pm1.g2 (e1, e2) values(9999,'9999')");
+
+ // execute((String[])list.toArray(new String[list.size()]));
+ executeBatch((String[])list.toArray(new String[list.size()]), -1);
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 800 and e1 < 807");
+ test.assertRowCount(7);
+ test.closeConnection();
+
+ test = new QueryExecution(userTxn.getSource("pm2"));
+ test.execute("select * from g1 where e1 >= 800 and e1 < 807");
+ test.assertRowCount(7);
+ test.execute("select * from g2 where e1 >= 800 and e1 < 807");
+ test.assertRowCount(7);
+ test.closeConnection();
+ }
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OffWrapTransactionTests.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 1 month
teiid SVN: r1558 - trunk/test-integration/db/src/test/java/org/teiid/test/testcases.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-11-16 15:59:28 -0500 (Mon, 16 Nov 2009)
New Revision: 1558
Modified:
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java
Log:
Teiid 773 - cleanup and refactoring so that the assumption is there will be 2 datasources required in order to run the test.
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-11-16 20:59:07 UTC (rev 1557)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java 2009-11-16 20:59:28 UTC (rev 1558)
@@ -1,61 +1,58 @@
-/*
- * Copyright (c) 2000-2007 MetaMatrix, Inc.
- * All rights reserved.
- */
package org.teiid.test.testcases;
-
-
import junit.framework.TestCase;
import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.exception.QueryTestFailedException;
-import org.teiid.test.framework.transaction.TransactionFactory;
+import org.teiid.test.framework.datasource.DataSourceFactory;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
-public class BaseAbstractTransactionTestCase extends TestCase {
+public abstract class BaseAbstractTransactionTestCase extends TestCase {
+
+ protected ConfigPropertyLoader config = null;
+ protected TransactionContainer container = null;
+ protected boolean setupData = true;
- protected ConfigPropertyLoader config = null;
-
public BaseAbstractTransactionTestCase(String name) {
- super(name);
+ super(name);
+
+
}
-
+
+ protected abstract TransactionContainer getTransactionContainter();
-
- @Override
- protected void setUp() throws Exception {
- // TODO Auto-generated method stub
- super.setUp();
-
- config = ConfigPropertyLoader.createInstance();
- }
-
-
protected ConfigPropertyLoader getConfig() {
- return this.config;
+ return this.config;
}
- protected void addProperty(String key, String value) {
- config.setProperty(key, value);
- }
-
- /**
- * Call to assign a specific database type to the model. When a datasource is requested for this model,
- * a datasource of the specific dbtype will be returned. See {@link DataSourceFactory} for the logic that
- * controls this behavior.
- * @param modelName
- * @param dbtype
- *
- * @since
- */
- protected void setAssignModelToDatabaseType(String modelName, String dbtype) {
- config.setModelAssignedToDatabaseType(modelName, dbtype);
+ protected void addProperty(String key, String value) {
+ if (config == null) {
+ try {
+ setUp();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ throw new TransactionRuntimeException(e);
+ }
}
-
- protected TransactionContainer getTransactionContainter() throws QueryTestFailedException {
- return TransactionFactory.create(config);
- }
+ config.setProperty(key, value);
+ }
+ /**
+ * Call to assign a specific database type to the model. When a datasource
+ * is requested for this model, a datasource of the specific dbtype will be
+ * returned. See {@link DataSourceFactory} for the logic that controls this
+ * behavior.
+ *
+ * @param modelName
+ * @param dbtype
+ *
+ * @since
+ */
+ protected void setAssignModelToDatabaseType(String modelName, String dbtype) {
+ config.setModelAssignedToDatabaseType(modelName, dbtype);
+ }
+
+
+
}
15 years, 1 month
teiid SVN: r1557 - trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-11-16 15:59:07 -0500 (Mon, 16 Nov 2009)
New Revision: 1557
Added:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OffWrapTransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OnWrapTransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java
Log:
Teiid 773 - refactored back in the way jbedsp transaction classes where defined
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OffWrapTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OffWrapTransaction.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OffWrapTransaction.java 2009-11-16 20:59:07 UTC (rev 1557)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.transaction;
+
+import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.TransactionQueryTest;
+import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
+import org.teiid.test.framework.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
+
+
+
+/**
+ * This transction is only valid when
+ * AutoCommit = ON
+ * txnAutoWrap = OFF
+ */
+public class OffWrapTransaction extends TransactionContainer {
+
+ public OffWrapTransaction() {
+ super();
+ }
+
+ public void before(TransactionQueryTest test) {
+ this.setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_OFF);
+
+
+ }
+
+ public void after(TransactionQueryTest test) {
+
+ }
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OffWrapTransaction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OnWrapTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OnWrapTransaction.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OnWrapTransaction.java 2009-11-16 20:59:07 UTC (rev 1557)
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.transaction;
+
+import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.TransactionQueryTest;
+import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
+import org.teiid.test.framework.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
+
+
+/**
+ * This transction is only valid when
+ * AutoCommit = ON
+ * txnAutoWrap = ON
+ */
+public class OnWrapTransaction extends TransactionContainer {
+ public OnWrapTransaction() {
+ super();
+ }
+
+ public void before(TransactionQueryTest test) {
+ this.setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_ON);
+
+
+ }
+
+ public void after(TransactionQueryTest test) {
+
+ }
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OnWrapTransaction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java 2009-11-16 20:59:07 UTC (rev 1557)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.transaction;
+
+import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.TransactionQueryTest;
+import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
+import org.teiid.test.framework.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
+
+
+/**
+ * This transction is only valid when
+ * AutoCommit = ON
+ * txnAutoWrap = Optimistic.
+ */
+public class OptimisticWrapTransaction extends TransactionContainer {
+ public OptimisticWrapTransaction() {
+ super();
+ }
+
+ public void before(TransactionQueryTest test) {
+ this.setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_OPTIMISTIC);
+
+ }
+
+ public void after(TransactionQueryTest test) {
+
+ }
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java 2009-11-16 20:59:07 UTC (rev 1557)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.transaction;
+
+import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.TransactionQueryTest;
+import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
+import org.teiid.test.framework.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
+
+
+/**
+ * This transaction type only is valid when
+ * AutoCommit = ON
+ * txnAutoWrap = PESSIMISTIC
+ */
+public class PessimisticWrapTransaction extends TransactionContainer {
+ public PessimisticWrapTransaction() {
+ super();
+ }
+
+ public void before(TransactionQueryTest test) {
+ this.setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_PESSIMISTIC);
+
+ }
+
+ public void after(TransactionQueryTest test) {
+
+ }
+
+
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 1 month
teiid SVN: r1556 - in trunk/test-integration/db/src/main/java/org/teiid/test/framework: transaction and 1 other directory.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-11-16 15:58:17 -0500 (Mon, 16 Nov 2009)
New Revision: 1556
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.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 - cleanup and refactoring so that the assumption is there will be 2 datasources required in order to run the test.
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java 2009-11-16 20:57:50 UTC (rev 1555)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java 2009-11-16 20:58:17 UTC (rev 1556)
@@ -4,15 +4,9 @@
*/
package org.teiid.test.framework.query;
-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.SQLException;
import java.sql.Statement;
-import java.util.Map;
import java.util.Properties;
import javax.sql.XAConnection;
@@ -21,219 +15,240 @@
import org.teiid.test.framework.TransactionQueryTest;
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.datasource.DataStore;
import org.teiid.test.framework.exception.QueryTestFailedException;
-import com.metamatrix.jdbc.api.AbstractQueryTest;
-/**
- * The AbstractQueryTransactionTest is the class that should be extended when
- * a testcase is being created to validate certain behavior
+/**
+ * The AbstractQueryTransactionTest is the base implementation for the
+ * {@link TransactionQueryTest}. This provides the default logic for perform a testcase.
+ * The only method to implement in order to perform a basic, single datasource, test
+ * is the {@link #testCase()} method.
*
- * @see QueryExecution for use when direct queries to the source are used
- * to validate the results of the testcase.
+ * AbstractQueryTransactionTest is the class that should be extended when a
+ * testcase is being created to validate certain behavior
*
+ * <br>
+ * The following methods are useful when writing validation logic because they provide
+ * a direct connection to the datasource that was used by the VDB. This enables data
+ * validation of expected behavior of Teiid.
+ * <li>{@link #getSource(String)}. </li>
+ * <li>{@link #getXASource(String)} </li>
+ *
+ * <br>
+ *
+ * @see QueryExecution for use when direct queries to the source are used to
+ * validate the results of the testcase.
+ *
*/
-public abstract class AbstractQueryTransactionTest extends AbstractQueryTest implements TransactionQueryTest{
- protected Properties executionProperties = null;
- protected String testname = "NA";
- protected int fetchSize = -1;
- protected int queryTimeout = -1;
-
- protected Map<String, DataSource> datasources = null;
-
- protected ConnectionStrategy connStrategy;
-
-
- public AbstractQueryTransactionTest() {
- super();
- }
-
- public AbstractQueryTransactionTest(String testname) {
- super();
- this.testname = testname;
- }
-
- public String getTestName() {
- return this.testname;
- }
-
-
- @Override
- public void setConnectionStrategy(ConnectionStrategy connStrategy) {
- this.connStrategy = connStrategy;
-
- this.datasources = this.connStrategy.getDataSources();
-
- }
+public abstract class AbstractQueryTransactionTest extends com.metamatrix.jdbc.api.AbstractQueryTest
+ implements TransactionQueryTest {
+
+ private static boolean initialized = false;
- public void setExecutionProperties(Properties props) {
- assertNotNull(props);
- this.executionProperties = props;
-
- String fetchSizeStr = executionProperties.getProperty(CONNECTION_STRATEGY_PROPS.FETCH_SIZE);
- if ( fetchSizeStr != null ) {
- try {
- fetchSize = Integer.parseInt(fetchSizeStr);
- } catch ( NumberFormatException e ) {
- fetchSize = -1;
- this.print("Invalid fetch size value: " + fetchSizeStr + ", ignoring");
- }
- }
+ protected String testname = "NA";
+ protected int fetchSize = -1;
+ protected int queryTimeout = -1;
+
+ protected ConnectionStrategy connStrategy;
+
+ public AbstractQueryTransactionTest() {
+ super();
}
- @Override
- protected void compareResults(BufferedReader resultReader, BufferedReader expectedReader) throws IOException {
- assertEquals(read(expectedReader, compareResultsCaseSensitive()) , read(resultReader, compareResultsCaseSensitive()));
+
+ public AbstractQueryTransactionTest(String testname) {
+ super();
+ this.testname = testname;
}
+
+ public String getTestName() {
+ return this.testname;
+
+ }
- @Override protected void assignExecutionProperties(Statement stmt) {
- if (stmt instanceof com.metamatrix.jdbc.api.Statement) {
- com.metamatrix.jdbc.api.Statement statement = (com.metamatrix.jdbc.api.Statement)stmt;
- if (this.executionProperties != null) {
- String txnautowrap = this.executionProperties.getProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP);
- if (txnautowrap != null) {
- statement.setExecutionProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, txnautowrap);
- }
-
- }
-
- if (this.fetchSize > 0) {
- try {
- statement.setFetchSize(this.fetchSize);
- } catch (SQLException e) {
- this.print(e);
- }
- }
-
- if (this.queryTimeout > 0) {
- try {
- statement.setQueryTimeout(this.queryTimeout);
- } catch (SQLException e) {
- this.print(e);
- }
- }
- }
+ @Override
+ public void setConnectionStrategy(ConnectionStrategy connStrategy) throws QueryTestFailedException {
+ this.connStrategy = connStrategy;
+
+ this.setConnection(connStrategy.getConnection());
-
}
-
- public boolean hasRequiredDataSources() {
- boolean rtn = true;
-
- if (getNumberRequiredDataSources() == 0 || getNumberRequiredDataSources() > this.connStrategy.getNumberAvailableDataSources()) {
- this.print(getTestName() + " will not be run, it requires " + getNumberRequiredDataSources() +
- " datasources, but only available is " + this.connStrategy.getNumberAvailableDataSources());
- return false;
- }
+// @Override
+// protected void compareResults(BufferedReader resultReader,
+// BufferedReader expectedReader) throws IOException {
+// assertEquals(read(expectedReader, compareResultsCaseSensitive()), read(
+// resultReader, compareResultsCaseSensitive()));
+// }
-
-
-
- return rtn;
+ @Override
+ protected void assignExecutionProperties(Statement stmt) {
+ if (stmt instanceof com.metamatrix.jdbc.api.Statement) {
+ com.metamatrix.jdbc.api.Statement statement = (com.metamatrix.jdbc.api.Statement) stmt;
+
+ Properties executionProperties = this.connStrategy.getEnvironment();
+ if (executionProperties != null) {
+ String txnautowrap = executionProperties
+ .getProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP);
+ if (txnautowrap != null) {
+ statement.setExecutionProperty(
+ CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP,
+ txnautowrap);
+
+ this.print("TransactionAutoWrap = " + txnautowrap);
+ }
+
+ String fetchSizeStr = executionProperties
+ .getProperty(CONNECTION_STRATEGY_PROPS.FETCH_SIZE);
+ if (fetchSizeStr != null) {
+ try {
+ fetchSize = Integer.parseInt(fetchSizeStr);
+
+ this.print("FetchSize = " + fetchSize);
+ } catch (NumberFormatException e) {
+ fetchSize = -1;
+ // this.print("Invalid fetch size value: " + fetchSizeStr
+ // + ", ignoring");
+ }
+ }
+
+ }
+
+
+
+ if (this.fetchSize > 0) {
+ try {
+ statement.setFetchSize(this.fetchSize);
+ } catch (SQLException e) {
+// this.print(e);
+ }
+ }
+
+ if (this.queryTimeout > 0) {
+ try {
+ statement.setQueryTimeout(this.queryTimeout);
+ } catch (SQLException e) {
+// this.print(e);
+ }
+ }
+ }
+
}
-
- public int getNumberRequiredDataSources() {
- return 1;
- }
-
+
public boolean compareResultsCaseSensitive() {
- return true;
+ return true;
}
-
/**
- * Override <code>setupDataSource</code> if there is different mechinism for
+ * Override <code>setupDataSource</code> if there is different mechanism for
* setting up the datasources for the testcase
- * @throws QueryTestFailedException
- * @throws QueryTestFailedException
*
+ * @throws QueryTestFailedException
+ * @throws QueryTestFailedException
+ *
* @since
*/
@Override
- public void setupDataSource() throws QueryTestFailedException {
-
- DataSourceSetup dss = DataSourceSetupFactory.createDataSourceSetup(this.getNumberRequiredDataSources());
- dss.setup(datasources, connStrategy);
+ public void setup() throws QueryTestFailedException {
- }
+ if (!initialized) {
+ initialized = true;
+ DataStore.initialize(connStrategy);
+
+ }
+
+ DataStore.setup(connStrategy);
+
+ }
+ /**
+ * The source connection must be asked from the connection strategy because only here
+ * is it known which model was mapped to which datasource.
+ * This is because each test could potentially use an include/exclude datasource option
+ * that could change the mappings between tests.
+ * @param identifier
+ * @return
+ * @throws QueryTestFailedException
+ */
+ public Connection getSource(String identifier)
+ throws QueryTestFailedException {
+
+ Connection conn = this.connStrategy.createDriverConnection(identifier);
+ // force autocommit back to true, just in case the last user didnt
+ try {
+ conn.setAutoCommit(true);
+ } catch (Exception sqle) {
+ throw new QueryTestFailedException(sqle);
+ }
+
+ return conn;
- public Connection getSource(String identifier) throws QueryTestFailedException {
- return ConnectionUtil.getConnection(identifier, this.datasources, this.connStrategy);
- }
-
- public XAConnection getXASource(String identifier) throws QueryTestFailedException {
- return ConnectionUtil.getXAConnection(identifier, this.datasources, this.connStrategy);
- }
-
-
- /**
- * Implement testCase(), it is the entry point to the execution of the test.
- * @throws Exception
- *
- * @since
- */
+ }
+
+ public XAConnection getXASource(String identifier)
+ throws QueryTestFailedException {
+
+ return this.connStrategy.createDataSourceConnection(identifier);
+
+ }
+
+ /**
+ * Implement testCase(), it is the entry point to the execution of the test.
+ *
+ * @throws Exception
+ *
+ * @since
+ */
public abstract void testCase() throws Exception;
-
+
/**
- * Indicates what should be done when a failure occurs in {@link #testCase()}
+ * Indicates what should be done when a failure occurs in
+ * {@link #testCase()}
+ *
* @return
- *
+ *
* @since
*/
public boolean rollbackAllways() {
- return false;
+ return false;
}
-
+
/**
- * Override <code>before</code> if there is behavior that needs to be performed
- * prior to {@link #testCase()} being called.
+ * Override <code>before</code> if there is behavior that needs to be
+ * performed prior to {@link #testCase()} being called.
*
- *
+ *
* @since
*/
public void before() {
}
-
+
/**
- * Override <code>after</code> if there is behavior that needs to be performed
- * after {@link #testCase()} being called.
+ * Override <code>after</code> if there is behavior that needs to be
+ * performed after {@link #testCase()} being called.
*
- *
+ *
* @since
*/
public void after() {
}
-
- @Override
- public void validateTestCase() throws Exception {
-
- }
-
-
/**
- * 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.
+ * At end of each test, perform any cleanup that your test requires. Note:
+ * Do not cleanup any connections by calling {@link ConnectionStrategy#shutdown()}.
+ * That is performed by the
+ * {@link TransactionContainer#runTransaction(TransactionQueryTest)} at the
+ * end of the test.
*/
public void cleanup() {
-
+
}
-
- @Override
- public XAConnection getXAConnection() {
- // TODO Auto-generated method stub
- return null;
- }
+ @Override
+ public XAConnection getXAConnection() {
+ return null;
+ }
-
-
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java 2009-11-16 20:57:50 UTC (rev 1555)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java 2009-11-16 20:58:17 UTC (rev 1556)
@@ -19,9 +19,9 @@
public class JNDITransaction extends TransactionContainer {
UserTransaction userTxn = null;
- public JNDITransaction(ConfigPropertyLoader config) {
- super(config);
- }
+// public JNDITransaction(ConfigPropertyLoader config) {
+// super(config);
+// }
protected void before(TransactionQueryTest test) {
if (this.props.getProperty(CONNECTION_STRATEGY_PROPS.JNDINAME_USERTXN) == null) {
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-11-16 20:57:50 UTC (rev 1555)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java 2009-11-16 20:58:17 UTC (rev 1556)
@@ -10,22 +10,22 @@
import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.TransactionContainer;
import org.teiid.test.framework.TransactionQueryTest;
+import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
+import org.teiid.test.framework.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
import org.teiid.test.framework.exception.TransactionRuntimeException;
-
-
/**
* A transaction which is user controlled.
*/
public class LocalTransaction extends TransactionContainer {
- public LocalTransaction(ConfigPropertyLoader config) {
- super(config);
-
+ public LocalTransaction() {
+ super();
}
-
protected void before(TransactionQueryTest test) {
+ this.setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_OFF);
+
try {
debug("Autocommit: " + this.connStrategy.getAutocommit());
test.getConnection().setAutoCommit(this.connStrategy.getAutocommit());
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-11-16 20:57:50 UTC (rev 1555)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java 2009-11-16 20:58:17 UTC (rev 1556)
@@ -22,26 +22,26 @@
public static TransactionContainer create(ConfigPropertyLoader config) throws QueryTestFailedException {
TransactionContainer transacton = null;
- String type = config.getProperty(ConfigPropertyNames.TRANSACTION_TYPE);
- if (type == null) {
- type = ConfigPropertyNames.TRANSACTION_TYPES.LOCAL_TRANSACTION;
- }
-
- System.out.println("Create TransactionContainer: " + type);
-
- if (type.equalsIgnoreCase(ConfigPropertyNames.TRANSACTION_TYPES.LOCAL_TRANSACTION)) {
- transacton = new LocalTransaction(config);
- }
- else if (type.equalsIgnoreCase(ConfigPropertyNames.TRANSACTION_TYPES.XATRANSACTION)) {
- transacton = new XATransaction(config);
- }
- else if (type.equalsIgnoreCase(ConfigPropertyNames.TRANSACTION_TYPES.JNDI_TRANSACTION)) {
- transacton = new JNDITransaction(config);
+// String type = config.getProperty(ConfigPropertyNames.TRANSACTION_TYPE);
+// if (type == null) {
+// type = ConfigPropertyNames.TRANSACTION_TYPES.LOCAL_TRANSACTION;
+// }
+//
+// System.out.println("Create TransactionContainer: " + type);
+//
+// if (type.equalsIgnoreCase(ConfigPropertyNames.TRANSACTION_TYPES.LOCAL_TRANSACTION)) {
+// transacton = new LocalTransaction(config);
+// }
+// else if (type.equalsIgnoreCase(ConfigPropertyNames.TRANSACTION_TYPES.XATRANSACTION)) {
+// transacton = new XATransaction(config);
+// }
+// else if (type.equalsIgnoreCase(ConfigPropertyNames.TRANSACTION_TYPES.JNDI_TRANSACTION)) {
+// transacton = new JNDITransaction(config);
+//
+// } else {
+// throw new TransactionRuntimeException("Invalid property value of " + type + " for " + ConfigPropertyNames.TRANSACTION_TYPE );
+// }
- } else {
- throw new TransactionRuntimeException("Invalid property value of " + type + " for " + ConfigPropertyNames.TRANSACTION_TYPE );
- }
-
return transacton;
}
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-11-16 20:57:50 UTC (rev 1555)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java 2009-11-16 20:58:17 UTC (rev 1556)
@@ -21,9 +21,9 @@
private static Random RANDOM = new Random();
private MMXid xid;
- public XATransaction(ConfigPropertyLoader config) {
- super(config);
- }
+ public XATransaction() {
+ super();
+ }
protected void before(TransactionQueryTest test) {
try {
15 years, 1 month