incubator-imperius-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke...@apache.org
Subject svn commit: r611261 [38/43] - in /incubator/imperius/trunk: ./ imperius-javaspl/ imperius-javaspl/src/main/java/org/apache/imperius/javaspl/ imperius-splcore/ imperius-splcore/src/main/antlr/org/apache/imperius/spl/parser/compiler/ imperius-splcore/src...
Date Fri, 11 Jan 2008 18:57:14 GMT
Modified: incubator/imperius/trunk/imperius-splcore/src/test/java/org/apache/imperius/spl/tests/CollectionExpressionsTest.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/test/java/org/apache/imperius/spl/tests/CollectionExpressionsTest.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/test/java/org/apache/imperius/spl/tests/CollectionExpressionsTest.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/test/java/org/apache/imperius/spl/tests/CollectionExpressionsTest.java Fri Jan 11 10:56:30 2008
@@ -1,955 +1,955 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Prashant Baliga <prabalig@in.ibm.com>
- *
- */
-
-package org.apache.imperius.spl.tests;
-
-import java.util.List;
-import java.util.Vector;
-
-import org.apache.imperius.spl.external.Expression;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expression.primary.BasicCollectionExpression;
-import org.apache.imperius.spl.parser.expressions.impl.AllInCollection;
-import org.apache.imperius.spl.parser.expressions.impl.AnyInCollection;
-import org.apache.imperius.spl.parser.expressions.impl.ApplyToCollection;
-import org.apache.imperius.spl.parser.expressions.impl.AvrgInCollection;
-import org.apache.imperius.spl.parser.expressions.impl.BooleanConstant;
-import org.apache.imperius.spl.parser.expressions.impl.ByteConstant;
-import org.apache.imperius.spl.parser.expressions.impl.CollectionSize;
-import org.apache.imperius.spl.parser.expressions.impl.EqCollections;
-import org.apache.imperius.spl.parser.expressions.impl.FloatConstant;
-import org.apache.imperius.spl.parser.expressions.impl.InCollection;
-import org.apache.imperius.spl.parser.expressions.impl.MaxInCollection;
-import org.apache.imperius.spl.parser.expressions.impl.MedianInCollection;
-import org.apache.imperius.spl.parser.expressions.impl.MinInCollection;
-import org.apache.imperius.spl.parser.expressions.impl.SdInCollection;
-import org.apache.imperius.spl.parser.expressions.impl.StringConstant;
-import org.apache.imperius.spl.parser.expressions.impl.SubCollection;
-import org.apache.imperius.spl.parser.expressions.impl.Sum;
-import org.apache.imperius.spl.parser.expressions.impl.Union;
-
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-
-
-
-public class CollectionExpressionsTest  extends TestCase 
-{
-	
-    static final String CMVC_ID_NumericExpressionTest = "$Header: /cvsroot/cimsplpegasus/trunk/modules/imperius-splcore/src/com/ibm/ac/spl/tests/CollectionExpressionsTest.java,v 1.2 2007/12/20 13:07:37 prabalig Exp $";
-    static final String VERSION_NumericExpressionTest = "File version $Revision: 1.2 $, last changed $Date: 2007/12/20 13:07:37 $";
-//    private static Logger logger = SPLLogger.getCIMSPLLogger().getLogger();
-	
-    
-    static Expression propertySensor1 =null;
-    //new ConstantExpression("propertySensor1");
-static Expression propertySensor2 =null;
-    //new PropertySensor("propertySensor2");
-static  Expression propertySensor3 =null;
-    //new PropertySensor("propertySensor3");
-static  Expression propertySensor4 =null;
-    //new PropertySensor("propertySensor4");
-static  Expression propertySensor5 =null;
-    //new PropertySensor("propertySensor5");
-static  Expression propertySensor6 =null;
-    //new PropertySensor("propertySensor6");
-static  Expression propertySensor7 =null;
-    //new PropertySensor("propertySensor7");
-static  Expression propertySensor8 =null;
-    //new PropertySensor("propertySensor8");
-static  Expression propertySensor9 =null;
-    //new PropertySensor("propertySensor9");
-static  Expression propertySensor10 =null;
-    //new PropertySensor("propertySensor10");
-    public CollectionExpressionsTest(String arg0) {
-        super(arg0);
-    }
-
-    public static Test suite() {
-        TestSuite suite = new TestSuite(CollectionExpressionsTest.class);
-        TestSetup wrapper = new TestSetup(suite) {
-
-            protected void setUp() throws Exception {
-                oneTimeSetUp();
-            }
-
-            protected void tearDown() throws Exception {
-                oneTimeTearDown();
-            }
-        };
-        return wrapper;
-    }
-
-    public static void main(String[] args) {
-        junit.textui.TestRunner.run(suite());
-    }
-
-    protected static void oneTimeSetUp() throws Exception {
-    }
-
-    protected static void oneTimeTearDown() throws Exception {
-
-    }
-
-    public void testAllInCollection() {
-    	propertySensor1 = new ByteConstant((byte)1);
-    	propertySensor2 = new ByteConstant((byte)2);
-    	propertySensor3 = new ByteConstant((byte)3);
-    	propertySensor4 = new ByteConstant((byte)4);
-    	propertySensor5 = new ByteConstant((byte)5);
-    	propertySensor6 = new ByteConstant((byte)6);
-    	propertySensor7 = new ByteConstant((byte)7);
-    	propertySensor8 = new ByteConstant((byte)8);
-    	
-    	StringConstant stringLOR = new StringConstant("\"OR\"");
-    	StringConstant stringLAND = new StringConstant("\"AND\"");
-    	StringConstant stringBXOR = new StringConstant("\"XOR\"");
-    	StringConstant stringNOT_EQUAL = new StringConstant("\"NOT_EQUAL\"");
-    	StringConstant stringEQUAL = new StringConstant("\"EQUAL\"");
-    	StringConstant stringLT = new StringConstant("\"LESS\"");
-    	StringConstant stringGT = new StringConstant("\"GREATER\"");
-    	StringConstant stringLE = new StringConstant("\"LESS_OR_EQUAL\"");
-    	StringConstant stringGE = new StringConstant("\"GREATER_OR_EQUAL\"");
-    	
-    	
-		
-		
-    	
-        try {
-            Vector v = new Vector();
-            Vector vbytes = new Vector();
-            
-            vbytes.add(propertySensor1);
-            vbytes.add(propertySensor2);
-            vbytes.add(propertySensor3);
-            vbytes.add(propertySensor4);
-            vbytes.add(propertySensor5);
-            vbytes.add(propertySensor6);
-            vbytes.add(propertySensor7);
-            vbytes.add(propertySensor8);
-            
-            Expression collection = new BasicCollectionExpression(vbytes,null);
-            
-            v.add(new ByteConstant((byte)0));
-            v.add(stringGT);
-            v.add(collection);
-            Expression es1 = new AllInCollection(v,true);
-            v.clear();
-            
-            v.add(new ByteConstant((byte)10));
-            v.add(stringLT);
-            v.add(collection);
-            Expression es2 = new AllInCollection(v,true);
-            v.clear();
-            
-            v.add(new ByteConstant((byte)8));
-            v.add(stringLE);
-            v.add(collection);
-            Expression es3 = new AllInCollection(v,true);
-            v.clear();
-            
-            v.add(new ByteConstant((byte)1));
-            v.add(stringGE);
-            v.add(collection);
-            Expression es4 = new AllInCollection(v,true);
-            v.clear();
-            
-            
-
-
-            assertTrue(((Boolean)es1.evaluate()).booleanValue());
-            assertTrue(((Boolean)es2.evaluate()).booleanValue());
-            assertTrue(((Boolean)es3.evaluate()).booleanValue());
-            assertTrue(((Boolean)es4.evaluate()).booleanValue());
-            
-            
-            
-            propertySensor1 = new BooleanConstant(true);
-        	propertySensor2 = new BooleanConstant(true);
-        	propertySensor3 = new BooleanConstant(true);
-        	propertySensor4 = new BooleanConstant(true);
-        	
-        	
-        	vbytes.clear();
-        	
-        	vbytes.add(propertySensor1);
-            vbytes.add(propertySensor2);
-            vbytes.add(propertySensor3);
-            vbytes.add(propertySensor4);
-            
-            
-            collection = new BasicCollectionExpression(vbytes,null);
-            
-            v.add(new BooleanConstant(false));
-            v.add(stringLOR);
-            v.add(collection);
-            Expression es5 = new AllInCollection(v,true);
-            v.clear();
-            
-            v.add(new BooleanConstant(true));
-            v.add(stringLAND);
-            v.add(collection);
-            Expression es6 = new AllInCollection(v,true);
-            v.clear();
-            
-            v.add(new BooleanConstant(false));
-            v.add(stringBXOR);
-            v.add(collection);
-            Expression es7 = new AllInCollection(v,true);
-            v.clear();
-            
-            v.add(new BooleanConstant(false));
-            v.add(stringNOT_EQUAL);
-            v.add(collection);
-            Expression es8 = new AllInCollection(v,true);
-            v.clear();
-            
-            v.add(new BooleanConstant(true));
-            v.add(stringEQUAL);
-            v.add(collection);
-            Expression es9 = new AllInCollection(v,true);
-            v.clear();
-            
-            
-
-
-            assertTrue(((Boolean)es5.evaluate()).booleanValue());
-            assertTrue(((Boolean)es6.evaluate()).booleanValue());
-            assertTrue(((Boolean)es7.evaluate()).booleanValue());
-            assertTrue(((Boolean)es8.evaluate()).booleanValue());
-            assertTrue(((Boolean)es9.evaluate()).booleanValue());
-            
-            
-            
-            
-        } catch (SPLException e) {
-        	e.printStackTrace();
-            fail("Received evaluation exception " + e.getMessage());
-        } catch (Exception e) {
-        	e.printStackTrace();
-            fail("Received expression exception " + e.getMessage());
-        }
-    }
-    
-    public void testAnyInCollection() {
-    	propertySensor1 = new ByteConstant((byte)1);
-    	propertySensor2 = new ByteConstant((byte)2);
-    	propertySensor3 = new ByteConstant((byte)3);
-    	propertySensor4 = new ByteConstant((byte)4);
-    	propertySensor5 = new ByteConstant((byte)5);
-    	propertySensor6 = new ByteConstant((byte)6);
-    	propertySensor7 = new ByteConstant((byte)7);
-    	propertySensor8 = new ByteConstant((byte)8);
-    	
-    	StringConstant stringLOR = new StringConstant("\"OR\"");
-    	StringConstant stringLAND = new StringConstant("\"AND\"");
-    	StringConstant stringBXOR = new StringConstant("\"XOR\"");
-    	StringConstant stringNOT_EQUAL = new StringConstant("\"NOT_EQUAL\"");
-    	StringConstant stringEQUAL = new StringConstant("\"EQUAL\"");
-    	StringConstant stringLT = new StringConstant("\"LESS\"");
-    	StringConstant stringGT = new StringConstant("\"GREATER\"");
-    	StringConstant stringLE = new StringConstant("\"LESS_OR_EQUAL\"");
-    	StringConstant stringGE = new StringConstant("\"GREATER_OR_EQUAL\"");
-    	
-		
-
-		
-		
-    	
-        try {
-            Vector v = new Vector();
-            Vector vbytes = new Vector();
-            
-            vbytes.add(propertySensor1);
-            vbytes.add(propertySensor2);
-            vbytes.add(propertySensor3);
-            vbytes.add(propertySensor4);
-            vbytes.add(propertySensor5);
-            vbytes.add(propertySensor6);
-            vbytes.add(propertySensor7);
-            vbytes.add(propertySensor8);
-            
-            Expression collection = new BasicCollectionExpression(vbytes,null);
-            
-            v.add(new ByteConstant((byte)6));
-            v.add(stringGT);
-            v.add(collection);
-            Expression es1 = new AnyInCollection(v,true);
-            v.clear();
-            
-            v.add(new ByteConstant((byte)2));
-            v.add(stringLT);
-            v.add(collection);
-            Expression es2 = new AnyInCollection(v,true);
-            v.clear();
-            
-            v.add(new ByteConstant((byte)3));
-            v.add(stringLE);
-            v.add(collection);
-            Expression es3 = new AnyInCollection(v,true);
-            v.clear();
-            
-            v.add(new ByteConstant((byte)4));
-            v.add(stringGE);
-            v.add(collection);
-            Expression es4 = new AnyInCollection(v,true);
-            v.clear();
-            
-            
-
-
-            assertTrue(((Boolean)es1.evaluate()).booleanValue());
-            assertTrue(((Boolean)es2.evaluate()).booleanValue());
-            assertTrue(((Boolean)es3.evaluate()).booleanValue());
-            assertTrue(((Boolean)es4.evaluate()).booleanValue());
-            
-            
-            
-            propertySensor1 = new BooleanConstant(true);
-        	propertySensor2 = new BooleanConstant(true);
-        	propertySensor3 = new BooleanConstant(true);
-        	propertySensor4 = new BooleanConstant(true);
-        	
-        	
-        	vbytes.clear();
-        	
-        	vbytes.add(propertySensor1);
-            vbytes.add(propertySensor2);
-            vbytes.add(propertySensor3);
-            vbytes.add(propertySensor4);
-            
-            
-            collection = new BasicCollectionExpression(vbytes,null);
-            
-            v.add(new BooleanConstant(false));
-            v.add(stringLOR);
-            v.add(collection);
-            Expression es5 = new AnyInCollection(v,true);
-            v.clear();
-            
-            v.add(new BooleanConstant(true));
-            v.add(stringLAND);
-            v.add(collection);
-            Expression es6 = new AnyInCollection(v,true);
-            v.clear();
-            
-            v.add(new BooleanConstant(false));
-            v.add(stringBXOR);
-            v.add(collection);
-            Expression es7 = new AnyInCollection(v,true);
-            v.clear();
-            
-            v.add(new BooleanConstant(false));
-            v.add(stringNOT_EQUAL);
-            v.add(collection);
-            Expression es8 = new AnyInCollection(v,true);
-            v.clear();
-            
-            v.add(new BooleanConstant(true));
-            v.add(stringEQUAL);
-            v.add(collection);
-            Expression es9 = new AnyInCollection(v,true);
-            v.clear();
-            
-            
-
-
-            assertTrue(((Boolean)es5.evaluate()).booleanValue());
-            assertTrue(((Boolean)es6.evaluate()).booleanValue());
-            assertTrue(((Boolean)es7.evaluate()).booleanValue());
-            assertTrue(((Boolean)es8.evaluate()).booleanValue());
-            assertTrue(((Boolean)es9.evaluate()).booleanValue());
-            
-            
-            
-            
-        } catch (SPLException e) {
-            fail("Received evaluation exception " + e.getMessage());
-        } catch (Exception e) {
-            fail("Received expression exception " + e.getMessage());
-        }
-    }
-    
-    public void testApplyToCollection() {
-    	propertySensor8 = new ByteConstant((byte)8);
-    	
-    	StringConstant stringPLUS = new StringConstant("\"PLUS\"");
-    	StringConstant stringMINUS = new StringConstant("\"MINUS\"");
-    	StringConstant stringSTAR = new StringConstant("\"MULTIPLY\"");
-    	StringConstant stringDIV = new StringConstant("\"DIVIDE\"");
-		
-
-		
-		
-    	
-        try {
-            Vector v = new Vector();
-            Vector vbytes = new Vector();
-            
-            vbytes.add(propertySensor8);
-            vbytes.add(propertySensor8);
-            vbytes.add(propertySensor8);
-            vbytes.add(propertySensor8);
-            
-            
-            Expression collection = new BasicCollectionExpression(vbytes,null);
-            
-            v.add(new ByteConstant((byte)10));
-            v.add(stringPLUS);
-            v.add(collection);
-            Expression es1 = new ApplyToCollection(v,true);
-            v.clear();
-            
-            v.add(new ByteConstant((byte)4));
-            v.add(stringMINUS);
-            v.add(collection);
-            Expression es2 = new ApplyToCollection(v,true);
-            v.clear();
-            
-            v.add(new ByteConstant((byte)2));
-            v.add(stringSTAR);
-            v.add(collection);
-            Expression es3 = new ApplyToCollection(v,true);
-            v.clear();
-            
-            v.add(new ByteConstant((byte)2));
-            v.add(stringDIV);
-            v.add(collection);
-            Expression es4 = new ApplyToCollection(v,true);
-            v.clear();
-            
-            List resultarr1=(List)es1.evaluate();
-            for(int i=0;i<resultarr1.size();i++){
-            	//System.out.println(((Number)resultarr1.get(i)).intValue());
-            	assertTrue(((Number)resultarr1.get(i)).intValue()==18);
-
-            }
-            
-            List resultarr2=(List)es2.evaluate();
-            for(int i=0;i<resultarr2.size();i++){
-            	//System.out.println(((Number)resultarr2.get(i)).intValue());
-            	assertTrue(((Number)resultarr2.get(i)).intValue()==4);
-
-            }
-            
-            List resultarr3=(List)es3.evaluate();
-            for(int i=0;i<resultarr3.size();i++){
-            	//System.out.println(((Number)resultarr3.get(i)).intValue());
-            	assertTrue(((Number)resultarr3.get(i)).intValue()==16);
-
-            }
-            
-            List resultarr4=(List)es4.evaluate();
-            for(int i=0;i<resultarr4.size();i++){
-            	//System.out.println(((Number)resultarr4.get(i)).intValue());
-            	assertTrue(((Number)resultarr4.get(i)).intValue()==4);
-
-            }
-            
-            
-        } catch (SPLException e) {
-        	e.printStackTrace();
-            fail("Received evaluation exception " + e.getMessage());
-        } catch (Exception e) {
-        	e.printStackTrace();
-            fail("Received expression exception " + e.getMessage());
-        }
-    }
-    
-    public void testAvrgInCollection() {
-    	propertySensor1 = new FloatConstant((float)1.11);
-    	propertySensor2 = new FloatConstant((float)2.22);
-    	propertySensor3 = new FloatConstant((float)3.33);
-    	propertySensor4 = new FloatConstant((float)4.44);
-    	propertySensor5 = new FloatConstant((float)-5.55);
-    	propertySensor6 = new FloatConstant((float)-6.66);
-    	propertySensor7 = new FloatConstant((float)-7.77);
-    	propertySensor8 = new FloatConstant((float)88.44);
-    	
-    	
-    	
-        try {
-            Vector v = new Vector();
-            Vector vbytes = new Vector();
-            
-            vbytes.add(propertySensor1);
-            vbytes.add(propertySensor2);
-            vbytes.add(propertySensor3);
-            vbytes.add(propertySensor4);
-            vbytes.add(propertySensor5);
-            vbytes.add(propertySensor6);
-            vbytes.add(propertySensor7);
-            vbytes.add(propertySensor8);
-            
-            
-            Expression collection = new BasicCollectionExpression(vbytes,null);
-            
-            v.add(collection);
-            Expression es1 = new AvrgInCollection(v,true);
-            v.clear();
-            double n=((Number)es1.evaluate()).doubleValue();
-           //System.out.println(n);
-            assertTrue(n>9.94 && n<9.95);
-
-            
-        } catch (SPLException e) {
-            fail("Received evaluation exception " + e.getMessage());
-        } catch (Exception e) {
-            fail("Received expression exception " + e.getMessage());
-        }
-    }
-    
-    public void testEqCollection() {
-    	propertySensor1 = new FloatConstant((float)1.11);
-    	propertySensor2 = new FloatConstant((float)2.22);
-    	propertySensor3 = new FloatConstant((float)3.33);
-    	propertySensor4 = new FloatConstant((float)4.44);
-    	propertySensor5 = new FloatConstant((float)-5.55);
-    	propertySensor6 = new FloatConstant((float)-6.66);
-    	propertySensor7 = new FloatConstant((float)-7.77);
-    	propertySensor8 = new FloatConstant((float)88.44);
-    	
-    	
-    	
-        try {
-            Vector v = new Vector();
-            Vector vbytes = new Vector();
-            
-            vbytes.add(propertySensor1);
-            vbytes.add(propertySensor2);
-            vbytes.add(propertySensor3);
-            vbytes.add(propertySensor4);
-            vbytes.add(propertySensor5);
-            vbytes.add(propertySensor6);
-            vbytes.add(propertySensor7);
-            vbytes.add(propertySensor8);
-            
-            
-            Expression collection = new BasicCollectionExpression(vbytes,null);
-            Expression collection1 = new BasicCollectionExpression(vbytes,null);
-            
-            v.add(collection);
-            v.add(collection1);
-            Expression es1 = new EqCollections(v,true);
-            v.clear();
-            assertTrue(((Boolean)es1.evaluate()).booleanValue());
-
-            
-        } catch (SPLException e) {
-            fail("Received evaluation exception " + e.getMessage());
-        } catch (Exception e) {
-            fail("Received expression exception " + e.getMessage());
-        }
-    }
-    
-    public void testMaxInCollection() {
-    	propertySensor1 = new FloatConstant((float)1.11);
-    	propertySensor2 = new FloatConstant((float)2.22);
-    	propertySensor3 = new FloatConstant((float)3.33);
-    	propertySensor4 = new FloatConstant((float)4.44);
-    	propertySensor5 = new FloatConstant((float)-5.55);
-    	propertySensor6 = new FloatConstant((float)-6.66);
-    	propertySensor7 = new FloatConstant((float)-7.77);
-    	propertySensor8 = new FloatConstant((float)88.44);
-    	
-    	
-    	
-        try {
-            Vector v = new Vector();
-            Vector vbytes = new Vector();
-            
-            vbytes.add(propertySensor1);
-            vbytes.add(propertySensor2);
-            vbytes.add(propertySensor3);
-            vbytes.add(propertySensor4);
-            vbytes.add(propertySensor5);
-            vbytes.add(propertySensor6);
-            vbytes.add(propertySensor7);
-            vbytes.add(propertySensor8);
-            
-            
-            Expression collection = new BasicCollectionExpression(vbytes,null);
-            
-            v.add(collection);
-            Expression es1 = new MaxInCollection(v,true);
-            v.clear();
-            assertTrue(((Number)es1.evaluate()).floatValue()==(float)88.44);
-
-            
-        } catch (SPLException e) {
-            fail("Received evaluation exception " + e.getMessage());
-        } catch (Exception e) {
-            fail("Received expression exception " + e.getMessage());
-        }
-    }
-    
-    public void testMinInCollection() {
-    	propertySensor1 = new FloatConstant((float)1.11);
-    	propertySensor2 = new FloatConstant((float)2.22);
-    	propertySensor3 = new FloatConstant((float)3.33);
-    	propertySensor4 = new FloatConstant((float)4.44);
-    	propertySensor5 = new FloatConstant((float)-5.55);
-    	propertySensor6 = new FloatConstant((float)-6.66);
-    	propertySensor7 = new FloatConstant((float)-7.77);
-    	propertySensor8 = new FloatConstant((float)88.44);
-    	
-    	
-    	
-        try {
-            Vector v = new Vector();
-            Vector vbytes = new Vector();
-            
-            vbytes.add(propertySensor1);
-            vbytes.add(propertySensor2);
-            vbytes.add(propertySensor3);
-            vbytes.add(propertySensor4);
-            vbytes.add(propertySensor5);
-            vbytes.add(propertySensor6);
-            vbytes.add(propertySensor7);
-            vbytes.add(propertySensor8);
-            
-            
-            Expression collection = new BasicCollectionExpression(vbytes,null);
-            
-            v.add(collection);
-            Expression es1 = new MinInCollection(v,true);
-            v.clear();
-            assertTrue(((Number)es1.evaluate()).floatValue()==(float)-7.77);
-
-            
-        } catch (SPLException e) {
-            fail("Received evaluation exception " + e.getMessage());
-        } catch (Exception e) {
-            fail("Received expression exception " + e.getMessage());
-        }
-    }
-    
-    public void testSum() {
-    	propertySensor1 = new FloatConstant((float)1.11);
-    	propertySensor2 = new FloatConstant((float)2.22);
-    	propertySensor3 = new FloatConstant((float)3.33);
-    	propertySensor4 = new FloatConstant((float)4.44);
-    	propertySensor5 = new FloatConstant((float)-5.55);
-    	propertySensor6 = new FloatConstant((float)-6.66);
-    	propertySensor7 = new FloatConstant((float)-7.77);
-    	propertySensor8 = new FloatConstant((float)88.44);
-    	
-    	
-    	
-        try {
-            Vector v = new Vector();
-            Vector vbytes = new Vector();
-            
-            vbytes.add(propertySensor1);
-            vbytes.add(propertySensor2);
-            vbytes.add(propertySensor3);
-            vbytes.add(propertySensor4);
-            vbytes.add(propertySensor5);
-            vbytes.add(propertySensor6);
-            vbytes.add(propertySensor7);
-            vbytes.add(propertySensor8);
-            
-            
-            Expression collection = new BasicCollectionExpression(vbytes,null);
-            
-            v.add(collection);
-            Expression es1 = new Sum(v,true);
-            v.clear();
-            assertTrue(((Number)es1.evaluate()).floatValue()==(float)79.560005);
-
-            
-        } catch (SPLException e) {
-            fail("Received evaluation exception " + e.getMessage());
-        } catch (Exception e) {
-            fail("Received expression exception " + e.getMessage());
-        }
-    }
-    
-    public void testInCollection() {
-    	propertySensor1 = new FloatConstant((float)1.11);
-    	propertySensor2 = new FloatConstant((float)2.22);
-    	propertySensor3 = new FloatConstant((float)3.33);
-    	propertySensor4 = new FloatConstant((float)4.44);
-    	propertySensor5 = new FloatConstant((float)-5.55);
-    	propertySensor6 = new FloatConstant((float)-6.66);
-    	propertySensor7 = new FloatConstant((float)-7.77);
-    	propertySensor8 = new FloatConstant((float)88.44);
-    	
-    	
-    	
-        try {
-            Vector v = new Vector();
-            Vector vbytes = new Vector();
-            
-            vbytes.add(propertySensor1);
-            vbytes.add(propertySensor2);
-            vbytes.add(propertySensor3);
-            vbytes.add(propertySensor4);
-            vbytes.add(propertySensor5);
-            vbytes.add(propertySensor6);
-            vbytes.add(propertySensor7);
-            
-            
-            Expression collection = new BasicCollectionExpression(vbytes,null);
-            
-            v.add(propertySensor3);
-            v.add(collection);
-            Expression es1 = new InCollection(v,true);
-            v.clear();
-            assertTrue(((Boolean)es1.evaluate()).booleanValue());
-            
-            v.add(propertySensor8);
-            v.add(collection);
-            Expression es2 = new InCollection(v,true);
-            v.clear();
-            assertFalse(((Boolean)es2.evaluate()).booleanValue());
-
-            
-        } catch (SPLException e) {
-        	e.printStackTrace();
-            fail("Received evaluation exception " + e.getMessage());
-        } catch (Exception e) {
-        	e.printStackTrace();
-            
-            fail("Received expression exception " + e.getMessage());
-        }
-    }
-    
-    public void testSubCollection() {
-    	propertySensor1 = new FloatConstant((float)1.11);
-    	propertySensor2 = new FloatConstant((float)2.22);
-    	propertySensor3 = new FloatConstant((float)3.33);
-    	propertySensor4 = new FloatConstant((float)4.44);
-    	propertySensor5 = new FloatConstant((float)-5.55);
-    	propertySensor6 = new FloatConstant((float)-6.66);
-    	propertySensor7 = new FloatConstant((float)-7.77);
-    	propertySensor8 = new FloatConstant((float)88.44);
-    	
-    	
-    	
-        try {
-            Vector v = new Vector();
-            Vector vbytes = new Vector();
-            
-            vbytes.add(propertySensor1);
-            vbytes.add(propertySensor2);
-            vbytes.add(propertySensor3);
-            vbytes.add(propertySensor4);
-            Expression collection = new BasicCollectionExpression(vbytes,null);
-            
-            vbytes.add(propertySensor5);
-            vbytes.add(propertySensor6);
-            vbytes.add(propertySensor7);
-            vbytes.add(propertySensor8);
-            
-            
-            Expression collection1 = new BasicCollectionExpression(vbytes,null);
-            
-            v.add(collection);
-            v.add(collection1);
-            Expression es1 = new SubCollection(v,true);
-            v.clear();
-            assertTrue(((Boolean)es1.evaluate()).booleanValue());
-
-            
-        } catch (SPLException e) {
-        	e.printStackTrace();
-            fail("Received evaluation exception " + e.getMessage());
-        } catch (Exception e) {
-        	e.printStackTrace();
-            fail("Received expression exception " + e.getMessage());
-        }
-    }
-    
-    public void testUnion() {
-    	propertySensor1 = new FloatConstant((float)1.11);
-    	propertySensor2 = new FloatConstant((float)2.22);
-    	propertySensor3 = new FloatConstant((float)3.33);
-    	propertySensor4 = new FloatConstant((float)4.44);
-    	propertySensor5 = new FloatConstant((float)-5.55);
-    	propertySensor6 = new FloatConstant((float)-6.66);
-    	propertySensor7 = new FloatConstant((float)-7.77);
-    	propertySensor8 = new FloatConstant((float)88.44);
-    	
-    	
-    	
-        try {
-            Vector v = new Vector();
-            Vector vbytes = new Vector();
-            Vector vbytes1 = new Vector();
-            
-            
-            vbytes.add(propertySensor1);
-            vbytes.add(propertySensor2);
-            vbytes.add(propertySensor3);
-            vbytes.add(propertySensor4);
-            Expression collection = new BasicCollectionExpression(vbytes,null);
-            vbytes1.add(propertySensor5);
-            vbytes1.add(propertySensor6);
-            vbytes1.add(propertySensor7);
-            vbytes1.add(propertySensor8);
-            
-            
-            Expression collection1 = new BasicCollectionExpression(vbytes1,null);
-            
-            v.add(collection);
-            v.add(collection1);
-            Expression es1 = new Union(v,true);
-            v.clear();
-            List resultList=(List)es1.evaluate();
-//            System.out.println("list "+ resultList.toString());
-            assertTrue(((Number)resultList.get(0)).floatValue()==(float)1.11);
-            assertTrue(((Number)resultList.get(1)).floatValue()==(float)2.22);
-            assertTrue(((Number)resultList.get(2)).floatValue()==(float)3.33);
-            assertTrue(((Number)resultList.get(3)).floatValue()==(float)4.44);
-            assertTrue(((Number)resultList.get(4)).floatValue()==(float)-5.55);
-            assertTrue(((Number)resultList.get(5)).floatValue()==(float)-6.66);
-            assertTrue(((Number)resultList.get(6)).floatValue()==(float)-7.77);
-            assertTrue(((Number)resultList.get(7)).floatValue()==(float)88.44);
-            
-            
-        } catch (SPLException e) {
-        	e.printStackTrace();
-            fail("Received evaluation exception " + e.getMessage());
-        } catch (Exception e) {
-        	e.printStackTrace();
-            fail("Received expression exception " + e.getMessage());
-        }
-    }
-    
-    public void testCollectionSize() {
-    	propertySensor1 = new FloatConstant((float)1.11);
-    	propertySensor2 = new FloatConstant((float)2.22);
-    	propertySensor3 = new FloatConstant((float)3.33);
-    	propertySensor4 = new FloatConstant((float)4.44);
-    	propertySensor5 = new FloatConstant((float)-5.55);
-    	propertySensor6 = new FloatConstant((float)-6.66);
-    	propertySensor7 = new FloatConstant((float)-7.77);
-    	propertySensor8 = new FloatConstant((float)88.44);
-    	
-    	
-    	
-        try {
-            Vector v = new Vector();
-            Vector vbytes = new Vector();
-            
-            vbytes.add(propertySensor1);
-            vbytes.add(propertySensor2);
-            vbytes.add(propertySensor3);
-            vbytes.add(propertySensor4);
-            vbytes.add(propertySensor5);
-            vbytes.add(propertySensor6);
-            vbytes.add(propertySensor7);
-            
-            
-            Expression collection = new BasicCollectionExpression(vbytes,null);
-            
-            v.add(collection);
-            Expression es1 = new CollectionSize(v,true);
-            v.clear();
-            assertTrue(((Number)es1.evaluate()).intValue()==7);
-            
-            
-            
-        } catch (SPLException e) {
-            fail("Received evaluation exception " + e.getMessage());
-        } catch (Exception e) {
-            fail("Received expression exception " + e.getMessage());
-        }
-    }
-    
-    public void testMedianInCollection() {
-    	propertySensor1 = new FloatConstant((float)6);
-    	propertySensor2 = new FloatConstant((float)9.7);
-    	propertySensor3 = new FloatConstant((float)14.8);
-    	propertySensor4 = new FloatConstant((float)22.4);
-    	propertySensor5 = new FloatConstant((float)-9.8);
-    	
-    	
-    	
-        try {
-            Vector v = new Vector();
-            Vector vbytes = new Vector();
-            
-            vbytes.add(propertySensor1);
-            vbytes.add(propertySensor2);
-            vbytes.add(propertySensor3);
-            vbytes.add(propertySensor4);
-            vbytes.add(propertySensor5);
-             
-            
-            Expression collection = new BasicCollectionExpression(vbytes,null);
-            
-            v.add(collection);
-            Expression es1 = new MedianInCollection(v,true);
-            v.clear();
-            assertTrue(((Number)es1.evaluate()).floatValue()==(float)9.7);
-            
-            
-            
-        } catch (SPLException e) {
-            fail("Received evaluation exception " + e.getMessage());
-        } catch (Exception e) {
-            fail("Received expression exception " + e.getMessage());
-        }
-    }
-    
-    public void testSdInCollection() {
-    	propertySensor1 = new FloatConstant((float)2);
-    	propertySensor2 = new FloatConstant((float)4);
-    	propertySensor3 = new FloatConstant((float)1);
-    	propertySensor4 = new FloatConstant((float)6);
-    	propertySensor5 = new FloatConstant((float)7);
-    	
-    	
-    	
-        try {
-            Vector v = new Vector();
-            Vector vbytes = new Vector();
-            
-            vbytes.add(propertySensor1);
-            vbytes.add(propertySensor2);
-            vbytes.add(propertySensor3);
-            vbytes.add(propertySensor4);
-            vbytes.add(propertySensor5);
-             
-            
-            Expression collection = new BasicCollectionExpression(vbytes,null);
-            
-            v.add(collection);
-            Expression es1 = new SdInCollection(v,true);
-            v.clear();
-           //System.out.println(((Number)es1.evaluate()).floatValue());
-            assertTrue(((Number)es1.evaluate()).floatValue()==(float)2.2803508501982757e+000);
-            
-            
-            
-        } catch (SPLException e) {
-            fail("Received evaluation exception " + e.getMessage());
-        } catch (Exception e) {
-            fail("Received expression exception " + e.getMessage());
-        }
-    }
-}
-
-
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+
+package org.apache.imperius.spl.tests;
+
+import java.util.List;
+import java.util.Vector;
+
+import org.apache.imperius.spl.external.Expression;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expression.primary.BasicCollectionExpression;
+import org.apache.imperius.spl.parser.expressions.impl.AllInCollection;
+import org.apache.imperius.spl.parser.expressions.impl.AnyInCollection;
+import org.apache.imperius.spl.parser.expressions.impl.ApplyToCollection;
+import org.apache.imperius.spl.parser.expressions.impl.AvrgInCollection;
+import org.apache.imperius.spl.parser.expressions.impl.BooleanConstant;
+import org.apache.imperius.spl.parser.expressions.impl.ByteConstant;
+import org.apache.imperius.spl.parser.expressions.impl.CollectionSize;
+import org.apache.imperius.spl.parser.expressions.impl.EqCollections;
+import org.apache.imperius.spl.parser.expressions.impl.FloatConstant;
+import org.apache.imperius.spl.parser.expressions.impl.InCollection;
+import org.apache.imperius.spl.parser.expressions.impl.MaxInCollection;
+import org.apache.imperius.spl.parser.expressions.impl.MedianInCollection;
+import org.apache.imperius.spl.parser.expressions.impl.MinInCollection;
+import org.apache.imperius.spl.parser.expressions.impl.SdInCollection;
+import org.apache.imperius.spl.parser.expressions.impl.StringConstant;
+import org.apache.imperius.spl.parser.expressions.impl.SubCollection;
+import org.apache.imperius.spl.parser.expressions.impl.Sum;
+import org.apache.imperius.spl.parser.expressions.impl.Union;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+
+
+public class CollectionExpressionsTest  extends TestCase 
+{
+	
+    static final String CMVC_ID_NumericExpressionTest = "$Header: /cvsroot/cimsplpegasus/trunk/modules/imperius-splcore/src/com/ibm/ac/spl/tests/CollectionExpressionsTest.java,v 1.2 2007/12/20 13:07:37 prabalig Exp $";
+    static final String VERSION_NumericExpressionTest = "File version $Revision: 1.2 $, last changed $Date: 2007/12/20 13:07:37 $";
+//    private static Logger logger = SPLLogger.getCIMSPLLogger().getLogger();
+	
+    
+    static Expression propertySensor1 =null;
+    //new ConstantExpression("propertySensor1");
+static Expression propertySensor2 =null;
+    //new PropertySensor("propertySensor2");
+static  Expression propertySensor3 =null;
+    //new PropertySensor("propertySensor3");
+static  Expression propertySensor4 =null;
+    //new PropertySensor("propertySensor4");
+static  Expression propertySensor5 =null;
+    //new PropertySensor("propertySensor5");
+static  Expression propertySensor6 =null;
+    //new PropertySensor("propertySensor6");
+static  Expression propertySensor7 =null;
+    //new PropertySensor("propertySensor7");
+static  Expression propertySensor8 =null;
+    //new PropertySensor("propertySensor8");
+static  Expression propertySensor9 =null;
+    //new PropertySensor("propertySensor9");
+static  Expression propertySensor10 =null;
+    //new PropertySensor("propertySensor10");
+    public CollectionExpressionsTest(String arg0) {
+        super(arg0);
+    }
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite(CollectionExpressionsTest.class);
+        TestSetup wrapper = new TestSetup(suite) {
+
+            protected void setUp() throws Exception {
+                oneTimeSetUp();
+            }
+
+            protected void tearDown() throws Exception {
+                oneTimeTearDown();
+            }
+        };
+        return wrapper;
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(suite());
+    }
+
+    protected static void oneTimeSetUp() throws Exception {
+    }
+
+    protected static void oneTimeTearDown() throws Exception {
+
+    }
+
+    public void testAllInCollection() {
+    	propertySensor1 = new ByteConstant((byte)1);
+    	propertySensor2 = new ByteConstant((byte)2);
+    	propertySensor3 = new ByteConstant((byte)3);
+    	propertySensor4 = new ByteConstant((byte)4);
+    	propertySensor5 = new ByteConstant((byte)5);
+    	propertySensor6 = new ByteConstant((byte)6);
+    	propertySensor7 = new ByteConstant((byte)7);
+    	propertySensor8 = new ByteConstant((byte)8);
+    	
+    	StringConstant stringLOR = new StringConstant("\"OR\"");
+    	StringConstant stringLAND = new StringConstant("\"AND\"");
+    	StringConstant stringBXOR = new StringConstant("\"XOR\"");
+    	StringConstant stringNOT_EQUAL = new StringConstant("\"NOT_EQUAL\"");
+    	StringConstant stringEQUAL = new StringConstant("\"EQUAL\"");
+    	StringConstant stringLT = new StringConstant("\"LESS\"");
+    	StringConstant stringGT = new StringConstant("\"GREATER\"");
+    	StringConstant stringLE = new StringConstant("\"LESS_OR_EQUAL\"");
+    	StringConstant stringGE = new StringConstant("\"GREATER_OR_EQUAL\"");
+    	
+    	
+		
+		
+    	
+        try {
+            Vector v = new Vector();
+            Vector vbytes = new Vector();
+            
+            vbytes.add(propertySensor1);
+            vbytes.add(propertySensor2);
+            vbytes.add(propertySensor3);
+            vbytes.add(propertySensor4);
+            vbytes.add(propertySensor5);
+            vbytes.add(propertySensor6);
+            vbytes.add(propertySensor7);
+            vbytes.add(propertySensor8);
+            
+            Expression collection = new BasicCollectionExpression(vbytes,null);
+            
+            v.add(new ByteConstant((byte)0));
+            v.add(stringGT);
+            v.add(collection);
+            Expression es1 = new AllInCollection(v,true);
+            v.clear();
+            
+            v.add(new ByteConstant((byte)10));
+            v.add(stringLT);
+            v.add(collection);
+            Expression es2 = new AllInCollection(v,true);
+            v.clear();
+            
+            v.add(new ByteConstant((byte)8));
+            v.add(stringLE);
+            v.add(collection);
+            Expression es3 = new AllInCollection(v,true);
+            v.clear();
+            
+            v.add(new ByteConstant((byte)1));
+            v.add(stringGE);
+            v.add(collection);
+            Expression es4 = new AllInCollection(v,true);
+            v.clear();
+            
+            
+
+
+            assertTrue(((Boolean)es1.evaluate()).booleanValue());
+            assertTrue(((Boolean)es2.evaluate()).booleanValue());
+            assertTrue(((Boolean)es3.evaluate()).booleanValue());
+            assertTrue(((Boolean)es4.evaluate()).booleanValue());
+            
+            
+            
+            propertySensor1 = new BooleanConstant(true);
+        	propertySensor2 = new BooleanConstant(true);
+        	propertySensor3 = new BooleanConstant(true);
+        	propertySensor4 = new BooleanConstant(true);
+        	
+        	
+        	vbytes.clear();
+        	
+        	vbytes.add(propertySensor1);
+            vbytes.add(propertySensor2);
+            vbytes.add(propertySensor3);
+            vbytes.add(propertySensor4);
+            
+            
+            collection = new BasicCollectionExpression(vbytes,null);
+            
+            v.add(new BooleanConstant(false));
+            v.add(stringLOR);
+            v.add(collection);
+            Expression es5 = new AllInCollection(v,true);
+            v.clear();
+            
+            v.add(new BooleanConstant(true));
+            v.add(stringLAND);
+            v.add(collection);
+            Expression es6 = new AllInCollection(v,true);
+            v.clear();
+            
+            v.add(new BooleanConstant(false));
+            v.add(stringBXOR);
+            v.add(collection);
+            Expression es7 = new AllInCollection(v,true);
+            v.clear();
+            
+            v.add(new BooleanConstant(false));
+            v.add(stringNOT_EQUAL);
+            v.add(collection);
+            Expression es8 = new AllInCollection(v,true);
+            v.clear();
+            
+            v.add(new BooleanConstant(true));
+            v.add(stringEQUAL);
+            v.add(collection);
+            Expression es9 = new AllInCollection(v,true);
+            v.clear();
+            
+            
+
+
+            assertTrue(((Boolean)es5.evaluate()).booleanValue());
+            assertTrue(((Boolean)es6.evaluate()).booleanValue());
+            assertTrue(((Boolean)es7.evaluate()).booleanValue());
+            assertTrue(((Boolean)es8.evaluate()).booleanValue());
+            assertTrue(((Boolean)es9.evaluate()).booleanValue());
+            
+            
+            
+            
+        } catch (SPLException e) {
+        	e.printStackTrace();
+            fail("Received evaluation exception " + e.getMessage());
+        } catch (Exception e) {
+        	e.printStackTrace();
+            fail("Received expression exception " + e.getMessage());
+        }
+    }
+    
+    public void testAnyInCollection() {
+    	propertySensor1 = new ByteConstant((byte)1);
+    	propertySensor2 = new ByteConstant((byte)2);
+    	propertySensor3 = new ByteConstant((byte)3);
+    	propertySensor4 = new ByteConstant((byte)4);
+    	propertySensor5 = new ByteConstant((byte)5);
+    	propertySensor6 = new ByteConstant((byte)6);
+    	propertySensor7 = new ByteConstant((byte)7);
+    	propertySensor8 = new ByteConstant((byte)8);
+    	
+    	StringConstant stringLOR = new StringConstant("\"OR\"");
+    	StringConstant stringLAND = new StringConstant("\"AND\"");
+    	StringConstant stringBXOR = new StringConstant("\"XOR\"");
+    	StringConstant stringNOT_EQUAL = new StringConstant("\"NOT_EQUAL\"");
+    	StringConstant stringEQUAL = new StringConstant("\"EQUAL\"");
+    	StringConstant stringLT = new StringConstant("\"LESS\"");
+    	StringConstant stringGT = new StringConstant("\"GREATER\"");
+    	StringConstant stringLE = new StringConstant("\"LESS_OR_EQUAL\"");
+    	StringConstant stringGE = new StringConstant("\"GREATER_OR_EQUAL\"");
+    	
+		
+
+		
+		
+    	
+        try {
+            Vector v = new Vector();
+            Vector vbytes = new Vector();
+            
+            vbytes.add(propertySensor1);
+            vbytes.add(propertySensor2);
+            vbytes.add(propertySensor3);
+            vbytes.add(propertySensor4);
+            vbytes.add(propertySensor5);
+            vbytes.add(propertySensor6);
+            vbytes.add(propertySensor7);
+            vbytes.add(propertySensor8);
+            
+            Expression collection = new BasicCollectionExpression(vbytes,null);
+            
+            v.add(new ByteConstant((byte)6));
+            v.add(stringGT);
+            v.add(collection);
+            Expression es1 = new AnyInCollection(v,true);
+            v.clear();
+            
+            v.add(new ByteConstant((byte)2));
+            v.add(stringLT);
+            v.add(collection);
+            Expression es2 = new AnyInCollection(v,true);
+            v.clear();
+            
+            v.add(new ByteConstant((byte)3));
+            v.add(stringLE);
+            v.add(collection);
+            Expression es3 = new AnyInCollection(v,true);
+            v.clear();
+            
+            v.add(new ByteConstant((byte)4));
+            v.add(stringGE);
+            v.add(collection);
+            Expression es4 = new AnyInCollection(v,true);
+            v.clear();
+            
+            
+
+
+            assertTrue(((Boolean)es1.evaluate()).booleanValue());
+            assertTrue(((Boolean)es2.evaluate()).booleanValue());
+            assertTrue(((Boolean)es3.evaluate()).booleanValue());
+            assertTrue(((Boolean)es4.evaluate()).booleanValue());
+            
+            
+            
+            propertySensor1 = new BooleanConstant(true);
+        	propertySensor2 = new BooleanConstant(true);
+        	propertySensor3 = new BooleanConstant(true);
+        	propertySensor4 = new BooleanConstant(true);
+        	
+        	
+        	vbytes.clear();
+        	
+        	vbytes.add(propertySensor1);
+            vbytes.add(propertySensor2);
+            vbytes.add(propertySensor3);
+            vbytes.add(propertySensor4);
+            
+            
+            collection = new BasicCollectionExpression(vbytes,null);
+            
+            v.add(new BooleanConstant(false));
+            v.add(stringLOR);
+            v.add(collection);
+            Expression es5 = new AnyInCollection(v,true);
+            v.clear();
+            
+            v.add(new BooleanConstant(true));
+            v.add(stringLAND);
+            v.add(collection);
+            Expression es6 = new AnyInCollection(v,true);
+            v.clear();
+            
+            v.add(new BooleanConstant(false));
+            v.add(stringBXOR);
+            v.add(collection);
+            Expression es7 = new AnyInCollection(v,true);
+            v.clear();
+            
+            v.add(new BooleanConstant(false));
+            v.add(stringNOT_EQUAL);
+            v.add(collection);
+            Expression es8 = new AnyInCollection(v,true);
+            v.clear();
+            
+            v.add(new BooleanConstant(true));
+            v.add(stringEQUAL);
+            v.add(collection);
+            Expression es9 = new AnyInCollection(v,true);
+            v.clear();
+            
+            
+
+
+            assertTrue(((Boolean)es5.evaluate()).booleanValue());
+            assertTrue(((Boolean)es6.evaluate()).booleanValue());
+            assertTrue(((Boolean)es7.evaluate()).booleanValue());
+            assertTrue(((Boolean)es8.evaluate()).booleanValue());
+            assertTrue(((Boolean)es9.evaluate()).booleanValue());
+            
+            
+            
+            
+        } catch (SPLException e) {
+            fail("Received evaluation exception " + e.getMessage());
+        } catch (Exception e) {
+            fail("Received expression exception " + e.getMessage());
+        }
+    }
+    
+    public void testApplyToCollection() {
+    	propertySensor8 = new ByteConstant((byte)8);
+    	
+    	StringConstant stringPLUS = new StringConstant("\"PLUS\"");
+    	StringConstant stringMINUS = new StringConstant("\"MINUS\"");
+    	StringConstant stringSTAR = new StringConstant("\"MULTIPLY\"");
+    	StringConstant stringDIV = new StringConstant("\"DIVIDE\"");
+		
+
+		
+		
+    	
+        try {
+            Vector v = new Vector();
+            Vector vbytes = new Vector();
+            
+            vbytes.add(propertySensor8);
+            vbytes.add(propertySensor8);
+            vbytes.add(propertySensor8);
+            vbytes.add(propertySensor8);
+            
+            
+            Expression collection = new BasicCollectionExpression(vbytes,null);
+            
+            v.add(new ByteConstant((byte)10));
+            v.add(stringPLUS);
+            v.add(collection);
+            Expression es1 = new ApplyToCollection(v,true);
+            v.clear();
+            
+            v.add(new ByteConstant((byte)4));
+            v.add(stringMINUS);
+            v.add(collection);
+            Expression es2 = new ApplyToCollection(v,true);
+            v.clear();
+            
+            v.add(new ByteConstant((byte)2));
+            v.add(stringSTAR);
+            v.add(collection);
+            Expression es3 = new ApplyToCollection(v,true);
+            v.clear();
+            
+            v.add(new ByteConstant((byte)2));
+            v.add(stringDIV);
+            v.add(collection);
+            Expression es4 = new ApplyToCollection(v,true);
+            v.clear();
+            
+            List resultarr1=(List)es1.evaluate();
+            for(int i=0;i<resultarr1.size();i++){
+            	//System.out.println(((Number)resultarr1.get(i)).intValue());
+            	assertTrue(((Number)resultarr1.get(i)).intValue()==18);
+
+            }
+            
+            List resultarr2=(List)es2.evaluate();
+            for(int i=0;i<resultarr2.size();i++){
+            	//System.out.println(((Number)resultarr2.get(i)).intValue());
+            	assertTrue(((Number)resultarr2.get(i)).intValue()==4);
+
+            }
+            
+            List resultarr3=(List)es3.evaluate();
+            for(int i=0;i<resultarr3.size();i++){
+            	//System.out.println(((Number)resultarr3.get(i)).intValue());
+            	assertTrue(((Number)resultarr3.get(i)).intValue()==16);
+
+            }
+            
+            List resultarr4=(List)es4.evaluate();
+            for(int i=0;i<resultarr4.size();i++){
+            	//System.out.println(((Number)resultarr4.get(i)).intValue());
+            	assertTrue(((Number)resultarr4.get(i)).intValue()==4);
+
+            }
+            
+            
+        } catch (SPLException e) {
+        	e.printStackTrace();
+            fail("Received evaluation exception " + e.getMessage());
+        } catch (Exception e) {
+        	e.printStackTrace();
+            fail("Received expression exception " + e.getMessage());
+        }
+    }
+    
+    public void testAvrgInCollection() {
+    	propertySensor1 = new FloatConstant((float)1.11);
+    	propertySensor2 = new FloatConstant((float)2.22);
+    	propertySensor3 = new FloatConstant((float)3.33);
+    	propertySensor4 = new FloatConstant((float)4.44);
+    	propertySensor5 = new FloatConstant((float)-5.55);
+    	propertySensor6 = new FloatConstant((float)-6.66);
+    	propertySensor7 = new FloatConstant((float)-7.77);
+    	propertySensor8 = new FloatConstant((float)88.44);
+    	
+    	
+    	
+        try {
+            Vector v = new Vector();
+            Vector vbytes = new Vector();
+            
+            vbytes.add(propertySensor1);
+            vbytes.add(propertySensor2);
+            vbytes.add(propertySensor3);
+            vbytes.add(propertySensor4);
+            vbytes.add(propertySensor5);
+            vbytes.add(propertySensor6);
+            vbytes.add(propertySensor7);
+            vbytes.add(propertySensor8);
+            
+            
+            Expression collection = new BasicCollectionExpression(vbytes,null);
+            
+            v.add(collection);
+            Expression es1 = new AvrgInCollection(v,true);
+            v.clear();
+            double n=((Number)es1.evaluate()).doubleValue();
+           //System.out.println(n);
+            assertTrue(n>9.94 && n<9.95);
+
+            
+        } catch (SPLException e) {
+            fail("Received evaluation exception " + e.getMessage());
+        } catch (Exception e) {
+            fail("Received expression exception " + e.getMessage());
+        }
+    }
+    
+    public void testEqCollection() {
+    	propertySensor1 = new FloatConstant((float)1.11);
+    	propertySensor2 = new FloatConstant((float)2.22);
+    	propertySensor3 = new FloatConstant((float)3.33);
+    	propertySensor4 = new FloatConstant((float)4.44);
+    	propertySensor5 = new FloatConstant((float)-5.55);
+    	propertySensor6 = new FloatConstant((float)-6.66);
+    	propertySensor7 = new FloatConstant((float)-7.77);
+    	propertySensor8 = new FloatConstant((float)88.44);
+    	
+    	
+    	
+        try {
+            Vector v = new Vector();
+            Vector vbytes = new Vector();
+            
+            vbytes.add(propertySensor1);
+            vbytes.add(propertySensor2);
+            vbytes.add(propertySensor3);
+            vbytes.add(propertySensor4);
+            vbytes.add(propertySensor5);
+            vbytes.add(propertySensor6);
+            vbytes.add(propertySensor7);
+            vbytes.add(propertySensor8);
+            
+            
+            Expression collection = new BasicCollectionExpression(vbytes,null);
+            Expression collection1 = new BasicCollectionExpression(vbytes,null);
+            
+            v.add(collection);
+            v.add(collection1);
+            Expression es1 = new EqCollections(v,true);
+            v.clear();
+            assertTrue(((Boolean)es1.evaluate()).booleanValue());
+
+            
+        } catch (SPLException e) {
+            fail("Received evaluation exception " + e.getMessage());
+        } catch (Exception e) {
+            fail("Received expression exception " + e.getMessage());
+        }
+    }
+    
+    public void testMaxInCollection() {
+    	propertySensor1 = new FloatConstant((float)1.11);
+    	propertySensor2 = new FloatConstant((float)2.22);
+    	propertySensor3 = new FloatConstant((float)3.33);
+    	propertySensor4 = new FloatConstant((float)4.44);
+    	propertySensor5 = new FloatConstant((float)-5.55);
+    	propertySensor6 = new FloatConstant((float)-6.66);
+    	propertySensor7 = new FloatConstant((float)-7.77);
+    	propertySensor8 = new FloatConstant((float)88.44);
+    	
+    	
+    	
+        try {
+            Vector v = new Vector();
+            Vector vbytes = new Vector();
+            
+            vbytes.add(propertySensor1);
+            vbytes.add(propertySensor2);
+            vbytes.add(propertySensor3);
+            vbytes.add(propertySensor4);
+            vbytes.add(propertySensor5);
+            vbytes.add(propertySensor6);
+            vbytes.add(propertySensor7);
+            vbytes.add(propertySensor8);
+            
+            
+            Expression collection = new BasicCollectionExpression(vbytes,null);
+            
+            v.add(collection);
+            Expression es1 = new MaxInCollection(v,true);
+            v.clear();
+            assertTrue(((Number)es1.evaluate()).floatValue()==(float)88.44);
+
+            
+        } catch (SPLException e) {
+            fail("Received evaluation exception " + e.getMessage());
+        } catch (Exception e) {
+            fail("Received expression exception " + e.getMessage());
+        }
+    }
+    
+    public void testMinInCollection() {
+    	propertySensor1 = new FloatConstant((float)1.11);
+    	propertySensor2 = new FloatConstant((float)2.22);
+    	propertySensor3 = new FloatConstant((float)3.33);
+    	propertySensor4 = new FloatConstant((float)4.44);
+    	propertySensor5 = new FloatConstant((float)-5.55);
+    	propertySensor6 = new FloatConstant((float)-6.66);
+    	propertySensor7 = new FloatConstant((float)-7.77);
+    	propertySensor8 = new FloatConstant((float)88.44);
+    	
+    	
+    	
+        try {
+            Vector v = new Vector();
+            Vector vbytes = new Vector();
+            
+            vbytes.add(propertySensor1);
+            vbytes.add(propertySensor2);
+            vbytes.add(propertySensor3);
+            vbytes.add(propertySensor4);
+            vbytes.add(propertySensor5);
+            vbytes.add(propertySensor6);
+            vbytes.add(propertySensor7);
+            vbytes.add(propertySensor8);
+            
+            
+            Expression collection = new BasicCollectionExpression(vbytes,null);
+            
+            v.add(collection);
+            Expression es1 = new MinInCollection(v,true);
+            v.clear();
+            assertTrue(((Number)es1.evaluate()).floatValue()==(float)-7.77);
+
+            
+        } catch (SPLException e) {
+            fail("Received evaluation exception " + e.getMessage());
+        } catch (Exception e) {
+            fail("Received expression exception " + e.getMessage());
+        }
+    }
+    
+    public void testSum() {
+    	propertySensor1 = new FloatConstant((float)1.11);
+    	propertySensor2 = new FloatConstant((float)2.22);
+    	propertySensor3 = new FloatConstant((float)3.33);
+    	propertySensor4 = new FloatConstant((float)4.44);
+    	propertySensor5 = new FloatConstant((float)-5.55);
+    	propertySensor6 = new FloatConstant((float)-6.66);
+    	propertySensor7 = new FloatConstant((float)-7.77);
+    	propertySensor8 = new FloatConstant((float)88.44);
+    	
+    	
+    	
+        try {
+            Vector v = new Vector();
+            Vector vbytes = new Vector();
+            
+            vbytes.add(propertySensor1);
+            vbytes.add(propertySensor2);
+            vbytes.add(propertySensor3);
+            vbytes.add(propertySensor4);
+            vbytes.add(propertySensor5);
+            vbytes.add(propertySensor6);
+            vbytes.add(propertySensor7);
+            vbytes.add(propertySensor8);
+            
+            
+            Expression collection = new BasicCollectionExpression(vbytes,null);
+            
+            v.add(collection);
+            Expression es1 = new Sum(v,true);
+            v.clear();
+            assertTrue(((Number)es1.evaluate()).floatValue()==(float)79.560005);
+
+            
+        } catch (SPLException e) {
+            fail("Received evaluation exception " + e.getMessage());
+        } catch (Exception e) {
+            fail("Received expression exception " + e.getMessage());
+        }
+    }
+    
+    public void testInCollection() {
+    	propertySensor1 = new FloatConstant((float)1.11);
+    	propertySensor2 = new FloatConstant((float)2.22);
+    	propertySensor3 = new FloatConstant((float)3.33);
+    	propertySensor4 = new FloatConstant((float)4.44);
+    	propertySensor5 = new FloatConstant((float)-5.55);
+    	propertySensor6 = new FloatConstant((float)-6.66);
+    	propertySensor7 = new FloatConstant((float)-7.77);
+    	propertySensor8 = new FloatConstant((float)88.44);
+    	
+    	
+    	
+        try {
+            Vector v = new Vector();
+            Vector vbytes = new Vector();
+            
+            vbytes.add(propertySensor1);
+            vbytes.add(propertySensor2);
+            vbytes.add(propertySensor3);
+            vbytes.add(propertySensor4);
+            vbytes.add(propertySensor5);
+            vbytes.add(propertySensor6);
+            vbytes.add(propertySensor7);
+            
+            
+            Expression collection = new BasicCollectionExpression(vbytes,null);
+            
+            v.add(propertySensor3);
+            v.add(collection);
+            Expression es1 = new InCollection(v,true);
+            v.clear();
+            assertTrue(((Boolean)es1.evaluate()).booleanValue());
+            
+            v.add(propertySensor8);
+            v.add(collection);
+            Expression es2 = new InCollection(v,true);
+            v.clear();
+            assertFalse(((Boolean)es2.evaluate()).booleanValue());
+
+            
+        } catch (SPLException e) {
+        	e.printStackTrace();
+            fail("Received evaluation exception " + e.getMessage());
+        } catch (Exception e) {
+        	e.printStackTrace();
+            
+            fail("Received expression exception " + e.getMessage());
+        }
+    }
+    
+    public void testSubCollection() {
+    	propertySensor1 = new FloatConstant((float)1.11);
+    	propertySensor2 = new FloatConstant((float)2.22);
+    	propertySensor3 = new FloatConstant((float)3.33);
+    	propertySensor4 = new FloatConstant((float)4.44);
+    	propertySensor5 = new FloatConstant((float)-5.55);
+    	propertySensor6 = new FloatConstant((float)-6.66);
+    	propertySensor7 = new FloatConstant((float)-7.77);
+    	propertySensor8 = new FloatConstant((float)88.44);
+    	
+    	
+    	
+        try {
+            Vector v = new Vector();
+            Vector vbytes = new Vector();
+            
+            vbytes.add(propertySensor1);
+            vbytes.add(propertySensor2);
+            vbytes.add(propertySensor3);
+            vbytes.add(propertySensor4);
+            Expression collection = new BasicCollectionExpression(vbytes,null);
+            
+            vbytes.add(propertySensor5);
+            vbytes.add(propertySensor6);
+            vbytes.add(propertySensor7);
+            vbytes.add(propertySensor8);
+            
+            
+            Expression collection1 = new BasicCollectionExpression(vbytes,null);
+            
+            v.add(collection);
+            v.add(collection1);
+            Expression es1 = new SubCollection(v,true);
+            v.clear();
+            assertTrue(((Boolean)es1.evaluate()).booleanValue());
+
+            
+        } catch (SPLException e) {
+        	e.printStackTrace();
+            fail("Received evaluation exception " + e.getMessage());
+        } catch (Exception e) {
+        	e.printStackTrace();
+            fail("Received expression exception " + e.getMessage());
+        }
+    }
+    
+    public void testUnion() {
+    	propertySensor1 = new FloatConstant((float)1.11);
+    	propertySensor2 = new FloatConstant((float)2.22);
+    	propertySensor3 = new FloatConstant((float)3.33);
+    	propertySensor4 = new FloatConstant((float)4.44);
+    	propertySensor5 = new FloatConstant((float)-5.55);
+    	propertySensor6 = new FloatConstant((float)-6.66);
+    	propertySensor7 = new FloatConstant((float)-7.77);
+    	propertySensor8 = new FloatConstant((float)88.44);
+    	
+    	
+    	
+        try {
+            Vector v = new Vector();
+            Vector vbytes = new Vector();
+            Vector vbytes1 = new Vector();
+            
+            
+            vbytes.add(propertySensor1);
+            vbytes.add(propertySensor2);
+            vbytes.add(propertySensor3);
+            vbytes.add(propertySensor4);
+            Expression collection = new BasicCollectionExpression(vbytes,null);
+            vbytes1.add(propertySensor5);
+            vbytes1.add(propertySensor6);
+            vbytes1.add(propertySensor7);
+            vbytes1.add(propertySensor8);
+            
+            
+            Expression collection1 = new BasicCollectionExpression(vbytes1,null);
+            
+            v.add(collection);
+            v.add(collection1);
+            Expression es1 = new Union(v,true);
+            v.clear();
+            List resultList=(List)es1.evaluate();
+//            System.out.println("list "+ resultList.toString());
+            assertTrue(((Number)resultList.get(0)).floatValue()==(float)1.11);
+            assertTrue(((Number)resultList.get(1)).floatValue()==(float)2.22);
+            assertTrue(((Number)resultList.get(2)).floatValue()==(float)3.33);
+            assertTrue(((Number)resultList.get(3)).floatValue()==(float)4.44);
+            assertTrue(((Number)resultList.get(4)).floatValue()==(float)-5.55);
+            assertTrue(((Number)resultList.get(5)).floatValue()==(float)-6.66);
+            assertTrue(((Number)resultList.get(6)).floatValue()==(float)-7.77);
+            assertTrue(((Number)resultList.get(7)).floatValue()==(float)88.44);
+            
+            
+        } catch (SPLException e) {
+        	e.printStackTrace();
+            fail("Received evaluation exception " + e.getMessage());
+        } catch (Exception e) {
+        	e.printStackTrace();
+            fail("Received expression exception " + e.getMessage());
+        }
+    }
+    
+    public void testCollectionSize() {
+    	propertySensor1 = new FloatConstant((float)1.11);
+    	propertySensor2 = new FloatConstant((float)2.22);
+    	propertySensor3 = new FloatConstant((float)3.33);
+    	propertySensor4 = new FloatConstant((float)4.44);
+    	propertySensor5 = new FloatConstant((float)-5.55);
+    	propertySensor6 = new FloatConstant((float)-6.66);
+    	propertySensor7 = new FloatConstant((float)-7.77);
+    	propertySensor8 = new FloatConstant((float)88.44);
+    	
+    	
+    	
+        try {
+            Vector v = new Vector();
+            Vector vbytes = new Vector();
+            
+            vbytes.add(propertySensor1);
+            vbytes.add(propertySensor2);
+            vbytes.add(propertySensor3);
+            vbytes.add(propertySensor4);
+            vbytes.add(propertySensor5);
+            vbytes.add(propertySensor6);
+            vbytes.add(propertySensor7);
+            
+            
+            Expression collection = new BasicCollectionExpression(vbytes,null);
+            
+            v.add(collection);
+            Expression es1 = new CollectionSize(v,true);
+            v.clear();
+            assertTrue(((Number)es1.evaluate()).intValue()==7);
+            
+            
+            
+        } catch (SPLException e) {
+            fail("Received evaluation exception " + e.getMessage());
+        } catch (Exception e) {
+            fail("Received expression exception " + e.getMessage());
+        }
+    }
+    
+    public void testMedianInCollection() {
+    	propertySensor1 = new FloatConstant((float)6);
+    	propertySensor2 = new FloatConstant((float)9.7);
+    	propertySensor3 = new FloatConstant((float)14.8);
+    	propertySensor4 = new FloatConstant((float)22.4);
+    	propertySensor5 = new FloatConstant((float)-9.8);
+    	
+    	
+    	
+        try {
+            Vector v = new Vector();
+            Vector vbytes = new Vector();
+            
+            vbytes.add(propertySensor1);
+            vbytes.add(propertySensor2);
+            vbytes.add(propertySensor3);
+            vbytes.add(propertySensor4);
+            vbytes.add(propertySensor5);
+             
+            
+            Expression collection = new BasicCollectionExpression(vbytes,null);
+            
+            v.add(collection);
+            Expression es1 = new MedianInCollection(v,true);
+            v.clear();
+            assertTrue(((Number)es1.evaluate()).floatValue()==(float)9.7);
+            
+            
+            
+        } catch (SPLException e) {
+            fail("Received evaluation exception " + e.getMessage());
+        } catch (Exception e) {
+            fail("Received expression exception " + e.getMessage());
+        }
+    }
+    
+    public void testSdInCollection() {
+    	propertySensor1 = new FloatConstant((float)2);
+    	propertySensor2 = new FloatConstant((float)4);
+    	propertySensor3 = new FloatConstant((float)1);
+    	propertySensor4 = new FloatConstant((float)6);
+    	propertySensor5 = new FloatConstant((float)7);
+    	
+    	
+    	
+        try {
+            Vector v = new Vector();
+            Vector vbytes = new Vector();
+            
+            vbytes.add(propertySensor1);
+            vbytes.add(propertySensor2);
+            vbytes.add(propertySensor3);
+            vbytes.add(propertySensor4);
+            vbytes.add(propertySensor5);
+             
+            
+            Expression collection = new BasicCollectionExpression(vbytes,null);
+            
+            v.add(collection);
+            Expression es1 = new SdInCollection(v,true);
+            v.clear();
+           //System.out.println(((Number)es1.evaluate()).floatValue());
+            assertTrue(((Number)es1.evaluate()).floatValue()==(float)2.2803508501982757e+000);
+            
+            
+            
+        } catch (SPLException e) {
+            fail("Received evaluation exception " + e.getMessage());
+        } catch (Exception e) {
+            fail("Received expression exception " + e.getMessage());
+        }
+    }
+}
+
+

Propchange: incubator/imperius/trunk/imperius-splcore/src/test/java/org/apache/imperius/spl/tests/CollectionExpressionsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message