teiid SVN: r1430 - trunk/test-integration/db/src/main/resources.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-21 16:24:15 -0400 (Mon, 21 Sep 2009)
New Revision: 1430
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-21 19:37:01 UTC (rev 1429)
+++ trunk/test-integration/db/src/main/resources/default-config.properties 2009-09-21 20:24:15 UTC (rev 1430)
@@ -16,6 +16,7 @@
##########################################
# properties for Teiid connection
##########################################
+#driver=org.teiid.jdbc.TeiidDriver
driver=com.metamatrix.jdbc.EmbeddedDataSource
URL=jdbc:metamatrix:Transaction@target/classes/transactions/transaction.properties
User=metamatrixadmin
Modified: trunk/test-integration/db/src/main/resources/xa-config.properties
===================================================================
--- trunk/test-integration/db/src/main/resources/xa-config.properties 2009-09-21 19:37:01 UTC (rev 1429)
+++ trunk/test-integration/db/src/main/resources/xa-config.properties 2009-09-21 20:24:15 UTC (rev 1430)
@@ -43,8 +43,8 @@
#
#
-pm1=nonxa
-pm2=nonxa
+pm1=xa
+pm2=xa
##########################################
15 years, 3 months
teiid SVN: r1429 - in branches/6.2.x/engine/src: test/java/com/metamatrix/query/processor/relational and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-09-21 15:37:01 -0400 (Mon, 21 Sep 2009)
New Revision: 1429
Modified:
branches/6.2.x/engine/src/main/java/com/metamatrix/query/processor/relational/BatchedUpdateNode.java
branches/6.2.x/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java
Log:
TEIID-843 fix for indexoutofbounds exception.
Modified: branches/6.2.x/engine/src/main/java/com/metamatrix/query/processor/relational/BatchedUpdateNode.java
===================================================================
--- branches/6.2.x/engine/src/main/java/com/metamatrix/query/processor/relational/BatchedUpdateNode.java 2009-09-21 17:29:59 UTC (rev 1428)
+++ branches/6.2.x/engine/src/main/java/com/metamatrix/query/processor/relational/BatchedUpdateNode.java 2009-09-21 19:37:01 UTC (rev 1429)
@@ -90,7 +90,7 @@
for (int i = 0; i < updateCommands.size(); i++) {
Command updateCommand = (Command)updateCommands.get(i).clone();
CommandContext context = this.getContext();
- if (this.contexts != null) {
+ if (this.contexts != null && !this.contexts.isEmpty()) {
context = (CommandContext)context.clone();
context.setVariableContext(this.contexts.get(i));
}
Modified: branches/6.2.x/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java
===================================================================
--- branches/6.2.x/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java 2009-09-21 17:29:59 UTC (rev 1428)
+++ branches/6.2.x/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java 2009-09-21 19:37:01 UTC (rev 1429)
@@ -26,6 +26,7 @@
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import org.junit.Test;
@@ -57,7 +58,7 @@
for (Command command : commands) {
shouldEvaluate.add(EvaluatableVisitor.needsProcessingEvaluation(command));
}
- BatchedUpdateNode node = new BatchedUpdateNode(1, commands, null, shouldEvaluate, "myModelName"); //$NON-NLS-1$
+ BatchedUpdateNode node = new BatchedUpdateNode(1, commands, Collections.EMPTY_LIST, shouldEvaluate, "myModelName"); //$NON-NLS-1$
CommandContext context = new CommandContext();
context.setProcessorID("myProcessorID"); //$NON-NLS-1$
node.initialize(context, Mockito.mock(BufferManager.class), pdm);
15 years, 3 months
teiid SVN: r1428 - in trunk: engine/src/main/java/com/metamatrix/query/processor/proc and 9 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-09-21 13:29:59 -0400 (Mon, 21 Sep 2009)
New Revision: 1428
Added:
trunk/engine/src/test/java/com/metamatrix/query/processor/TestTempTables.java
Modified:
trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/LoopInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNode.java
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Command.java
trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/GroupSymbol.java
trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStoreImpl.java
trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestProjectIntoNode.java
trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java
Log:
TEIID-162 adding support for updatable temp tables. the implementation creates a new tuple source as the target for the update.
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2009-09-20 16:31:50 UTC (rev 1427)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2009-09-21 17:29:59 UTC (rev 1428)
@@ -648,10 +648,6 @@
<para>temp tables are non-transactional.
</para>
</listitem>
- <listitem>
- <para>Temp tables do not support update or delete operations.
- </para>
- </listitem>
</itemizedlist>
<para>The following example is a series of statements that loads a temporary table with data from 2 sources, and with a manually inserted record, and then uses that temp table in a subsequent query.</para>
<programlisting>...
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/LoopInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/LoopInstruction.java 2009-09-20 16:31:50 UTC (rev 1427)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/LoopInstruction.java 2009-09-21 17:29:59 UTC (rev 1428)
@@ -71,10 +71,6 @@
}
}
- public Program getLoopProgram() { //Defect 13291 - added method to support changes to ProcedurePlan
- return loopProgram;
- }
-
/**
* Returns a deep clone
*/
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java 2009-09-20 16:31:50 UTC (rev 1427)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java 2009-09-21 17:29:59 UTC (rev 1428)
@@ -404,11 +404,7 @@
if(rowCount == null) {
rowCount = new Integer(NO_ROWS_UPDATED);
}
-
- final List updateResult = new ArrayList(1);
- updateResult.add(rowCount);
-
- return new UpdateCountTupleSource(updateResult);
+ return new UpdateCountTupleSource((Integer)rowCount);
}
/**
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNode.java 2009-09-20 16:31:50 UTC (rev 1427)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNode.java 2009-09-21 17:29:59 UTC (rev 1428)
@@ -357,7 +357,7 @@
* @param elements List of elements
* @return Map of element to Integer, which is the index
*/
- protected Map createLookupMap(List elements) {
+ public static Map createLookupMap(List elements) {
Map lookupMap = new HashMap();
for(int i=0; i<elements.size(); i++) {
Object element = elements.get(i);
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Command.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Command.java 2009-09-20 16:31:50 UTC (rev 1427)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Command.java 2009-09-21 17:29:59 UTC (rev 1428)
@@ -107,7 +107,7 @@
public static final int TYPE_DROP = 12;
- private static List updateCommandSymbol;
+ private static List<SingleElementSymbol> updateCommandSymbol;
/**
* All temporary group IDs discovered while resolving this
@@ -305,11 +305,11 @@
*/
public abstract boolean areResultsCachable();
- public static List getUpdateCommandSymbol() {
+ public static List<SingleElementSymbol> getUpdateCommandSymbol() {
if (updateCommandSymbol == null ) {
ElementSymbol symbol = new ElementSymbol("Count"); //$NON-NLS-1$
symbol.setType(DataTypeManager.DefaultDataClasses.INTEGER);
- updateCommandSymbol = Arrays.asList(new ElementSymbol[] {symbol});
+ updateCommandSymbol = Arrays.asList((SingleElementSymbol)symbol);
}
return updateCommandSymbol;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/GroupSymbol.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/GroupSymbol.java 2009-09-20 16:31:50 UTC (rev 1427)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/GroupSymbol.java 2009-09-21 17:29:59 UTC (rev 1428)
@@ -151,7 +151,7 @@
}
/**
- * Returns true if this is a symbol for a temporary group (i.e. if it starts with a '#')
+ * Returns true if this is a symbol for a temporary (implicit or explicit) group
* @return
* @since 5.5
*/
Modified: trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStoreImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStoreImpl.java 2009-09-20 16:31:50 UTC (rev 1427)
+++ trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStoreImpl.java 2009-09-21 17:29:59 UTC (rev 1428)
@@ -23,14 +23,15 @@
package com.metamatrix.query.tempdata;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.api.exception.query.ExpressionEvaluationException;
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.api.exception.query.QueryProcessingException;
@@ -48,25 +49,107 @@
import com.metamatrix.query.metadata.TempMetadataAdapter;
import com.metamatrix.query.metadata.TempMetadataStore;
import com.metamatrix.query.processor.proc.UpdateCountTupleSource;
+import com.metamatrix.query.processor.relational.RelationalNode;
+import com.metamatrix.query.processor.relational.TupleCollector;
import com.metamatrix.query.resolver.util.ResolverUtil;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.Create;
+import com.metamatrix.query.sql.lang.Criteria;
+import com.metamatrix.query.sql.lang.Delete;
import com.metamatrix.query.sql.lang.Drop;
import com.metamatrix.query.sql.lang.Insert;
+import com.metamatrix.query.sql.lang.ProcedureContainer;
import com.metamatrix.query.sql.lang.Query;
+import com.metamatrix.query.sql.lang.Update;
import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.GroupSymbol;
+import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.util.TypeRetrievalUtil;
/**
* @since 5.5
*/
-public class TempTableStoreImpl implements TempTableStore{
- private BufferManager buffer;
+public class TempTableStoreImpl implements TempTableStore {
+
+ private abstract class UpdateTupleSource implements TupleSource {
+ private final String groupKey;
+ private final TupleSourceID tsId;
+ private final TupleSource ts;
+ protected final Map lookup;
+ private final TupleCollector tc;
+ private final TupleSourceID newTs;
+ protected final Evaluator eval;
+ private final Criteria crit;
+ protected int updateCount = 0;
+ private boolean done;
+
+ private UpdateTupleSource(String groupKey, TupleSourceID tsId, Criteria crit) throws TupleSourceNotFoundException, MetaMatrixComponentException {
+ this.groupKey = groupKey;
+ this.tsId = tsId;
+ this.ts = buffer.getTupleSource(tsId);
+ List columns = buffer.getTupleSchema(tsId);
+ this.lookup = RelationalNode.createLookupMap(columns);
+ this.newTs = buffer.createTupleSource(columns, TypeRetrievalUtil.getTypeNames(columns), sessionID, TupleSourceType.PROCESSOR);
+ this.tc = new TupleCollector(newTs, buffer);
+ this.eval = new Evaluator(lookup, null, null);
+ this.crit = crit;
+ }
+
+ @Override
+ public List<?> nextTuple() throws MetaMatrixComponentException,
+ MetaMatrixProcessingException {
+ if (done) {
+ return null;
+ }
+
+ List<?> tuple = null;
+ //still have to worry about blocked exceptions...
+ while ((tuple = ts.nextTuple()) != null) {
+ if (eval.evaluate(crit, tuple)) {
+ tuplePassed(tuple);
+ } else {
+ tupleFailed(tuple);
+ }
+ }
+ tc.close();
+ groupToTupleSourceID.put(groupKey, newTs);
+ try {
+ buffer.removeTupleSource(tsId);
+ }catch(TupleSourceNotFoundException e) {
+
+ }
+ done = true;
+ return Arrays.asList(updateCount);
+ }
+
+ protected void addTuple(List<?> tuple) throws MetaMatrixComponentException {
+ try {
+ tc.addTuple(tuple);
+ } catch (TupleSourceNotFoundException e) {
+ throw new MetaMatrixComponentException(e);
+ }
+ }
+
+ protected abstract void tuplePassed(List<?> tuple) throws ExpressionEvaluationException, BlockedException, MetaMatrixComponentException;
+
+ protected abstract void tupleFailed(List<?> tuple) throws MetaMatrixComponentException;
+
+ @Override
+ public List<SingleElementSymbol> getSchema() {
+ return Command.getUpdateCommandSymbol();
+ }
+
+ @Override
+ public void closeSource() throws MetaMatrixComponentException {
+
+ }
+ }
+
+ private BufferManager buffer;
private TempMetadataStore tempMetadataStore = new TempMetadataStore();
- private Map groupToTupleSourceID = new HashMap();
+ private Map<String, TupleSourceID> groupToTupleSourceID = new HashMap<String, TupleSourceID>();
private String sessionID;
private TempTableStore parentTempTableStore;
@@ -96,7 +179,7 @@
}
groupToTupleSourceID.put(tempTableName, tsId);
}
-
+
public void removeTempTable(Command command) throws MetaMatrixComponentException{
if(command.getType() == Command.TYPE_DROP) {
String tempTableName = ((Drop)command).getTable().getName().toUpperCase();
@@ -106,7 +189,7 @@
public void removeTempTableByName(String tempTableName) throws MetaMatrixComponentException {
tempMetadataStore.removeTempGroup(tempTableName);
- TupleSourceID tsId = (TupleSourceID)this.groupToTupleSourceID.remove(tempTableName);
+ TupleSourceID tsId = this.groupToTupleSourceID.remove(tempTableName);
if(tsId != null) {
try {
buffer.removeTupleSource(tsId);
@@ -119,52 +202,90 @@
}
public TupleSource registerRequest(Command command) throws MetaMatrixComponentException, ExpressionEvaluationException, QueryProcessingException{
- if(!hasTempTable(command)) {
- return null;
- }
-
- switch (command.getType()) {
- case Command.TYPE_INSERT:
- {
- return addTuple((Insert)command);
+ if (command instanceof Query) {
+ Query query = (Query)command;
+ GroupSymbol group = (GroupSymbol)query.getFrom().getGroups().get(0);
+ if (!group.isTempGroupSymbol()) {
+ return null;
}
- case Command.TYPE_QUERY:
- {
- Query query = (Query)command;
- GroupSymbol group = (GroupSymbol)query.getFrom().getGroups().get(0);
- TupleSourceID tsId = getTupleSourceID(group.getNonCorrelationName().toUpperCase(), command);
- try {
- return buffer.getTupleSource(tsId);
- }catch(TupleSourceNotFoundException e) {
- throw new MetaMatrixComponentException(e);
- }
+ TupleSourceID tsId = getTupleSourceID(group.getNonCorrelationName().toUpperCase(), command);
+ try {
+ return buffer.getTupleSource(tsId);
+ }catch(TupleSourceNotFoundException e) {
+ throw new MetaMatrixComponentException(e);
}
- case Command.TYPE_CREATE:
- {
- addTempTable(((Create)command).getTable().getName().toUpperCase(), ((Create)command).getColumns(), false);
- return new UpdateCountTupleSource(0);
- }
- case Command.TYPE_DROP:
- {
- removeTempTable(command);
- return new UpdateCountTupleSource(0);
- }
}
- throw new AssertionError("unhandled temp table reqest"); //$NON-NLS-1$
+ if (command instanceof ProcedureContainer) {
+ GroupSymbol group = ((ProcedureContainer)command).getGroup();
+ if (!group.isTempGroupSymbol()) {
+ return null;
+ }
+ final String groupKey = group.getNonCorrelationName().toUpperCase();
+ final TupleSourceID tsId = getTupleSourceID(groupKey, command);
+ if (command instanceof Insert) {
+ return addTuple((Insert)command, tsId);
+ }
+ try {
+ if (command instanceof Update) {
+ final Update update = (Update)command;
+ final Criteria crit = update.getCriteria();
+ return new UpdateTupleSource(groupKey, tsId, crit) {
+ @Override
+ protected void tuplePassed(List<?> tuple)
+ throws ExpressionEvaluationException,
+ BlockedException, MetaMatrixComponentException {
+ List<Object> newTuple = new ArrayList<Object>(tuple);
+ for (Map.Entry<ElementSymbol, Expression> entry : update.getChangeList().getClauseMap().entrySet()) {
+ newTuple.set((Integer)lookup.get(entry.getKey()), eval.evaluate(entry.getValue(), tuple));
+ }
+ updateCount++;
+ addTuple(newTuple);
+ }
+
+ protected void tupleFailed(java.util.List<?> tuple) throws MetaMatrixComponentException {
+ addTuple(tuple);
+ }
+ };
+ }
+ if (command instanceof Delete) {
+ final Delete delete = (Delete)command;
+ final Criteria crit = delete.getCriteria();
+ return new UpdateTupleSource(groupKey, tsId, crit) {
+ @Override
+ protected void tuplePassed(List<?> tuple)
+ throws ExpressionEvaluationException,
+ BlockedException, MetaMatrixComponentException {
+ updateCount++;
+ }
+
+ protected void tupleFailed(java.util.List<?> tuple) throws MetaMatrixComponentException {
+ addTuple(tuple);
+ }
+ };
+ }
+ } catch (TupleSourceNotFoundException e) {
+ throw new MetaMatrixComponentException(e);
+ }
+ }
+ if (command instanceof Create) {
+ addTempTable(((Create)command).getTable().getName().toUpperCase(), ((Create)command).getColumns(), false);
+ return new UpdateCountTupleSource(0);
+ }
+ if (command instanceof Drop) {
+ removeTempTable(command);
+ return new UpdateCountTupleSource(0);
+ }
+ return null;
}
public void removeTempTables() throws MetaMatrixComponentException{
- List names = new ArrayList( groupToTupleSourceID.keySet() );
- Iterator iter = names.iterator();
-
- while(iter.hasNext()) {
- removeTempTableByName((String)iter.next());
+ for (String name : new ArrayList<String>( groupToTupleSourceID.keySet() )) {
+ removeTempTableByName(name);
}
}
private TupleSourceID getTupleSourceID(String tempTableID, Command command) throws MetaMatrixComponentException, QueryProcessingException{
-
- TupleSourceID tsID = (TupleSourceID)groupToTupleSourceID.get(tempTableID);
+ TupleSourceID tsID = groupToTupleSourceID.get(tempTableID);
if(tsID != null) {
return tsID;
}
@@ -195,42 +316,23 @@
throw new QueryProcessingException(QueryExecPlugin.Util.getString("TempTableStore.table_doesnt_exist_error", tempTableID)); //$NON-NLS-1$
}
addTempTable(tempTableID, columns, true);
- return (TupleSourceID)groupToTupleSourceID.get(tempTableID);
+ return groupToTupleSourceID.get(tempTableID);
}
- private TupleSource addTuple(Insert insert) throws MetaMatrixComponentException, ExpressionEvaluationException, QueryProcessingException {
+ private TupleSource addTuple(Insert insert, TupleSourceID tsId) throws MetaMatrixComponentException, ExpressionEvaluationException {
GroupSymbol group = insert.getGroup();
- TupleSourceID tsId = getTupleSourceID(group.getNonCorrelationName().toUpperCase(), insert);
int tuplesAdded = 0;
try {
int rowCount = buffer.getRowCount(tsId);
TupleBatch tupleBatch;
- List elements = ResolverUtil.resolveElementsInGroup(group, new TempMetadataAdapter(null, tempMetadataStore));
+ List<ElementSymbol> elements = ResolverUtil.resolveElementsInGroup(group, new TempMetadataAdapter(null, tempMetadataStore));
- if ( insert.isBulk() ) {
- List<List<Object>> tuples = getBulkRows(insert);
-
- tuplesAdded = tuples.size();
+ List<List<Object>> tuples = getBulkRows(insert, elements);
+
+ tuplesAdded = tuples.size();
- // Buffer manager has 1 based index for the tuple sources
- tupleBatch = new TupleBatch((++rowCount), tuples);
-
- } else {
-
- tuplesAdded = 1;
- List tuple = new ArrayList(elements.size());
- for(Iterator i = elements.iterator(); i.hasNext();){
- ElementSymbol symbol = (ElementSymbol)i.next();
- int index = insert.getVariables().indexOf(symbol);
- Object value = null;
- if (index != -1) {
- Expression expr = (Expression)insert.getValues().get(index);
- value = Evaluator.evaluate(expr);
- }
- tuple.add(value);
- }
- tupleBatch = new TupleBatch(++rowCount, new List[]{tuple});
- }
+ // Buffer manager has 1 based index for the tuple sources
+ tupleBatch = new TupleBatch((++rowCount), tuples);
buffer.addTupleBatch(tsId, tupleBatch);
} catch (TupleSourceNotFoundException err) {
@@ -244,18 +346,31 @@
return new UpdateCountTupleSource(tuplesAdded);
}
- public static List<List<Object>> getBulkRows(Insert insert) {
- Constant c = (Constant)insert.getValues().get(0);
- int bulkRowCount = ((List<?>)c.getValue()).size();
+ public static List<List<Object>> getBulkRows(Insert insert, List<ElementSymbol> elements) throws ExpressionEvaluationException, BlockedException, MetaMatrixComponentException {
+ int bulkRowCount = 1;
+ if (insert.isBulk()) {
+ Constant c = (Constant)insert.getValues().get(0);
+ bulkRowCount = ((List<?>)c.getValue()).size();
+ }
List<List<Object>> tuples = new ArrayList<List<Object>>(bulkRowCount);
for (int row = 0; row < bulkRowCount; row++) {
List<Object> currentRow = new ArrayList<Object>(insert.getValues().size());
- for (int i = 0; i < insert.getValues().size(); i++) {
- Constant multiValue = (Constant)insert.getValues().get(i);
- currentRow.add(((List<?>)multiValue.getValue()).get(row));
- }
+ for (ElementSymbol symbol : elements) {
+ int index = insert.getVariables().indexOf(symbol);
+ Object value = null;
+ if (index != -1) {
+ if (insert.isBulk()) {
+ Constant multiValue = (Constant)insert.getValues().get(index);
+ value = ((List<?>)multiValue.getValue()).get(row);
+ } else {
+ Expression expr = (Expression)insert.getValues().get(index);
+ value = Evaluator.evaluate(expr);
+ }
+ }
+ currentRow.add(value);
+ }
tuples.add(currentRow);
}
return tuples;
@@ -286,11 +401,11 @@
return false;
}
- public Set getAllTempTables() {
- return new HashSet(this.groupToTupleSourceID.keySet());
+ public Set<String> getAllTempTables() {
+ return new HashSet<String>(this.groupToTupleSourceID.keySet());
}
public TupleSourceID getTupleSourceID(String tempTableName) {
- return (TupleSourceID)groupToTupleSourceID.get(tempTableName.toUpperCase());
+ return groupToTupleSourceID.get(tempTableName.toUpperCase());
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java 2009-09-20 16:31:50 UTC (rev 1427)
+++ trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java 2009-09-21 17:29:59 UTC (rev 1428)
@@ -163,9 +163,6 @@
validateNoXMLUpdates(obj);
validateHasProjectedSymbols(obj);
validateGroupSupportsUpdate(obj.getGroup());
- if (obj.getGroup().isTempTable()) {
- handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.update_temp", obj.getGroup()), obj.getGroup()); //$NON-NLS-1$
- }
}
public void visit(GroupBy obj) {
@@ -834,10 +831,6 @@
}
validateSetClauseList(update.getChangeList());
-
- if (update.getGroup().isTempTable()) {
- handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.update_temp", update.getGroup()), update.getGroup()); //$NON-NLS-1$
- }
}
/**
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-09-20 16:31:50 UTC (rev 1427)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-09-21 17:29:59 UTC (rev 1428)
@@ -59,6 +59,7 @@
import com.metamatrix.dqp.message.ParameterInfo;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.mapping.relational.QueryNode;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.FakeFunctionMetadataSource;
import com.metamatrix.query.optimizer.QueryOptimizer;
import com.metamatrix.query.optimizer.TestOptimizer;
@@ -105,11 +106,11 @@
}
}
- public static ProcessorPlan helpGetPlan(String sql, FakeMetadataFacade metadata) {
+ public static ProcessorPlan helpGetPlan(String sql, QueryMetadataInterface metadata) {
return helpGetPlan(sql, metadata, null);
}
- public static ProcessorPlan helpGetPlan(String sql, FakeMetadataFacade metadata, String[] bindings) {
+ public static ProcessorPlan helpGetPlan(String sql, QueryMetadataInterface metadata, String[] bindings) {
if(DEBUG) System.out.println("\n####################################\n" + sql); //$NON-NLS-1$
Command command = helpParse(sql);
@@ -128,18 +129,18 @@
return process;
}
- static ProcessorPlan helpGetPlan(Command command, FakeMetadataFacade metadata) {
+ static ProcessorPlan helpGetPlan(Command command, QueryMetadataInterface metadata) {
return helpGetPlan(command, metadata, new DefaultCapabilitiesFinder());
}
- static ProcessorPlan helpGetPlan(Command command, FakeMetadataFacade metadata, CapabilitiesFinder capFinder) {
+ static ProcessorPlan helpGetPlan(Command command, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) {
CommandContext context = new CommandContext();
context.setProcessorBatchSize(2000);
context.setConnectorBatchSize(2000);
return helpGetPlan(command, metadata, capFinder, context);
}
- static ProcessorPlan helpGetPlan(Command command, FakeMetadataFacade metadata, CapabilitiesFinder capFinder, CommandContext context) {
+ static ProcessorPlan helpGetPlan(Command command, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, CommandContext context) {
if(DEBUG) System.out.println("\n####################################\n" + command); //$NON-NLS-1$
// resolve
Added: trunk/engine/src/test/java/com/metamatrix/query/processor/TestTempTables.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestTempTables.java (rev 0)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestTempTables.java 2009-09-21 17:29:59 UTC (rev 1428)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.query.processor;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.buffer.BufferManagerFactory;
+import com.metamatrix.query.metadata.TempMetadataAdapter;
+import com.metamatrix.query.tempdata.TempTableStoreImpl;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
+
+public class TestTempTables {
+
+ private TempMetadataAdapter metadata;
+ private TempTableDataManager dataManager;
+
+ private void execute(String sql, List[] expectedResults) throws Exception {
+ TestProcessor.doProcess(TestProcessor.helpGetPlan(sql, metadata), dataManager, expectedResults, TestProcessor.createCommandContext());
+ }
+
+ @Before public void setUp() throws MetaMatrixComponentException {
+ TempTableStoreImpl tempStore = new TempTableStoreImpl(BufferManagerFactory.getStandaloneBufferManager(), "1", null); //$NON-NLS-1$
+ metadata = new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), tempStore.getMetadataStore());
+ FakeDataManager fdm = new FakeDataManager();
+ TestProcessor.sampleData1(fdm);
+ dataManager = new TempTableDataManager(fdm, tempStore);
+ }
+
+ @Ignore("need to correct select into query formation")
+ @Test public void testInsertWithQueryExpression() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ execute("update x set e1 = e2 where e2 > 1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ }
+
+ @Test public void testOutofOrderInsert() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (1, 'one')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("select e1, e2 from x", new List[] {Arrays.asList("one", 1)}); //$NON-NLS-1$
+ }
+
+ @Test public void testUpdate() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (1, 'one')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("select e1, e2 into x from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ execute("update x set e1 = e2 where e2 > 1", new List[] {Arrays.asList(2)}); //$NON-NLS-1$
+ execute("select e1 from x where e2 > 0 order by e1", new List[] { //$NON-NLS-1$
+ Arrays.asList((String)null),
+ Arrays.asList("2"), //$NON-NLS-1$
+ Arrays.asList("3"), //$NON-NLS-1$
+ Arrays.asList("c"), //$NON-NLS-1$
+ Arrays.asList("one")}); //$NON-NLS-1$
+ }
+
+ @Test public void testDelete() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("select e1, e2 into x from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ execute("delete from x where ascii(e1) > e2", new List[] {Arrays.asList(5)}); //$NON-NLS-1$
+ execute("select e1 from x order by e1", new List[] {Arrays.asList((String)null)}); //$NON-NLS-1$
+ }
+
+}
Property changes on: trunk/engine/src/test/java/com/metamatrix/query/processor/TestTempTables.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java 2009-09-20 16:31:50 UTC (rev 1427)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java 2009-09-21 17:29:59 UTC (rev 1428)
@@ -27,7 +27,6 @@
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -38,9 +37,6 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.api.exception.query.QueryResolverException;
import com.metamatrix.api.exception.query.QueryValidatorException;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.BufferManagerFactory;
@@ -53,7 +49,6 @@
import com.metamatrix.dqp.message.ParameterInfo;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.metadata.TempMetadataID;
import com.metamatrix.query.optimizer.QueryOptimizer;
import com.metamatrix.query.optimizer.TestOptimizer;
import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
@@ -822,9 +817,7 @@
// Set up data
FakeDataManager dataMgr = exampleDataManager(metadata);
- ProcessorPlan plan = helpTestTempTable(userUpdateStr, metadata, dataMgr, new List[] {
- Arrays.asList( new Object[] { new Integer(1) } )
- } );
+ ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
// Create expected results
List[] expected = new List[] {
@@ -840,9 +833,7 @@
// Set up data
FakeDataManager dataMgr = exampleDataManager(metadata);
- ProcessorPlan plan = helpTestTempTable(userUpdateStr, metadata, dataMgr, new List[] {
- Arrays.asList( new Object[] { new Integer(1) } )
- } );
+ ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g2"); //$NON-NLS-1$
List elementIDs = metadata.getElementIDsInGroupID(groupID);
@@ -872,9 +863,7 @@
// Set up data
FakeDataManager dataMgr = exampleDataManager(metadata);
- ProcessorPlan plan = helpTestTempTable(userUpdateStr, metadata, dataMgr, new List[] {
- Arrays.asList( new Object[] { new Integer(1) } )
- } );
+ ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g2"); //$NON-NLS-1$
List elementIDs = metadata.getElementIDsInGroupID(groupID);
@@ -902,9 +891,7 @@
// Set up data
FakeDataManager dataMgr = exampleDataManager(metadata);
- ProcessorPlan plan = helpTestTempTable(userUpdateStr, metadata, dataMgr, new List[] {
- Arrays.asList( new Object[] { new Integer(1) } )
- } );
+ ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
// Create expected results
List[] expected = new List[] {
@@ -912,47 +899,6 @@
helpTestProcess(plan, expected, dataMgr);
}
- private ProcessorPlan helpTestTempTable(String userUpdateStr,
- FakeMetadataFacade metadata,
- FakeDataManager dataMgr, List[] tempdata) throws QueryParserException,
- QueryResolverException,
- MetaMatrixComponentException,
- QueryValidatorException,
- QueryPlannerException,
- QueryMetadataException {
- QueryParser parser = new QueryParser();
- Command userCommand = parser.parseCommand(userUpdateStr);
- QueryResolver.resolveCommand(userCommand, metadata);
- ValidatorReport report = Validator.validate(userCommand, metadata);
- // Get invalid objects from report
- Collection actualObjs = new ArrayList();
- report.collectInvalidObjects(actualObjs);
- if(actualObjs.size() > 0) {
- fail("Expected no failures but got some: " + report.getFailureMessage()); //$NON-NLS-1$
- }
- QueryRewriter.rewrite(userCommand, null, metadata, null);
-
- ProcessorPlan plan = null;
- AnalysisRecord analysisRecord = new AnalysisRecord(false, false, DEBUG);
- try {
- plan = QueryOptimizer.optimizePlan(userCommand, metadata, null, new DefaultCapabilitiesFinder(), analysisRecord, null);
- } finally {
- if(DEBUG) {
- System.out.println(analysisRecord.getDebugLog());
- }
- }
-
- Object tempGroup = new TempMetadataID("#temptable", Collections.EMPTY_LIST); //$NON-NLS-1$
- List tempSymbols = new ArrayList(1);
- ElementSymbol element = new ElementSymbol("Count"); //$NON-NLS-1$
- tempSymbols.add(element);
-
- dataMgr.registerTuples(
- tempGroup,
- tempSymbols, tempdata);
- return plan;
- }
-
@Test public void testVirtualProcedure15() throws Exception {
String userUpdateStr = "EXEC pm1.vsp19()"; //$NON-NLS-1$
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
@@ -960,9 +906,7 @@
// Set up data
FakeDataManager dataMgr = exampleDataManager(metadata);
- ProcessorPlan plan = helpTestTempTable(userUpdateStr, metadata, dataMgr, new List[] {
- Arrays.asList( new Object[] { new Integer(1) } )
- } );
+ ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
// Create expected results
List[] expected = new List[] {
@@ -981,9 +925,7 @@
// Set up data
FakeDataManager dataMgr = exampleDataManager(metadata);
- ProcessorPlan plan = helpTestTempTable(userUpdateStr, metadata, dataMgr, new List[] {
- Arrays.asList( new Object[] { new Integer(1) } )
- } );
+ ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
// Create expected results
List[] expected = new List[] {
Arrays.asList(new Object[] { "First"}), //$NON-NLS-1$
@@ -999,9 +941,7 @@
//Set up data
FakeDataManager dataMgr = exampleDataManager(metadata);
- ProcessorPlan plan = helpTestTempTable(userUpdateStr, metadata, dataMgr, new List[] {
- Arrays.asList( new Object[] { new Integer(1) } )
- } );
+ ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
// Create expected results
List[] expected = new List[] {
@@ -1018,9 +958,7 @@
//Set up data
FakeDataManager dataMgr = exampleDataManager(metadata);
- ProcessorPlan plan = helpTestTempTable(userUpdateStr, metadata, dataMgr, new List[] {
- Arrays.asList( new Object[] { new Integer(1) } )
- } );
+ ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
// Create expected results
List[] expected = new List[] {
@@ -1035,9 +973,7 @@
//Set up data
FakeDataManager dataMgr = exampleDataManager(metadata);
- ProcessorPlan plan = helpTestTempTable(userUpdateStr, metadata, dataMgr, new List[] {
- Arrays.asList( new Object[] { new Integer(1) } )
- } );
+ ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
// Create expected results
List[] expected = new List[] {
@@ -1051,9 +987,7 @@
//Set up data
FakeDataManager dataMgr = exampleDataManager(metadata);
- ProcessorPlan plan = helpTestTempTable(userUpdateStr, metadata, dataMgr, new List[] {
- Arrays.asList( new Object[] { new Integer(1) } )
- } );
+ ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
// Create expected results
List[] expected = new List[] {
Arrays.asList(new Object[] { "Second", new Integer(15)})}; //$NON-NLS-1$
@@ -1067,9 +1001,7 @@
//Set up data
FakeDataManager dataMgr = exampleDataManager(metadata);
- ProcessorPlan plan = helpTestTempTable(userUpdateStr, metadata, dataMgr, new List[] {
- Arrays.asList( new Object[] { new Integer(1) } )
- } );
+ ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
// Create expected results
List[] expected = new List[] {};
@@ -1269,9 +1201,7 @@
//Set up data
FakeDataManager dataMgr = exampleDataManager(metadata);
- ProcessorPlan plan = helpTestTempTable(userUpdateStr, metadata, dataMgr, new List[] {
- Arrays.asList( new Object[] { new Integer(1) } )
- } );
+ ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g2"); //$NON-NLS-1$
List elementIDs = metadata.getElementIDsInGroupID(groupID);
@@ -1298,22 +1228,8 @@
String userUpdateStr = "EXEC pm1.vsp46()"; //$NON-NLS-1$
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
- Command userCommand = null;
- QueryParser parser = new QueryParser();
- userCommand = parser.parseCommand(userUpdateStr);
- QueryResolver.resolveCommand(userCommand, metadata);
- QueryRewriter.rewrite(userCommand, null, metadata, null);
+ ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
- ProcessorPlan plan = null;
- AnalysisRecord analysisRecord = new AnalysisRecord(false, false, DEBUG);
- try {
- plan = QueryOptimizer.optimizePlan(userCommand, metadata, null, new DefaultCapabilitiesFinder(), analysisRecord, null);
- } finally {
- if(DEBUG) {
- System.out.println(analysisRecord.getDebugLog());
- }
- }
-
// Set up data
FakeDataManager dataMgr = exampleDataManager(metadata);
@@ -2573,22 +2489,8 @@
String userUpdateStr = "select a.e1 from (EXEC pm1.vsp46()) as a, pm1.g1 where a.e1=pm1.g1.e1"; //$NON-NLS-1$
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
- Command userCommand = null;
- QueryParser parser = new QueryParser();
- userCommand = parser.parseCommand(userUpdateStr);
- QueryResolver.resolveCommand(userCommand, metadata);
- QueryRewriter.rewrite(userCommand, null, metadata, null);
+ ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
- ProcessorPlan plan = null;
- AnalysisRecord analysisRecord = new AnalysisRecord(false, false, DEBUG);
- try {
- plan = QueryOptimizer.optimizePlan(userCommand, metadata, null, new DefaultCapabilitiesFinder(), analysisRecord, null);
- } finally {
- if(DEBUG) {
- System.out.println(analysisRecord.getDebugLog());
- }
- }
-
// Set up data
FakeDataManager dataMgr = exampleDataManager(metadata);
@@ -2786,5 +2688,25 @@
helpTestProcess(plan, expected, dataMgr);
}
+ @Test public void testTempSubqueryInput() throws Exception {
+ String proc = "CREATE VIRTUAL PROCEDURE " + //$NON-NLS-1$
+ "BEGIN " + //$NON-NLS-1$
+ " select e1, e2, e3, e4 into #t1 from pm1.g1;\n" + //$NON-NLS-1$
+ " update #t1 set e1 = 1 where e4 < 2;\n" + //$NON-NLS-1$
+ " delete from #t1 where e4 > 2;\n" + //$NON-NLS-1$
+ " select e1 from #t1;\n" + //$NON-NLS-1$
+ "END"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = createProcedureMetadata(proc);
+ String userQuery = "SELECT * FROM (EXEC pm1.sq1()) as proc"; //$NON-NLS-1$
+ FakeDataManager dataMgr = exampleDataManager2(metadata);
+ ProcessorPlan plan = getProcedurePlan(userQuery, metadata, TestOptimizer.getGenericFinder());
+
+ List[] expected = new List[] {
+ Arrays.asList( new Object[] { String.valueOf(1) } ),
+ };
+ helpTestProcess(plan, expected, dataMgr);
+ }
+
private static final boolean DEBUG = false;
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestProjectIntoNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestProjectIntoNode.java 2009-09-20 16:31:50 UTC (rev 1427)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestProjectIntoNode.java 2009-09-21 17:29:59 UTC (rev 1428)
@@ -29,6 +29,7 @@
import junit.framework.TestCase;
import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.query.ExpressionEvaluationException;
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.TupleBatch;
@@ -146,7 +147,7 @@
this.exceptionOnClose = exceptionOnClose;
}
public Object lookupCodeValue(CommandContext context,String codeTableName,String returnElementName,String keyElementName,Object keyValue) throws BlockedException,MetaMatrixComponentException {return null;}
- public TupleSource registerRequest(Object processorID,Command command,String modelName,String connectorBindingId, int nodeID) throws MetaMatrixComponentException {
+ public TupleSource registerRequest(Object processorID,Command command,String modelName,String connectorBindingId, int nodeID) throws MetaMatrixComponentException, ExpressionEvaluationException {
callCount++;
int batchSize = 1;
@@ -155,7 +156,7 @@
if (command instanceof Insert) {
Insert insert = (Insert)command;
if (insert.isBulk()) {
- List batch = TempTableStoreImpl.getBulkRows(insert);
+ List batch = TempTableStoreImpl.getBulkRows(insert, insert.getVariables());
batchSize = batch.size();
assertEquals("Unexpected batch on call " + callCount, expectedBatchSize, batchSize); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java 2009-09-20 16:31:50 UTC (rev 1427)
+++ trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java 2009-09-21 17:29:59 UTC (rev 1428)
@@ -1928,23 +1928,6 @@
helpValidate("SELECT * FROM vm1.doc1 where context(1, a2)='x'", new String[] {"context(1, a2)"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testValidTempUpdateDelete() {
- FakeMetadataFacade fakeMetadata = exampleMetadata();
-
- TempMetadataStore store = new TempMetadataStore(new HashMap());
-
- ElementSymbol e1 = new ElementSymbol("#temp.e1");//$NON-NLS-1$
- e1.setType(DataTypeManager.DefaultDataClasses.INTEGER);
-
- store.addTempGroup("#temp", Arrays.asList(e1), false, true); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = new TempMetadataAdapter(fakeMetadata, store);
-
- helpValidate("delete from #temp", new String[] {"#temp"}, metadata); //$NON-NLS-1$ //$NON-NLS-2$
-
- helpValidate("update #temp set e1 = 1", new String[] {"#temp"}, metadata); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
public void testInsertIntoVirtualWithQuery() throws Exception {
QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
Command command = helpResolve("insert into vm1.g1 select 1, 2, true, 3", metadata); //$NON-NLS-1$
15 years, 3 months
teiid SVN: r1427 - trunk/test-integration/db/src/main/resources.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-20 12:31:50 -0400 (Sun, 20 Sep 2009)
New Revision: 1427
Added:
trunk/test-integration/db/src/main/resources/xa-config.properties
Modified:
trunk/test-integration/db/src/main/resources/default-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-20 16:31:17 UTC (rev 1426)
+++ trunk/test-integration/db/src/main/resources/default-config.properties 2009-09-20 16:31:50 UTC (rev 1427)
@@ -2,6 +2,10 @@
# Common Properties for everybody
##########################################
+
+# local, xa, jndi
+transaction-type=local
+
process-batch = 20
connector-batch = 20
@@ -57,10 +61,6 @@
#connection-type=datasource
#connection-type=driver
-
-# local, xa, jndi
-#transaction-type=local
-
# autocommit applies to local transaction-type only
# default is true
#autocommit=false
Added: trunk/test-integration/db/src/main/resources/xa-config.properties
===================================================================
--- trunk/test-integration/db/src/main/resources/xa-config.properties (rev 0)
+++ trunk/test-integration/db/src/main/resources/xa-config.properties 2009-09-20 16:31:50 UTC (rev 1427)
@@ -0,0 +1,76 @@
+##########################################
+# Common Properties for everybody
+##########################################
+# local, xa, jndi
+transaction-type=xa
+
+process-batch = 20
+connector-batch = 20
+
+# this is how to submit queries to Teiid
+# default is true
+execute.in.batch=false
+
+##########################################
+# properties for Teiid connection
+##########################################
+driver=com.metamatrix.jdbc.EmbeddedDataSource
+URL=jdbc:metamatrix:Transaction@target/classes/transactions/transaction.properties
+User=metamatrixadmin
+Password=mm
+databasename=Transaction
+servername=target/classes/transactions/transaction.properties
+portnumber=0
+application-name=txn-test
+
+# jboss
+# mm.ds-jndiname=java:mmXA
+# usertxn-jndiname=UserTransaction
+
+# weblogic
+mm.ds-jndiname=mmXA
+usertxn-jndiname=java:comp/UserTransaction
+
+# === Mode-to-Datasource Mapping ======
+# <model>=<datasource type name>
+
+# This mapping will be used by the set of testcases that load this config file.
+# These mapping control what datasource is mapped to which model
+#
+# See the resources/datasources/datasource_mapping.xml for the available datasource type names
+#
+# <datasource type name> can be the name of either a datasourcegroup or datasource
+#
+#
+
+pm1=nonxa
+pm2=nonxa
+
+
+##########################################
+# 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
+
+#-----------------------------
+
+
Property changes on: trunk/test-integration/db/src/main/resources/xa-config.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 3 months
teiid SVN: r1426 - 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-20 12:31:17 -0400 (Sun, 20 Sep 2009)
New Revision: 1426
Added:
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionDriverFalseOffTest.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/XATransactionDriverFalseOffTest.java
Removed:
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransaction.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransaction.java
Modified:
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionDriverTrueOffTest.java
Log:
Teiid 773 - renamed SingelSourceTransaction and TwoSourceTransaction to include the word scenarios in the name because these represent all the defined scenarios that are setup. And in each transaction type test (i.e., local, xa, etc), all the scenarios should be run and those that are not valid for a certain test type, then it needs to be documented and explicitly overridden.
Added: 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 (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionDriverFalseOffTest.java 2009-09-20 16:31:17 UTC (rev 1426)
@@ -0,0 +1,44 @@
+/*
+ * 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.connection.ConnectionStrategy;
+
+
+/**
+ * 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 {
+
+ System.setProperty(ConfigPropertyNames.CONNECTION_TYPE, ConfigPropertyNames.CONNECTION_TYPES.DRIVER_CONNECTION);
+ System.setProperty(ConnectionStrategy.AUTOCOMMIT, "false");
+ System.setProperty(ConnectionStrategy.TXN_AUTO_WRAP, "off");
+ // System.setProperty(ConnectionStrategy.FETCH_SIZE, "20");
+
+
+ }
+
+
+
+
+
+
+
+
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionDriverFalseOffTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionDriverTrueOffTest.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionDriverTrueOffTest.java 2009-09-20 04:22:12 UTC (rev 1425)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionDriverTrueOffTest.java 2009-09-20 16:31:17 UTC (rev 1426)
@@ -13,12 +13,11 @@
*
* Settings:
*
- * - Transaction Type = local
* - Using Driver
* - Autocommit = True
* - TxnAutoWrap = Off
*/
-public class LocalTransactionDriverTrueOffTest extends TwoSourceTransaction {
+public class LocalTransactionDriverTrueOffTest extends TwoSourceTransactionScenarios {
public LocalTransactionDriverTrueOffTest(String name) {
super(name);
@@ -27,16 +26,12 @@
@Override
protected void setUp() throws Exception {
- System.setProperty(ConfigPropertyNames.TRANSACTION_TYPE, ConfigPropertyNames.TRANSACTION_TYPES.LOCAL_TRANSACTION);
-
System.setProperty(ConfigPropertyNames.CONNECTION_TYPE, ConfigPropertyNames.CONNECTION_TYPES.DRIVER_CONNECTION);
System.setProperty(ConnectionStrategy.AUTOCOMMIT, "true");
System.setProperty(ConnectionStrategy.TXN_AUTO_WRAP, "off");
// System.setProperty(ConnectionStrategy.FETCH_SIZE, "true");
- }
-
-
-
+ }
+
}
Deleted: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransaction.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransaction.java 2009-09-20 04:22:12 UTC (rev 1425)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransaction.java 2009-09-20 16:31:17 UTC (rev 1426)
@@ -1,270 +0,0 @@
-/*
- * Copyright (c) 2000-2007 MetaMatrix, Inc.
- * All rights reserved.
- */
-package org.teiid.test.testcases;
-
-import org.teiid.test.framework.AbstractQueryTransactionTest;
-import org.teiid.test.framework.QueryExecution;
-
-import com.metamatrix.jdbc.api.AbstractQueryTest;
-
-
-
-/**
- * A common SingleSource test case among many different transaction stuff.
- */
-public class SingleSourceTransaction extends BaseAbstractTransactionTestCase {
-
- public SingleSourceTransaction(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);
- }
-
- public void validateTestCase() throws Exception {
-
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- // there is nothing to verify here..
-
- System.out.println("Complete CommonTransactionTest.testSingleSourceSelect");
-
- }
-
-
- /**
- * 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);
-
-
- System.out.println("Complete CommonTransactionTest.testSingleSourceUpdate");
-
- }
-
-
- /**
- * 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);
-
-
- System.out.println("Complete CommonTransactionTest.testSingleSourcePreparedUpdate");
-
- }
-
- /**
- * 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);
-
-
- System.out.println("Complete CommonTransactionTest.testSingleSourceMultipleCommands");
-
- }
-
- /**
- * 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);
- }
-
- public void validateTestCase() throws Exception {
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- System.out.println("Complete CommonTransactionTest.testSingleSourcePartialProcessing");
-
- }
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = rollback
- */
-
- public void xtestSingleSourceMultipleCommandsExplicitRollback() throws Exception {
- // now it's empty
- AbstractQueryTest test = new QueryExecution(this.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();
-
-
- 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);
-
-
- System.out.println("Complete testSingleSourceMultipleCommandsExplicitRollback");
- }
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = rollback
- */
- public void xtestSingleSourceMultipleCommandsReferentialIntegrityRollback() 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);
-
- System.out.println("Complete testSingleSourceMultipleCommandsReferentialIntegrityRollback");
-
- }
-
-}
Copied: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionScenarios.java (from rev 1424, trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransaction.java)
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionScenarios.java (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionScenarios.java 2009-09-20 16:31:17 UTC (rev 1426)
@@ -0,0 +1,276 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+import org.teiid.test.framework.AbstractQueryTransactionTest;
+import org.teiid.test.framework.QueryExecution;
+import org.teiid.test.framework.TransactionQueryTest;
+
+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);
+ }
+
+ public void validateTestCase() throws Exception {
+
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // there is nothing to verify here..
+
+ System.out.println("Complete testSingleSourceSelect");
+
+ }
+
+
+ /**
+ * 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);
+
+
+ System.out.println("Complete testSingleSourceUpdate");
+
+ }
+
+
+ /**
+ * 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);
+
+
+ System.out.println("Complete testSingleSourcePreparedUpdate");
+
+ }
+
+ /**
+ * 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);
+
+
+ System.out.println("Complete testSingleSourceMultipleCommands");
+
+ }
+
+ /**
+ * 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);
+ }
+
+ public void validateTestCase() throws Exception {
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ System.out.println("Complete testSingleSourcePartialProcessing");
+
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * 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();
+
+
+ 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);
+
+ System.out.println("Complete testSingleSourceMultipleCommandsExplicitRollback");
+
+ }
+
+ /**
+ * 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);
+
+ System.out.println("Complete testSingleSourceMultipleCommandsReferentialIntegrityRollback");
+
+ }
+
+
+
+
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionScenarios.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransaction.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransaction.java 2009-09-20 04:22:12 UTC (rev 1425)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransaction.java 2009-09-20 16:31:17 UTC (rev 1426)
@@ -1,801 +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.AbstractQueryTransactionTest;
-import org.teiid.test.framework.QueryExecution;
-
-import com.metamatrix.jdbc.api.AbstractQueryTest;
-
-
-
-/**
- * Test cases that require 2 datasources
- */
-public class TwoSourceTransaction extends SingleSourceTransaction {
-
- public TwoSourceTransaction(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;
- }
-
- public void validateTestCase() throws Exception {
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourceSelect");
-
- }
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceVirtualSelect() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceVirtualSelect") {
- public void testCase() throws Exception {
- execute("select * from vm.g1 where vm.g1.pm1e1 < 100");
- assertRowCount(100);
- }
- public int getNumberRequiredDataSources(){
- return 2;
- }
- public void validateTestCase() throws Exception {
- }
-
- };
-
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourceVirtualSelect");
-
- }
-
- /**
- * Sources = 2
- * Commands = 1, Update
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceUpdate() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceUpdate") {
- 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);
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourceUpdate");
-
- }
-
- /**
- * Sources = 2
- * Commands = 1, Update
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceSelectInto() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceSelectInto") {
- 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);
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourceSelectInto");
-
- }
-
- /**
- * Sources = 2
- * Commands = 1, Update
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceBulkRowInsert() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceBulkRowInsert") {
- 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);
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourceBulkRowInsert");
-
- }
-
- /**
- * Sources = 2
- * Commands = 1, Update(prepared statement)
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourcePreparedUpdate() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourcePreparedUpdate") {
- 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);
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourcePreparedUpdate");
-
- }
-
-
- /**
- * Sources = 2
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void 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);
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourceMultipleCommands");
-
-
- }
-
- /**
- * Sources = 2
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceMultipleVirtualCommands() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleVirtualCommands") {
- 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);
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourceMultipleVirtualCommands");
-
-
- }
-
- /**
- * 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);
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourceMultipleCommandsCancel");
-
- }
-
- /**
- * 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 {
- assertTrue(getLastException().getMessage().indexOf("Operation timed out before completion") != -1);
- }
- }
-
- 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);
-
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourceTimeout");
-
- }
-
-
- 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 testMultipleSourcePartialProcessingUsingLimit() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourcePartialProcessingUsingLimit") {
- 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);
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourcePartialProcessingUsingLimit");
-
- }
-
- /**
- * 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);
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourcePartialProcessingUsingMakedep");
-
- }
-
- /**
- * 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);
-
- System.out.println("Complete testMultipleSourceMultipleCommandsExplicitRollback");
-
- }
-
- /**
- * 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);
-
-
- System.out.println("Complete testMultipleSourceMultipleCommandsReferentialIntegrityRollback");
-
- }
-
- /**
- * Sources = 2
- * Commands = 1, Update
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceBulkRowInsertRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceBulkRowInsertRollback") {
- 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);
-
-
- System.out.println("Complete testMultipleSourceBulkRowInsertRollback");
-
- }
-
- /**
- * Sources = 2
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceMultipleVirtualCommandsRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleVirtualCommandsRollback") {
- 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);
-
-
- System.out.println("Complete testMultipleSourceMultipleVirtualCommandsRollback");
-
- }
-
-
-}
Copied: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionScenarios.java (from rev 1424, trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransaction.java)
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionScenarios.java (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionScenarios.java 2009-09-20 16:31:17 UTC (rev 1426)
@@ -0,0 +1,811 @@
+/*
+ * 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.AbstractQueryTransactionTest;
+import org.teiid.test.framework.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;
+ }
+
+ public void validateTestCase() throws Exception {
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ System.out.println("Complete testMultipleSourceSelect");
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceViewSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceVirtualSelect") {
+ public void testCase() throws Exception {
+ execute("select * from vm.g1 where vm.g1.pm1e1 < 100");
+ assertRowCount(100);
+ }
+ public int getNumberRequiredDataSources(){
+ return 2;
+ }
+ public void validateTestCase() throws Exception {
+ }
+
+ };
+
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ System.out.println("Complete testMultipleSourceVirtualSelect");
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceViewUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceUpdate") {
+ 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);
+
+ System.out.println("Complete testMultipleSourceUpdate");
+
+ }
+
+ /**
+ * 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);
+
+ System.out.println("Complete testMultipleSourceViewSelectInto");
+
+ }
+
+ /**
+ * 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);
+
+ System.out.println("Complete testMultipleSourceViewBulkRowInsert");
+
+ }
+
+ /**
+ * 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);
+
+
+ System.out.println("Complete testMultipleSourceViewBulkRowInsertRollback");
+
+ }
+
+
+ /**
+ * 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);
+
+ System.out.println("Complete testMultipleSourceViewPreparedUpdate");
+
+ }
+
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void 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);
+
+ System.out.println("Complete testMultipleSourceMultipleCommands");
+
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceViewMultipleCommands() throws Exception {
+ 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);
+
+ System.out.println("Complete testMultipleSourceViewMultipleCommands");
+
+
+ }
+
+ /**
+ * 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);
+
+
+ System.out.println("Complete testMultipleSourceViewMultipleCommandsRollback");
+
+ }
+
+
+ /**
+ * 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);
+
+ System.out.println("Complete testMultipleSourceMultipleCommandsCancel");
+
+ }
+
+
+ /**
+ * 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);
+
+ System.out.println("Complete testMultipleSourceMultipleCommandsExplicitRollback");
+
+ }
+
+ /**
+ * 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);
+
+
+ System.out.println("Complete testMultipleSourceMultipleCommandsReferentialIntegrityRollback");
+
+ }
+
+
+
+ /**
+ * 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 {
+ assertTrue(getLastException().getMessage().indexOf("Operation timed out before completion") != -1);
+ }
+ }
+
+ 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);
+
+
+ System.out.println("Complete testMultipleSourceTimeout");
+
+ }
+
+
+ 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);
+
+ System.out.println("Complete testMultipleSourceViewPartialProcessingUsingLimit");
+
+ }
+
+ /**
+ * 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);
+
+ System.out.println("Complete testMultipleSourcePartialProcessingUsingMakedep");
+
+ }
+
+
+
+
+
+
+
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionScenarios.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/XATransactionDriverFalseOffTest.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/XATransactionDriverFalseOffTest.java (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/XATransactionDriverFalseOffTest.java 2009-09-20 16:31:17 UTC (rev 1426)
@@ -0,0 +1,41 @@
+/*
+ * 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.connection.ConnectionStrategy;
+
+
+/**
+ * Local Transaction Test
+ *
+ * Settings:
+ *
+ * - Transaction Type = local
+ * - Using Driver
+ * - Autocommit = True
+ * - TxnAutoWrap = Off
+ */
+public class XATransactionDriverFalseOffTest extends TwoSourceTransactionScenarios {
+
+ public XATransactionDriverFalseOffTest(String name) {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ System.setProperty(ConfigPropertyNames.CONFIG_FILE, "xa-conig.properties");
+
+ System.setProperty(ConfigPropertyNames.CONNECTION_TYPE, ConfigPropertyNames.CONNECTION_TYPES.DATASOURCE_CONNECTION);
+ System.setProperty(ConnectionStrategy.AUTOCOMMIT, "true");
+ System.setProperty(ConnectionStrategy.TXN_AUTO_WRAP, "off");
+ // System.setProperty(ConnectionStrategy.FETCH_SIZE, "true");
+
+
+ }
+
+
+
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/XATransactionDriverFalseOffTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 3 months
teiid SVN: r1425 - trunk/test-integration/db/src/main/resources.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-20 00:22:12 -0400 (Sun, 20 Sep 2009)
New Revision: 1425
Modified:
trunk/test-integration/db/src/main/resources/default-config.properties
Log:
Teiid 773 - organize integration test - changed it where a specialized testcase (i.e. LocalTransactionDriverTrueOffTest) only has to extend the single/two source testcases and provide the setup of the properties to control how the tests will be performed (i.e., autocommit, transaction type, connection type, txnautowrap, etc.). Now I can create variations of the specialized testcase in order to test the same set of tests (queries) under different behavior options.
Modified: trunk/test-integration/db/src/main/resources/default-config.properties
===================================================================
--- trunk/test-integration/db/src/main/resources/default-config.properties 2009-09-20 04:17:44 UTC (rev 1424)
+++ trunk/test-integration/db/src/main/resources/default-config.properties 2009-09-20 04:22:12 UTC (rev 1425)
@@ -1,34 +1,16 @@
##########################################
# Common Properties for everybody
##########################################
-#available types (datasource, driver, jndi)
-#connection-type=datasource
-connection-type=driver
process-batch = 20
connector-batch = 20
-# local, xa, jndi
-transaction-type=local
-
-# autocommit applies to local transaction-type only
-# default is true
-autocommit=false
-
# this is how to submit queries to Teiid
# default is true
execute.in.batch=false
-
-# AUTO_WRAP_OFF = "OFF"
-# AUTO_WRAP_ON = "ON"
-# AUTO_WRAP_PESSIMISTIC = "PESSIMISTIC"
-# AUTO_WRAP_OPTIMISTIC = "OPTIMISTIC"
-
-txnAutoWrap=off
-
##########################################
-# properties for MetaMatrix connection
+# properties for Teiid connection
##########################################
driver=com.metamatrix.jdbc.EmbeddedDataSource
URL=jdbc:metamatrix:Transaction@target/classes/transactions/transaction.properties
@@ -62,9 +44,34 @@
pm1=nonxa
pm2=nonxa
-#pm1=mysqlA
-#pm2=mysqlB
+##########################################
+# 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
+
+# local, xa, jndi
+#transaction-type=local
+
+# 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, 3 months
teiid SVN: r1424 - 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-20 00:17:44 -0400 (Sun, 20 Sep 2009)
New Revision: 1424
Added:
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionDriverTrueOffTest.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransaction.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransaction.java
Removed:
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionTest.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionTest.java
Modified:
trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java
Log:
Teiid 773 - organize integration test - changed it where a specialized testcase (i.e. LocalTransactionDriverTrueOffTest) only has to extend the single/two source testcases and provide the setup of the properties to control how the tests will be performed (i.e., autocommit, transaction type, connection type, txnautowrap, etc.). Now I can create variations of the specialized testcase in order to test the same set of tests (queries) under different behavior options.
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-20 04:12:21 UTC (rev 1423)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java 2009-09-20 04:17:44 UTC (rev 1424)
@@ -15,6 +15,7 @@
import javax.sql.XAConnection;
+import org.teiid.test.framework.connection.ConnectionStrategy;
import org.teiid.test.framework.connection.ConnectionStrategyFactory;
import org.teiid.test.framework.datasource.DataSourceSetupFactory;
import org.teiid.test.framework.exception.TransactionRuntimeException;
@@ -63,13 +64,13 @@
if (this.executionProperties != null) {
if (stmt instanceof com.metamatrix.jdbc.api.Statement) {
com.metamatrix.jdbc.api.Statement statement = (com.metamatrix.jdbc.api.Statement)stmt;
- String txnautowrap = this.executionProperties.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP);
+ String txnautowrap = this.executionProperties.getProperty(ConnectionStrategy.TXN_AUTO_WRAP);
if (txnautowrap != null) {
- statement.setExecutionProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP, txnautowrap);
+ statement.setExecutionProperty(ConnectionStrategy.TXN_AUTO_WRAP, txnautowrap);
}
- if (this.executionProperties.getProperty(ExecutionProperties.PROP_FETCH_SIZE) != null) {
- statement.setExecutionProperty(ExecutionProperties.PROP_FETCH_SIZE, this.executionProperties.getProperty(ExecutionProperties.PROP_FETCH_SIZE));
+ if (this.executionProperties.getProperty(ConnectionStrategy.FETCH_SIZE) != null) {
+ statement.setExecutionProperty(ConnectionStrategy.FETCH_SIZE, this.executionProperties.getProperty(ConnectionStrategy.FETCH_SIZE));
}
}
}
Added: 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 (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionDriverTrueOffTest.java 2009-09-20 04:17:44 UTC (rev 1424)
@@ -0,0 +1,42 @@
+/*
+ * 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.connection.ConnectionStrategy;
+
+
+/**
+ * Local Transaction Test
+ *
+ * Settings:
+ *
+ * - Transaction Type = local
+ * - Using Driver
+ * - Autocommit = True
+ * - TxnAutoWrap = Off
+ */
+public class LocalTransactionDriverTrueOffTest extends TwoSourceTransaction {
+
+ public LocalTransactionDriverTrueOffTest(String name) {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+
+ System.setProperty(ConfigPropertyNames.TRANSACTION_TYPE, ConfigPropertyNames.TRANSACTION_TYPES.LOCAL_TRANSACTION);
+
+ System.setProperty(ConfigPropertyNames.CONNECTION_TYPE, ConfigPropertyNames.CONNECTION_TYPES.DRIVER_CONNECTION);
+ System.setProperty(ConnectionStrategy.AUTOCOMMIT, "true");
+ System.setProperty(ConnectionStrategy.TXN_AUTO_WRAP, "off");
+ // System.setProperty(ConnectionStrategy.FETCH_SIZE, "true");
+
+
+ }
+
+
+
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionDriverTrueOffTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransaction.java (from rev 1327, trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionTest.java)
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransaction.java (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransaction.java 2009-09-20 04:17:44 UTC (rev 1424)
@@ -0,0 +1,270 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+import org.teiid.test.framework.AbstractQueryTransactionTest;
+import org.teiid.test.framework.QueryExecution;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+
+
+/**
+ * A common SingleSource test case among many different transaction stuff.
+ */
+public class SingleSourceTransaction extends BaseAbstractTransactionTestCase {
+
+ public SingleSourceTransaction(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);
+ }
+
+ public void validateTestCase() throws Exception {
+
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // there is nothing to verify here..
+
+ System.out.println("Complete CommonTransactionTest.testSingleSourceSelect");
+
+ }
+
+
+ /**
+ * 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);
+
+
+ System.out.println("Complete CommonTransactionTest.testSingleSourceUpdate");
+
+ }
+
+
+ /**
+ * 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);
+
+
+ System.out.println("Complete CommonTransactionTest.testSingleSourcePreparedUpdate");
+
+ }
+
+ /**
+ * 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);
+
+
+ System.out.println("Complete CommonTransactionTest.testSingleSourceMultipleCommands");
+
+ }
+
+ /**
+ * 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);
+ }
+
+ public void validateTestCase() throws Exception {
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ System.out.println("Complete CommonTransactionTest.testSingleSourcePartialProcessing");
+
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = rollback
+ */
+
+ public void xtestSingleSourceMultipleCommandsExplicitRollback() throws Exception {
+ // now it's empty
+ AbstractQueryTest test = new QueryExecution(this.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();
+
+
+ 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);
+
+
+ System.out.println("Complete testSingleSourceMultipleCommandsExplicitRollback");
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = rollback
+ */
+ public void xtestSingleSourceMultipleCommandsReferentialIntegrityRollback() 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);
+
+ System.out.println("Complete testSingleSourceMultipleCommandsReferentialIntegrityRollback");
+
+ }
+
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransaction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionTest.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionTest.java 2009-09-20 04:12:21 UTC (rev 1423)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/SingleSourceTransactionTest.java 2009-09-20 04:17:44 UTC (rev 1424)
@@ -1,270 +0,0 @@
-/*
- * Copyright (c) 2000-2007 MetaMatrix, Inc.
- * All rights reserved.
- */
-package org.teiid.test.testcases;
-
-import org.teiid.test.framework.AbstractQueryTransactionTest;
-import org.teiid.test.framework.QueryExecution;
-
-import com.metamatrix.jdbc.api.AbstractQueryTest;
-
-
-
-/**
- * A common SingleSource test case among many different transaction stuff.
- */
-public class SingleSourceTransactionTest extends BaseAbstractTransactionTestCase {
-
- public SingleSourceTransactionTest(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);
- }
-
- public void validateTestCase() throws Exception {
-
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- // there is nothing to verify here..
-
- System.out.println("Complete CommonTransactionTest.testSingleSourceSelect");
-
- }
-
-
- /**
- * 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);
-
-
- System.out.println("Complete CommonTransactionTest.testSingleSourceUpdate");
-
- }
-
-
- /**
- * 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);
-
-
- System.out.println("Complete CommonTransactionTest.testSingleSourcePreparedUpdate");
-
- }
-
- /**
- * 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);
-
-
- System.out.println("Complete CommonTransactionTest.testSingleSourceMultipleCommands");
-
- }
-
- /**
- * 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);
- }
-
- public void validateTestCase() throws Exception {
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- System.out.println("Complete CommonTransactionTest.testSingleSourcePartialProcessing");
-
- }
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = rollback
- */
-
- public void xtestSingleSourceMultipleCommandsExplicitRollback() throws Exception {
- // now it's empty
- AbstractQueryTest test = new QueryExecution(this.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();
-
-
- 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);
-
-
- System.out.println("Complete testSingleSourceMultipleCommandsExplicitRollback");
- }
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = rollback
- */
- public void xtestSingleSourceMultipleCommandsReferentialIntegrityRollback() 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);
-
- System.out.println("Complete testSingleSourceMultipleCommandsReferentialIntegrityRollback");
-
- }
-
-}
Copied: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransaction.java (from rev 1378, trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionTest.java)
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransaction.java (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransaction.java 2009-09-20 04:17:44 UTC (rev 1424)
@@ -0,0 +1,801 @@
+/*
+ * 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.AbstractQueryTransactionTest;
+import org.teiid.test.framework.QueryExecution;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+
+
+/**
+ * Test cases that require 2 datasources
+ */
+public class TwoSourceTransaction extends SingleSourceTransaction {
+
+ public TwoSourceTransaction(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;
+ }
+
+ public void validateTestCase() throws Exception {
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourceSelect");
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceVirtualSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceVirtualSelect") {
+ public void testCase() throws Exception {
+ execute("select * from vm.g1 where vm.g1.pm1e1 < 100");
+ assertRowCount(100);
+ }
+ public int getNumberRequiredDataSources(){
+ return 2;
+ }
+ public void validateTestCase() throws Exception {
+ }
+
+ };
+
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourceVirtualSelect");
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceUpdate") {
+ 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);
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourceUpdate");
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceSelectInto() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceSelectInto") {
+ 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);
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourceSelectInto");
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceBulkRowInsert() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceBulkRowInsert") {
+ 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);
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourceBulkRowInsert");
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Update(prepared statement)
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourcePreparedUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourcePreparedUpdate") {
+ 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);
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourcePreparedUpdate");
+
+ }
+
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void 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);
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourceMultipleCommands");
+
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceMultipleVirtualCommands() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleVirtualCommands") {
+ 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);
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourceMultipleVirtualCommands");
+
+
+ }
+
+ /**
+ * 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);
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourceMultipleCommandsCancel");
+
+ }
+
+ /**
+ * 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 {
+ assertTrue(getLastException().getMessage().indexOf("Operation timed out before completion") != -1);
+ }
+ }
+
+ 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);
+
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourceTimeout");
+
+ }
+
+
+ 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 testMultipleSourcePartialProcessingUsingLimit() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourcePartialProcessingUsingLimit") {
+ 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);
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourcePartialProcessingUsingLimit");
+
+ }
+
+ /**
+ * 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);
+
+ System.out.println("Complete CommonTransactionTest.testMultipleSourcePartialProcessingUsingMakedep");
+
+ }
+
+ /**
+ * 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);
+
+ System.out.println("Complete testMultipleSourceMultipleCommandsExplicitRollback");
+
+ }
+
+ /**
+ * 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);
+
+
+ System.out.println("Complete testMultipleSourceMultipleCommandsReferentialIntegrityRollback");
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceBulkRowInsertRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceBulkRowInsertRollback") {
+ 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);
+
+
+ System.out.println("Complete testMultipleSourceBulkRowInsertRollback");
+
+ }
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceMultipleVirtualCommandsRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleVirtualCommandsRollback") {
+ 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);
+
+
+ System.out.println("Complete testMultipleSourceMultipleVirtualCommandsRollback");
+
+ }
+
+
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransaction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionTest.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionTest.java 2009-09-20 04:12:21 UTC (rev 1423)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/TwoSourceTransactionTest.java 2009-09-20 04:17:44 UTC (rev 1424)
@@ -1,802 +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.AbstractQueryTransactionTest;
-import org.teiid.test.framework.QueryExecution;
-import org.teiid.test.framework.datasource.DataSource;
-
-import com.metamatrix.jdbc.api.AbstractQueryTest;
-
-
-
-/**
- * Test cases that require 2 datasources
- */
-public class TwoSourceTransactionTest extends BaseAbstractTransactionTestCase {
-
- public TwoSourceTransactionTest(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;
- }
-
- public void validateTestCase() throws Exception {
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourceSelect");
-
- }
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceVirtualSelect() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceVirtualSelect") {
- public void testCase() throws Exception {
- execute("select * from vm.g1 where vm.g1.pm1e1 < 100");
- assertRowCount(100);
- }
- public int getNumberRequiredDataSources(){
- return 2;
- }
- public void validateTestCase() throws Exception {
- }
-
- };
-
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourceVirtualSelect");
-
- }
-
- /**
- * Sources = 2
- * Commands = 1, Update
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceUpdate() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceUpdate") {
- 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);
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourceUpdate");
-
- }
-
- /**
- * Sources = 2
- * Commands = 1, Update
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceSelectInto() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceSelectInto") {
- 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);
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourceSelectInto");
-
- }
-
- /**
- * Sources = 2
- * Commands = 1, Update
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceBulkRowInsert() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceBulkRowInsert") {
- 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);
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourceBulkRowInsert");
-
- }
-
- /**
- * Sources = 2
- * Commands = 1, Update(prepared statement)
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourcePreparedUpdate() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourcePreparedUpdate") {
- 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);
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourcePreparedUpdate");
-
- }
-
-
- /**
- * Sources = 2
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void 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);
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourceMultipleCommands");
-
-
- }
-
- /**
- * Sources = 2
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceMultipleVirtualCommands() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleVirtualCommands") {
- 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);
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourceMultipleVirtualCommands");
-
-
- }
-
- /**
- * 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);
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourceMultipleCommandsCancel");
-
- }
-
- /**
- * 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 {
- assertTrue(getLastException().getMessage().indexOf("Operation timed out before completion") != -1);
- }
- }
-
- 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);
-
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourceTimeout");
-
- }
-
-
- 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 testMultipleSourcePartialProcessingUsingLimit() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourcePartialProcessingUsingLimit") {
- 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);
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourcePartialProcessingUsingLimit");
-
- }
-
- /**
- * 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);
-
- System.out.println("Complete CommonTransactionTest.testMultipleSourcePartialProcessingUsingMakedep");
-
- }
-
- /**
- * 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);
-
- System.out.println("Complete testMultipleSourceMultipleCommandsExplicitRollback");
-
- }
-
- /**
- * 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);
-
-
- System.out.println("Complete testMultipleSourceMultipleCommandsReferentialIntegrityRollback");
-
- }
-
- /**
- * Sources = 2
- * Commands = 1, Update
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceBulkRowInsertRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceBulkRowInsertRollback") {
- 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);
-
-
- System.out.println("Complete testMultipleSourceBulkRowInsertRollback");
-
- }
-
- /**
- * Sources = 2
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceMultipleVirtualCommandsRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleVirtualCommandsRollback") {
- 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);
-
-
- System.out.println("Complete testMultipleSourceMultipleVirtualCommandsRollback");
-
- }
-
-
-}
15 years, 3 months
teiid SVN: r1423 - 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-20 00:12:21 -0400 (Sun, 20 Sep 2009)
New Revision: 1423
Added:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java
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/ConnectionStrategy.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java
Log:
Teiid 773 - organize integration test - refactored properties so that it makes it easier to for the testcase to specify the property instead of putting it in the config properties file
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-19 03:29:55 UTC (rev 1422)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2009-09-20 04:12:21 UTC (rev 1423)
@@ -7,20 +7,16 @@
import org.teiid.test.framework.connection.ConnectionStrategyFactory;
public class ConfigPropertyLoader {
- /**
- * Specify this property to set a specific configuration to use
- */
- public static final String CONFIG_FILE="config";
/**
* The default config file to use when #CONFIG_FILE system property isn't set
*/
- private static final String DEFAULT_CONFIG_FILE_NAME="default-config.properties";
+ protected static final String DEFAULT_CONFIG_FILE_NAME="default-config.properties";
private static Properties props = null;
public synchronized static void loadConfigurationProperties() {
- String filename = System.getProperty(CONFIG_FILE);
+ String filename = System.getProperty(ConfigPropertyNames.CONFIG_FILE);
if (filename == null) {
filename = DEFAULT_CONFIG_FILE_NAME;
}
@@ -36,12 +32,14 @@
}
private static void loadProperties(String filename) {
- props = null;
+ props = System.getProperties();
try {
InputStream in = ConfigPropertyLoader.class.getResourceAsStream("/"+ filename);
if (in != null) {
- props = new Properties();
- props.load(in);
+ Properties lprops = new Properties();
+ lprops.load(in);
+ props.putAll(lprops);
+
}
else {
throw new RuntimeException("Failed to load properties from file '"+filename+ "' configuration file");
@@ -52,12 +50,17 @@
}
public static void main(String[] args) {
+ System.setProperty("test", "value");
+
ConfigPropertyLoader.loadConfigurationProperties();
Properties p = ConfigPropertyLoader.getProperties();
if (p == null || p.isEmpty()) {
throw new RuntimeException("Failed to load config properties file");
}
+ if (p.getProperty("test") == null) {
+ throw new RuntimeException("Failed to pickup system property");
+ }
System.out.println("Loaded Config Properties " + p.toString());
}
Added: 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 (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java 2009-09-20 04:12:21 UTC (rev 1423)
@@ -0,0 +1,67 @@
+package org.teiid.test.framework;
+
+/**
+ * The following properties can be set in 2 ways:
+ * <li>set as a System property(..)</li>
+ * <li>specify it in the config properties file</li>
+ *
+ * @author vanhalbert
+ *
+ */
+public interface ConfigPropertyNames {
+
+ /**
+ * Specify this as a system property to set a specific configuration to use
+ * otherwise the {@link ConfigPropertyLoader#DEFAULT_CONFIG_FILE_NAME} will be loaded.
+ */
+ public static final String CONFIG_FILE="config";
+
+
+ /**
+ * For Driver/Datasource connection related properties, {@link ConnectionStrategy}.
+ */
+
+
+ /**
+ * Transaction Type indicates the type of transaction container to use
+ * @see TransactionFactory
+ */
+ public static final String TRANSACTION_TYPE = "transaction-type"; //$NON-NLS-1$
+
+ public interface TRANSACTION_TYPES {
+ public static final String LOCAL_TRANSACTION = "local"; //$NON-NLS-1$
+ public static final String XATRANSACTION = "xa"; //$NON-NLS-1$
+ public static final String JNDI_TRANSACTION = "jndi"; //$NON-NLS-1$
+ }
+
+
+
+ /**
+ * 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
+ * connection.properties files.
+ */
+ public static final String USE_DATASOURCES_PROP = "usedatasources";
+
+
+ /**
+ * Connection Type indicates the type of connection (strategy) to use
+ * Options are {@link CONNECTION_TYPES}
+ */
+ public static final String CONNECTION_TYPE = "connection-type"; //$NON-NLS-1$
+
+
+ public interface CONNECTION_TYPES {
+
+ // used to create the jdb driver
+ public static final String DRIVER_CONNECTION = "driver"; //$NON-NLS-1$
+ // used to create a datasource
+ public static final String DATASOURCE_CONNECTION = "datasource"; //$NON-NLS-1$
+ // used for when embedded is running in an appserver
+ public static final String JNDI_CONNECTION = "jndi"; //$NON-NLS-1$
+
+
+ }
+
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-19 03:29:55 UTC (rev 1422)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java 2009-09-20 04:12:21 UTC (rev 1423)
@@ -23,28 +23,13 @@
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
+import com.metamatrix.jdbc.api.ExecutionProperties;
+
public abstract class ConnectionStrategy {
- /**
- * Connection Type indicates the type of connection (strategy) to use
- */
- public static final String CONNECTION_TYPE = "connection-type"; //$NON-NLS-1$
- /**
- * The connection types that map to connection strategies
- * ****************************************************************
- */
- // used to create the jdb driver
- public static final String DRIVER_CONNECTION = "driver"; //$NON-NLS-1$
- // used to create a datasource
- public static final String DATASOURCE_CONNECTION = "datasource"; //$NON-NLS-1$
- // used for when embedded is running in an appserver
- public static final String JNDI_CONNECTION = "jndi"; //$NON-NLS-1$
- /*
- * ******************************************************************
- */
-
+
public static final String DS_USER = "user"; //$NON-NLS-1$
// need both user variables because Teiid uses 'user' and connectors use 'username'
@@ -69,6 +54,10 @@
public static final String AUTOCOMMIT = "autocommit"; //$NON-NLS-1$
+ public static final String TXN_AUTO_WRAP = ExecutionProperties.PROP_TXN_AUTO_WRAP;
+
+ public static final String FETCH_SIZE = ExecutionProperties.PROP_FETCH_SIZE;
+
public static final String EXEC_IN_BATCH = "execute.in.batch"; //$NON-NLS-1$
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-19 03:29:55 UTC (rev 1422)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java 2009-09-20 04:12:21 UTC (rev 1423)
@@ -10,27 +10,17 @@
import java.util.Properties;
import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.ConfigPropertyNames;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
public class ConnectionStrategyFactory {
- /**
- * Specify this property to set a specific configuration to use
- */
- public static final String CONFIG_FILE="config";
-
- /**
- * The default config file to use when #CONFIG_FILE system property isn't set
- */
- private static final String DEFAULT_CONFIG_FILE_NAME="default-config.properties";
-
private static ConnectionStrategyFactory _instance = null;
private ConnectionStrategy strategy = null;
private static Map<String, ConnectionStrategy> sources = null;
-
-
+
private ConnectionStrategyFactory(){
}
@@ -59,14 +49,12 @@
_instance.shutdown();
_instance = null;
-
-
}
}
private void shutdown() {
Properties p = System.getProperties();
- p.remove(CONFIG_FILE);
+ p.remove(ConfigPropertyNames.CONFIG_FILE);
for (Iterator it=sources.keySet().iterator(); it.hasNext(); ){
@@ -101,26 +89,26 @@
ConnectionStrategy strategy = null;
- String type = props.getProperty(ConnectionStrategy.CONNECTION_TYPE, ConnectionStrategy.DRIVER_CONNECTION);
+ String type = props.getProperty(ConfigPropertyNames.CONNECTION_TYPE, ConfigPropertyNames.CONNECTION_TYPES.DRIVER_CONNECTION);
if (type == null) {
- throw new RuntimeException("Property " + ConnectionStrategy.CONNECTION_TYPE + " was specified");
+ throw new RuntimeException("Property " + ConfigPropertyNames.CONNECTION_TYPE + " was specified");
}
- if (type.equalsIgnoreCase(ConnectionStrategy.DRIVER_CONNECTION)) {
+ if (type.equalsIgnoreCase(ConfigPropertyNames.CONNECTION_TYPES.DRIVER_CONNECTION)) {
strategy = createDriverStrategy(null, props);
System.out.println("Created Driver Strategy");
}
- else if (type.equalsIgnoreCase(ConnectionStrategy.DATASOURCE_CONNECTION)) {
+ else if (type.equalsIgnoreCase(ConfigPropertyNames.CONNECTION_TYPES.DATASOURCE_CONNECTION)) {
strategy = createDataSourceStrategy(null, props);
System.out.println("Created DataSource Strategy");
}
- else if (type.equalsIgnoreCase(ConnectionStrategy.JNDI_CONNECTION)) {
+ else if (type.equalsIgnoreCase(ConfigPropertyNames.CONNECTION_TYPES.JNDI_CONNECTION)) {
strategy = createJEEStrategy(null, props);
System.out.println("Created JEE Strategy");
}
if (strategy == null) {
- new TransactionRuntimeException("Invalid property value for " + ConnectionStrategy.CONNECTION_TYPE + " is " + type );
+ new TransactionRuntimeException("Invalid property value for " + ConfigPropertyNames.CONNECTION_TYPE + " is " + type );
}
// call configure here because this is creating the connection to Teiid
// direct connections to the datasource use the static call directly to create strategy and don't need to configure
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java 2009-09-19 03:29:55 UTC (rev 1422)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java 2009-09-20 04:12:21 UTC (rev 1423)
@@ -30,6 +30,7 @@
public DriverConnection(Properties props) throws QueryTestFailedException {
super(props);
+ validate();
}
public void validate() {
@@ -81,8 +82,6 @@
}
}
-
- validate();
this.connection = getJDBCConnection(this.driver, this.url, this.username, this.pwd);
return this.connection;
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-19 03:29:55 UTC (rev 1422)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2009-09-20 04:12:21 UTC (rev 1423)
@@ -17,6 +17,8 @@
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
+import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.ConfigPropertyNames;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
import org.teiid.test.util.StringUtil;
@@ -25,7 +27,7 @@
import com.metamatrix.common.xml.XMLReaderWriterImpl;
/**
- * The DataSourceMgr is responsible for loading and managing the datasource
+ * The DataSourceMgr is responsible for loading and managing datasources defined by the datasource
* mapping properties file {@see #DATASOURCE_MAPPING_FILE} and the mapped
* datasource properties files. The {@link #getDatasourceProperties(String)}
* returns the properties defined for that datasourceid, which is mapped in the
@@ -36,13 +38,6 @@
*/
public class DataSourceMgr {
- /**
- * 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
- * connection.properties files.
- */
- static final String USE_DATASOURCES_PROP = "usedatasources";
static final String RELATIVE_DIRECTORY = "datasources/";
static final String DATASOURCE_MAPPING_FILE = "datasource_mapping.xml";
@@ -220,7 +215,7 @@
throws QueryTestFailedException {
Set<String> limitds = new HashSet<String>();
- String limitdsprop = System.getProperty(USE_DATASOURCES_PROP);
+ String limitdsprop = ConfigPropertyLoader.getProperty(ConfigPropertyNames.USE_DATASOURCES_PROP);
if (limitdsprop != null && limitdsprop.length() > 0) {
System.out.println("Limit datasources to: " + limitdsprop);
List<String> dss = StringUtil.split(limitdsprop, ",");
@@ -414,7 +409,7 @@
DataSourceMgr.reset();
- System.setProperty(DataSourceMgr.USE_DATASOURCES_PROP, "ds_sqlserver");
+ System.setProperty(ConfigPropertyNames.USE_DATASOURCES_PROP, "ds_sqlserver");
mgr = DataSourceMgr.getInstance();
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-19 03:29:55 UTC (rev 1422)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java 2009-09-20 04:12:21 UTC (rev 1423)
@@ -5,6 +5,7 @@
package org.teiid.test.framework.transaction;
import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.ConfigPropertyNames;
import org.teiid.test.framework.TransactionContainer;
import org.teiid.test.framework.exception.TransactionRuntimeException;
import org.teiid.test.framework.connection.ConnectionStrategy;
@@ -14,14 +15,6 @@
public class TransactionFactory {
- public static final String LOCAL_TRANSACTION = "local"; //$NON-NLS-1$
- public static final String XATRANSACTION = "xa"; //$NON-NLS-1$
- public static final String JNDI_TRANSACTION = "jndi"; //$NON-NLS-1$
-
- /**
- * Transaction Type indicates the type of transaction container to use
- */
- public static final String TRANSACTION_TYPE = "transaction-type"; //$NON-NLS-1$
private TransactionFactory(){}
@@ -37,22 +30,22 @@
ConnectionStrategy connstrategy = ConnectionStrategyFactory.getInstance().getConnectionStrategy();
- String type = connstrategy.getEnvironment().getProperty(TRANSACTION_TYPE, LOCAL_TRANSACTION);
+ String type = connstrategy.getEnvironment().getProperty(ConfigPropertyNames.TRANSACTION_TYPE, ConfigPropertyNames.TRANSACTION_TYPES.LOCAL_TRANSACTION);
if (type == null) {
- throw new RuntimeException("Property " + TRANSACTION_TYPE + " was specified");
+ throw new RuntimeException("Property " + ConfigPropertyNames.TRANSACTION_TYPE + " was specified");
}
- if (type.equalsIgnoreCase(LOCAL_TRANSACTION)) {
+ if (type.equalsIgnoreCase(ConfigPropertyNames.TRANSACTION_TYPES.LOCAL_TRANSACTION)) {
transacton = new LocalTransaction(connstrategy);
}
- else if (type.equalsIgnoreCase(XATRANSACTION)) {
+ else if (type.equalsIgnoreCase(ConfigPropertyNames.TRANSACTION_TYPES.XATRANSACTION)) {
transacton = new XATransaction(connstrategy);
}
- else if (type.equalsIgnoreCase(JNDI_TRANSACTION)) {
+ else if (type.equalsIgnoreCase(ConfigPropertyNames.TRANSACTION_TYPES.JNDI_TRANSACTION)) {
transacton = new JNDITransaction(connstrategy);
} else {
- throw new TransactionRuntimeException("Invalid property value of " + type + " for " + TRANSACTION_TYPE );
+ throw new TransactionRuntimeException("Invalid property value of " + type + " for " + ConfigPropertyNames.TRANSACTION_TYPE );
}
return transacton;
15 years, 3 months
teiid SVN: r1422 - in trunk/test-integration/db: src/main/java/org/teiid/test/framework/datasource and 1 other directory.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-18 23:29:55 -0400 (Fri, 18 Sep 2009)
New Revision: 1422
Modified:
trunk/test-integration/db/pom.xml
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
Log:
Teiid 773 - organize integration test - added option to specify which datasources (narrow the available datasources) to include in the test
Modified: trunk/test-integration/db/pom.xml
===================================================================
--- trunk/test-integration/db/pom.xml 2009-09-19 02:46:38 UTC (rev 1421)
+++ trunk/test-integration/db/pom.xml 2009-09-19 03:29:55 UTC (rev 1422)
@@ -101,6 +101,13 @@
<additionalClasspathElement>${basedir}/lib/db2jcc4.jar</additionalClasspathElement>
</additionalClasspathElements>
+ <systemProperties>
+ <property>
+ <name>usedatasources</name>
+ <value>${usedatasources}</value>
+ </property>
+ </systemProperties>
+
<!--
<forkMode>always</forkMode>
<forkedProcessTimeoutInSeconds>600</forkedProcessTimeoutInSeconds>
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-19 02:46:38 UTC (rev 1421)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2009-09-19 03:29:55 UTC (rev 1422)
@@ -42,7 +42,7 @@
* This enables one to test between certain datasources without having to remove
* connection.properties files.
*/
- static final String USE_DATASOURCES_PROP = "usedataources";
+ static final String USE_DATASOURCES_PROP = "usedatasources";
static final String RELATIVE_DIRECTORY = "datasources/";
static final String DATASOURCE_MAPPING_FILE = "datasource_mapping.xml";
@@ -222,6 +222,7 @@
Set<String> limitds = new HashSet<String>();
String limitdsprop = System.getProperty(USE_DATASOURCES_PROP);
if (limitdsprop != null && limitdsprop.length() > 0) {
+ System.out.println("Limit datasources to: " + limitdsprop);
List<String> dss = StringUtil.split(limitdsprop, ",");
limitds.addAll(dss);
}
@@ -283,6 +284,7 @@
if (include.size() > 0) {
if (!include.contains(name)) {
+ System.out.println("Excluded datasource: " + name);
return;
}
}
15 years, 3 months
teiid SVN: r1421 - 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-18 22:46:38 -0400 (Fri, 18 Sep 2009)
New Revision: 1421
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
Log:
Teiid 773 - organize integration test - added option to specify which datasources (narrow the available datasources) to include in the test
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java 2009-09-19 02:37:21 UTC (rev 1420)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java 2009-09-19 02:46:38 UTC (rev 1421)
@@ -48,10 +48,10 @@
return this.props;
}
- public boolean isOfDBType(String type) {
- return (this.dbtype.equalsIgnoreCase(type));
+ public String getDBType() {
+ return this.dbtype;
}
-
+
public int getBitMask() {
return this.bitMask;
}
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-19 02:37:21 UTC (rev 1420)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2009-09-19 02:46:38 UTC (rev 1421)
@@ -19,6 +19,7 @@
import org.jdom.JDOMException;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
+import org.teiid.test.util.StringUtil;
import com.metamatrix.common.xml.XMLReaderWriter;
import com.metamatrix.common.xml.XMLReaderWriterImpl;
@@ -35,8 +36,14 @@
*/
public class DataSourceMgr {
+ /**
+ * 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
+ * connection.properties files.
+ */
+ static final String USE_DATASOURCES_PROP = "usedataources";
-
static final String RELATIVE_DIRECTORY = "datasources/";
static final String DATASOURCE_MAPPING_FILE = "datasource_mapping.xml";
@@ -73,6 +80,17 @@
return _instance;
}
+ public static synchronized void reset() {
+
+ _instance.dstypeMap.clear();
+ _instance.allDatasourcesMap.clear();
+ _instance.modelToDatasourceMap.clear();
+ _instance.assignedDataSources.clear();
+
+ _instance = null;
+
+ }
+
public int numberOfAvailDataSources() {
return allDatasourcesMap.size();
}
@@ -172,7 +190,7 @@
modelToDatasourceMap.put(key, ds);
- }
+ }
} else {
@@ -200,7 +218,15 @@
private void loadDataSourceMappings()
throws QueryTestFailedException {
+
+ Set<String> limitds = new HashSet<String>();
+ String limitdsprop = System.getProperty(USE_DATASOURCES_PROP);
+ if (limitdsprop != null && limitdsprop.length() > 0) {
+ List<String> dss = StringUtil.split(limitdsprop, ",");
+ limitds.addAll(dss);
+ }
+
Document doc = null;
XMLReaderWriter readerWriter = new XMLReaderWriterImpl();
@@ -230,7 +256,7 @@
for (Iterator<Element> typeit = typeElements.iterator(); typeit.hasNext();) {
Element e = typeit.next();
- addDataSource(e, typename, datasources);
+ addDataSource(e, typename, datasources, limitds);
}
dstypeMap.put(typename, datasources);
allDatasourcesMap.putAll(datasources);
@@ -252,8 +278,14 @@
}
- private static void addDataSource(Element element, String type, Map<String, DataSource> datasources) {
+ private static void addDataSource(Element element, String group, Map<String, DataSource> datasources, Set<String> include) {
String name = element.getAttributeValue(Property.Attributes.NAME);
+
+ if (include.size() > 0) {
+ if (!include.contains(name)) {
+ return;
+ }
+ }
Properties props = getProperties(element);
String dir = props.getProperty(DataSource.DIRECTORY);
@@ -262,7 +294,7 @@
if (dsprops != null) {
props.putAll(dsprops);
DataSource ds = new DataSource(name,
- type,
+ group,
props);
datasources.put(ds.getName(), ds);
System.out.println("Loaded datasource " + ds.getName());
@@ -350,14 +382,14 @@
DataSourceMgr mgr = DataSourceMgr.getInstance();
try {
- DataSource ds1 = mgr.getDatasource("ds_mysql", "model1");
+ DataSource ds1 = mgr.getDatasource("ds_oracle", "model1");
DataSource ds2 = mgr.getDatasource("nonxa", "model1");
if (ds1 != ds2) {
throw new RuntimeException("Datasources are not the same");
}
System.out.println("Value for ds_mysql: "
- + mgr.getDatasourceProperties("ds_mysql", "model1"));
+ + mgr.getDatasourceProperties("ds_oracle", "model1"));
boolean shouldbeavail = mgr.hasAvailableDataSource("nonxa", DataSource.ExclusionTypeBitMask.ORACLE);
if (!shouldbeavail) {
@@ -377,7 +409,36 @@
} catch (QueryTestFailedException e) {
e.printStackTrace();
}
+
+ DataSourceMgr.reset();
+
+ System.setProperty(DataSourceMgr.USE_DATASOURCES_PROP, "ds_sqlserver");
+
+ mgr = DataSourceMgr.getInstance();
+ try {
+
+ DataSource dsfind = mgr.getDatasource("ds_sqlserver", "model1");
+ if (dsfind == null) {
+ throw new RuntimeException("The special included datasource was not found");
+
+ }
+ System.out.println("Datasource :" + dsfind.getName() + " was found");
+
+ try {
+ DataSource dsnotfound = mgr.getDatasource("ds_oracle", "model1");
+ if (dsnotfound != null) {
+ throw new RuntimeException("The special excluded datasource was found");
+
+ }
+ } catch (QueryTestFailedException qtf) {
+
+ System.out.println("Datasource: ds_oracle: was not found and should not have");
+ }
+
+ } catch (QueryTestFailedException e) {
+ e.printStackTrace();
+ }
}
}
15 years, 3 months