[teiid-commits] teiid SVN: r1701 - trunk/engine/src/test/java/com/metamatrix/query/processor.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Wed Dec 23 11:52:33 EST 2009


Author: shawkins
Date: 2009-12-23 11:52:32 -0500 (Wed, 23 Dec 2009)
New Revision: 1701

Modified:
   trunk/engine/src/test/java/com/metamatrix/query/processor/FakeProcessorPlan.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/TestBaseProcessorPlan.java
Log:
TEIID-911 consolidating fake processing plans

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/FakeProcessorPlan.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/FakeProcessorPlan.java	2009-12-23 16:39:47 UTC (rev 1700)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/FakeProcessorPlan.java	2009-12-23 16:52:32 UTC (rev 1701)
@@ -22,10 +22,20 @@
 
 package com.metamatrix.query.processor;
 
-import java.util.*;
+import static org.junit.Assert.*;
 
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.*;
+import com.metamatrix.common.buffer.BlockedException;
+import com.metamatrix.common.buffer.BufferManager;
+import com.metamatrix.common.buffer.TupleBatch;
+import com.metamatrix.query.sql.lang.Command;
 import com.metamatrix.query.util.CommandContext;
 
 /**
@@ -36,7 +46,8 @@
     private List batches;
     int batchIndex = 0;
     private int nextBatchRow = 1;
-
+    private boolean opened = false;
+    
     /**
      * Constructor for FakeProcessorPlan.
      * @param batches List of things to return in response to nextBatch() - typically 
@@ -47,6 +58,21 @@
         this.outputElements = outputElements;
         this.batches = batches;
     }
+    
+    public FakeProcessorPlan(int counts) {
+    	List[] rows = new List[counts];
+    	for (int i = 0; i < counts; i++) {
+            rows[i] = Arrays.asList(new Object[] {new Integer(1)});
+        }
+        TupleBatch batch = new TupleBatch(1, rows);
+        batch.setTerminationFlag(true);
+        this.batches = Arrays.asList(batch);
+        this.outputElements = Command.getUpdateCommandSymbol();
+    }
+    
+    public boolean isOpened() {
+		return opened;
+	}
 
     /**
      * @see java.lang.Object#clone()
@@ -67,13 +93,6 @@
     }
 
     /**
-     * @see com.metamatrix.query.processor.ProcessorPlan#connectTupleSource(com.metamatrix.common.buffer.TupleSource, com.metamatrix.common.buffer.TupleSourceID)
-     */
-    public void connectTupleSource(TupleSource source, int dataRequestID) {
-        // nothing
-    }
-
-    /**
      * @see com.metamatrix.query.processor.ProcessorPlan#getOutputElements()
      */
     public List getOutputElements() {
@@ -84,7 +103,8 @@
      * @see com.metamatrix.query.processor.ProcessorPlan#open()
      */
     public void open() throws MetaMatrixComponentException {
-        // nothing
+    	assertFalse("ProcessorPlan.open() should not be called more than once", opened); //$NON-NLS-1$
+        opened = true;
     }
 
     /**
@@ -122,14 +142,6 @@
         return this.outputElements;
     }
 
-    /* (non-Javadoc)
-     * @see com.metamatrix.query.processor.ProcessorPlan#getUpdateCount()
-     */
-    public int getUpdateCount() {
-        // TODO Auto-generated method stub
-        return 0;
-    }
-
     public Map getDescriptionProperties() {
         return new HashMap();
     }

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestBaseProcessorPlan.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestBaseProcessorPlan.java	2009-12-23 16:39:47 UTC (rev 1700)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestBaseProcessorPlan.java	2009-12-23 16:52:32 UTC (rev 1701)
@@ -22,20 +22,12 @@
 
 package com.metamatrix.query.processor;
 
-import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import junit.framework.TestCase;
 
-import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.query.util.CommandContext;
 
 public class TestBaseProcessorPlan extends TestCase {
 
@@ -44,7 +36,7 @@
     }
 
     public void testGetAndClearWarnings() {        
-        FakeProcessorPlan plan = new FakeProcessorPlan();
+        FakeProcessorPlan plan = new FakeProcessorPlan(Collections.emptyList(), Collections.emptyList());
         MetaMatrixException warning = new MetaMatrixException("test"); //$NON-NLS-1$
         plan.addWarning(warning);
         
@@ -53,64 +45,4 @@
         assertEquals("Did not get expected warning", warning, warnings.get(0)); //$NON-NLS-1$
         assertNull("Did not clear warnings from plan", plan.getAndClearWarnings());         //$NON-NLS-1$
     }
-
-    private static class FakeProcessorPlan extends ProcessorPlan {
-            
-        
-            /**
-         * @see java.lang.Object#clone()
-         */
-        public FakeProcessorPlan clone() {
-            return null;
-        }
-
-        /**
-         * @see com.metamatrix.query.processor.ProcessorPlan#close()
-         */
-        public void close() throws MetaMatrixComponentException {
-        }
-
-        /**
-         * @see com.metamatrix.query.processor.ProcessorPlan#getOutputElements()
-         */
-        public List getOutputElements() {
-            return null;
-        }
-
-        /**
-         * @see com.metamatrix.query.processor.ProcessorPlan#initialize(com.metamatrix.query.processor.ProcessorDataManager, java.lang.Object, com.metamatrix.common.buffer.BufferManager, java.lang.String, int)
-         */
-        public void initialize(
-            CommandContext context,
-            ProcessorDataManager dataMgr,
-            BufferManager bufferMgr) {
-        }
-
-        /**
-         * @see com.metamatrix.query.processor.ProcessorPlan#nextBatch()
-         */
-        public TupleBatch nextBatch() throws BlockedException, MetaMatrixComponentException {
-            return null;
-        }
-
-        /**
-         * @see com.metamatrix.query.processor.ProcessorPlan#open()
-         */
-        public void open() throws MetaMatrixComponentException {
-        }
-
-        public Map getDescriptionProperties() {
-            return new HashMap();
-        }
-        
-        /** 
-         * @see com.metamatrix.query.processor.ProcessorPlan#getChildPlans()
-         * @since 4.2
-         */
-        public Collection getChildPlans() {
-            return Collections.EMPTY_LIST;
-        }
-        
-
-    }
 }



More information about the teiid-commits mailing list