[teiid-commits] teiid SVN: r1055 - in trunk/engine/src: main/java/com/metamatrix/query/function and 3 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Tue Jun 16 13:20:38 EDT 2009


Author: shawkins
Date: 2009-06-16 13:20:38 -0400 (Tue, 16 Jun 2009)
New Revision: 1055

Modified:
   trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java
   trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java
   trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java
   trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java
   trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestCriteriaEvaluator.java
Log:
TEIID-670 TEIID-671 changed the equality logic to check for compareTo == 0, which ignores precision for bigdecimals.  also added bigdecimal function forms to system source for mod, atan2, and all of the "double" functions.

Modified: trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java	2009-06-16 15:31:54 UTC (rev 1054)
+++ trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java	2009-06-16 17:20:38 UTC (rev 1055)
@@ -207,9 +207,9 @@
 		// Compare two non-null values using specified operator
 		switch(criteria.getOperator()) {
 			case CompareCriteria.EQ:
-				return Boolean.valueOf(leftValue.equals(rightValue));
+				return Boolean.valueOf(compareValues(leftValue, rightValue) == 0);
 			case CompareCriteria.NE:
-				return Boolean.valueOf(! leftValue.equals(rightValue));
+				return Boolean.valueOf(compareValues(leftValue, rightValue) != 0);
 			case CompareCriteria.LT:
 				return Boolean.valueOf((compareValues(leftValue, rightValue) < 0));
 			case CompareCriteria.LE:

Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java	2009-06-16 15:31:54 UTC (rev 1054)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java	2009-06-16 17:20:38 UTC (rev 1055)
@@ -197,34 +197,34 @@
 
 	// ================== Function = ceiling =====================
 
-	public static Object ceiling(Double x) {
-		return new Double(Math.ceil(x));
+	public static Object ceiling(Number x) {
+		return new Double(Math.ceil(x.doubleValue()));
 	}
 
 	// ================== Function = exp =====================
 
-	public static Object exp(Double x) {
-		return new Double(Math.exp(x));
+	public static Object exp(Number x) {
+		return new Double(Math.exp(x.doubleValue()));
 	}
 
 	// ================== Function = floor =====================
 
-	public static  Object floor(Double x) {
+	public static  Object floor(Number x) {
 		return new Double(Math.floor(x.doubleValue()));
 	}
 
 	// ================== Function = log =====================
 
-	public static  Object log(Double x) {
-		return new Double(Math.log(x));
+	public static  Object log(Number x) {
+		return new Double(Math.log(x.doubleValue()));
 	}
 
 	// ================== Function = log10 =====================
 
 	private static final double log10baseE = Math.log(10);
 
-	public static Object log10(Double x) {
-		return new Double( Math.log(x) / log10baseE);
+	public static Object log10(Number x) {
+		return new Double( Math.log(x.doubleValue()) / log10baseE);
 	}
     
     // ================== Function = rand=====================
@@ -272,6 +272,10 @@
 			if(y instanceof BigInteger) {
 				return ((BigInteger)x).mod((BigInteger) y);
 			}
+		} else if(x instanceof BigDecimal) {
+			if(y instanceof BigDecimal) {
+				return ((BigDecimal)x).remainder((BigDecimal) y);
+			}
 		}
 
 		throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0007, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0007, new Object[]{"mod", x.getClass().getName(), y.getClass().getName()})); //$NON-NLS-1$
@@ -1263,37 +1267,37 @@
 	}
 
 	// ================== Function - ACOS =====================
-	public static Object acos(Double number) {
+	public static Object acos(Number number) {
 		return new Double(Math.acos(number.doubleValue()));
 	}
 
 	// ================== Function - ASIN =====================
-	public static Object asin(Double number) {
+	public static Object asin(Number number) {
 		return new Double(Math.asin(number.doubleValue()));
 	}
 
 	// ================== Function - ATAN =====================
-	public static Object atan(Double number) {
+	public static Object atan(Number number) {
 		return new Double(Math.atan(number.doubleValue()));
 	}
 
 	// ================== Function - ATAN2 =====================
-	public static Object atan2(Double number1, Double number2) {
+	public static Object atan2(Number number1, Number number2) {
 		return new Double(Math.atan2(number1.doubleValue(), number2.doubleValue()));
 	}
 
 	// ================== Function - COS =====================
-	public static Object cos(Double number) {
+	public static Object cos(Number number) {
 		return new Double(Math.cos(number.doubleValue()));
 	}
 
 	// ================== Function - COT =====================
-	public static Object cot(Double number) {
+	public static Object cot(Number number) {
 		return new Double(1/Math.tan(number.doubleValue()));
 	}
 
 	// ================== Function - DEGREES =====================
-	public static Object degrees(Double number) {
+	public static Object degrees(Number number) {
 		return new Double(Math.toDegrees(number.doubleValue()));
 	}
 
@@ -1303,17 +1307,17 @@
 	}
 
 	// ================== Function - RADIANS =====================
-	public static Object radians(Double number) {
+	public static Object radians(Number number) {
 		return new Double(Math.toRadians(number.doubleValue()));
 	}
 
 	// ================== Function - SIN =====================
-	public static Object sin(Double number) {
+	public static Object sin(Number number) {
 		return new Double(Math.sin(number.doubleValue()));
 	}
 
 	// ================== Function - TAN =====================
-	public static Object tan(Double number) {
+	public static Object tan(Number number) {
 		return new Double(Math.tan(number.doubleValue()));
 	}
 

Modified: trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java	2009-06-16 15:31:54 UTC (rev 1054)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java	2009-06-16 17:20:38 UTC (rev 1055)
@@ -62,11 +62,11 @@
         addArithmeticFunction(SourceSystemFunctions.SUBTRACT_OP, QueryPlugin.Util.getString("SystemSource.Subtract_desc"), "minus", QueryPlugin.Util.getString("SystemSource.Subtract_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
         addArithmeticFunction(SourceSystemFunctions.MULTIPLY_OP, QueryPlugin.Util.getString("SystemSource.Multiply_desc"), "multiply", QueryPlugin.Util.getString("SystemSource.Multiply_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
         addArithmeticFunction(SourceSystemFunctions.DIVIDE_OP, QueryPlugin.Util.getString("SystemSource.Divide_desc"), "divide", QueryPlugin.Util.getString("SystemSource.Divide_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+        addArithmeticFunction(SourceSystemFunctions.MOD, QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
         
         // numeric
         addAbsFunction();
         addRandFunction();
-        addModFunction();
         addPowerFunction();
         addRoundFunction();
         addSignFunction();
@@ -266,6 +266,11 @@
 				new FunctionParameter[] { 
 					new FunctionParameter("number", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Double_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
 				new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, description) ) );                 //$NON-NLS-1$
+		functions.add(
+				new FunctionMethod(name, description, NUMERIC, FUNCTION_CLASS, name,
+					new FunctionParameter[] { 
+						new FunctionParameter("number", DataTypeManager.DefaultDataTypes.BIG_DECIMAL, QueryPlugin.Util.getString("SystemSource.Double_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
+					new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, description) ) );                 //$NON-NLS-1$
 	}
 
 	private void addAtan2Function(String name, String description) {
@@ -275,6 +280,12 @@
 					new FunctionParameter("number1", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Atan_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
 					new FunctionParameter("number2", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Atan_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
 				new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, description) ) );                 //$NON-NLS-1$
+		functions.add(
+				new FunctionMethod(name, description, NUMERIC, FUNCTION_CLASS, name,
+					new FunctionParameter[] { 
+						new FunctionParameter("number1", DataTypeManager.DefaultDataTypes.BIG_DECIMAL, QueryPlugin.Util.getString("SystemSource.Atan_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
+						new FunctionParameter("number2", DataTypeManager.DefaultDataTypes.BIG_DECIMAL, QueryPlugin.Util.getString("SystemSource.Atan_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
+					new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, description) ) );                 //$NON-NLS-1$
 	}
 
 	private void addPiFunction(String name, String description) {
@@ -284,14 +295,6 @@
 				new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, description) ) );                 //$NON-NLS-1$
 	}
 			
-    private void addModFunction() {
-        addTypedArithmeticFunction(SourceSystemFunctions.MOD, QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
-        addTypedArithmeticFunction(SourceSystemFunctions.MOD, QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.LONG); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$ 
-        addTypedArithmeticFunction(SourceSystemFunctions.MOD, QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.FLOAT); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$ 
-        addTypedArithmeticFunction(SourceSystemFunctions.MOD, QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.DOUBLE); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$ 
-        addTypedArithmeticFunction(SourceSystemFunctions.MOD, QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.BIG_INTEGER); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$ 
-    }
-    
     private void addPowerFunction() {
         addTypedPowerFunction(DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.DOUBLE);
         addTypedPowerFunction(DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.INTEGER);        
@@ -342,6 +345,7 @@
     private void addSqrtFunction() {
         addTypedSqrtFunction(DataTypeManager.DefaultDataTypes.LONG);
         addTypedSqrtFunction(DataTypeManager.DefaultDataTypes.DOUBLE);
+        addTypedSqrtFunction(DataTypeManager.DefaultDataTypes.BIG_DECIMAL);
     }
     
     private void addTypedSqrtFunction(String type) {        

Modified: trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java	2009-06-16 15:31:54 UTC (rev 1054)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java	2009-06-16 17:20:38 UTC (rev 1055)
@@ -633,6 +633,10 @@
     @Test public void testInvokeDivide6() {
         helpInvokeMethod("/", new Object[] { new BigDecimal("3"), new BigDecimal("2") }, new BigDecimal("2"));   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
     }
+    
+    @Test public void testInvokeDivideMod() {
+        helpInvokeMethod("mod", new Object[] { new BigDecimal("3.1"), new BigDecimal("2") }, new BigDecimal("1.1"));   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+    }
 
     @Test public void testInvokeAbs1() {
         helpInvokeMethod("abs", new Object[] { new Integer(-3) }, new Integer(3)); //$NON-NLS-1$
@@ -674,6 +678,14 @@
 		helpInvokeMethod("atan2", new Object[] { new Double(0.05), new Double(0.07) }, new Double(0.6202494859828215)); //$NON-NLS-1$
 	}
 
+	@Test public void testInvokeAtanBigDecimal() {
+		helpInvokeMethod("atan", new Object[] { new BigDecimal(0.05) }, new Double(0.049958395721942765)); //$NON-NLS-1$
+	}
+
+	@Test public void testInvokeAtan2BigDecimal() {
+		helpInvokeMethod("atan2", new Object[] { new BigDecimal(0.05), new BigDecimal(0.07) }, new Double(0.6202494859828215)); //$NON-NLS-1$
+	}
+	
 	@Test public void testInvokeCos() {
 		helpInvokeMethod("cos", new Object[] { new Double(1.57) }, new Double(7.963267107332633E-4)); //$NON-NLS-1$
 	}

Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestCriteriaEvaluator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestCriteriaEvaluator.java	2009-06-16 15:31:54 UTC (rev 1054)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestCriteriaEvaluator.java	2009-06-16 17:20:38 UTC (rev 1055)
@@ -22,6 +22,9 @@
 
 package com.metamatrix.query.processor.eval;
 
+import static org.junit.Assert.*;
+
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -30,7 +33,7 @@
 import java.util.List;
 import java.util.Map;
 
-import junit.framework.TestCase;
+import org.junit.Test;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.MetaMatrixProcessingException;
@@ -38,6 +41,7 @@
 import com.metamatrix.common.buffer.BlockedException;
 import com.metamatrix.query.eval.Evaluator;
 import com.metamatrix.query.sql.lang.CollectionValueIterator;
+import com.metamatrix.query.sql.lang.CompareCriteria;
 import com.metamatrix.query.sql.lang.Criteria;
 import com.metamatrix.query.sql.lang.ExistsCriteria;
 import com.metamatrix.query.sql.lang.IsNullCriteria;
@@ -51,14 +55,8 @@
 import com.metamatrix.query.sql.util.ValueIterator;
 import com.metamatrix.query.util.CommandContext;
 
-public class TestCriteriaEvaluator extends TestCase {
+public class TestCriteriaEvaluator {
 
-	// ################################## FRAMEWORK ################################
-	
-	public TestCriteriaEvaluator(String name) { 
-		super(name);
-	}	
-	
 	// ################################## TEST HELPERS ################################
 	
     private void helpTestMatch(String value, String pattern, char escape, boolean negated, boolean expectedMatch) throws CriteriaEvaluationException, BlockedException, MetaMatrixComponentException {
@@ -122,218 +120,218 @@
 
 	// ################################## ACTUAL TESTS ################################
 	
-    public void testIsNull1() throws Exception {
+    @Test public void testIsNull1() throws Exception {
         helpTestIsNull(null, false, true);
     }
     
-    public void testIsNull2() throws Exception {
+    @Test public void testIsNull2() throws Exception {
         helpTestIsNull(null, true, false);
     }
     
-    public void testIsNull3() throws Exception {
+    @Test public void testIsNull3() throws Exception {
         helpTestIsNull("x", false, false); //$NON-NLS-1$
     }
     
-    public void testIsNull4() throws Exception {
+    @Test public void testIsNull4() throws Exception {
         helpTestIsNull("x", true, true); //$NON-NLS-1$
     }
     
-	public void testMatch1() throws Exception {
+	@Test public void testMatch1() throws Exception {
 		helpTestMatch("", "", MatchCriteria.NULL_ESCAPE_CHAR, true);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch2() throws Exception {
+	@Test public void testMatch2() throws Exception {
 		helpTestMatch("x", "", MatchCriteria.NULL_ESCAPE_CHAR, false);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch3() throws Exception {
+	@Test public void testMatch3() throws Exception {
 		helpTestMatch("", "%", MatchCriteria.NULL_ESCAPE_CHAR, true);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch4() throws Exception {
+	@Test public void testMatch4() throws Exception {
 		helpTestMatch("x", "%", MatchCriteria.NULL_ESCAPE_CHAR, true);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch5() throws Exception {
+	@Test public void testMatch5() throws Exception {
 		helpTestMatch("xx", "%", MatchCriteria.NULL_ESCAPE_CHAR, true);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch6() throws Exception {
+	@Test public void testMatch6() throws Exception {
 		helpTestMatch("xx", "%", MatchCriteria.NULL_ESCAPE_CHAR, true);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch7() throws Exception {
+	@Test public void testMatch7() throws Exception {
 		helpTestMatch("a", "a%", MatchCriteria.NULL_ESCAPE_CHAR, true);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch8() throws Exception {
+	@Test public void testMatch8() throws Exception {
 		helpTestMatch("ab", "a%", MatchCriteria.NULL_ESCAPE_CHAR, true);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch9() throws Exception {
+	@Test public void testMatch9() throws Exception {
 		helpTestMatch("a.", "a%", MatchCriteria.NULL_ESCAPE_CHAR, true);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch10() throws Exception {
+	@Test public void testMatch10() throws Exception {
 		helpTestMatch("a.", "a%", MatchCriteria.NULL_ESCAPE_CHAR, true);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 	
-	public void testMatch11() throws Exception {
+	@Test public void testMatch11() throws Exception {
 		helpTestMatch("ax.", "a%", MatchCriteria.NULL_ESCAPE_CHAR, true);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 	
-	public void testMatch12() throws Exception {
+	@Test public void testMatch12() throws Exception {
 		helpTestMatch("a..", "a%", MatchCriteria.NULL_ESCAPE_CHAR, true);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch13() throws Exception {
+	@Test public void testMatch13() throws Exception {
 //		helpTestMatch("x.y", "%.", MatchCriteria.NULL_ESCAPE_CHAR, false);		
 		helpTestMatch("a.b", "a%.", MatchCriteria.NULL_ESCAPE_CHAR, false);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch14() throws Exception {
+	@Test public void testMatch14() throws Exception {
 		helpTestMatch("aaa", "%aaa", MatchCriteria.NULL_ESCAPE_CHAR, true);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch15() throws Exception {
+	@Test public void testMatch15() throws Exception {
 		helpTestMatch("baaa", "%aaa", MatchCriteria.NULL_ESCAPE_CHAR, true);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch16() throws Exception {
+	@Test public void testMatch16() throws Exception {
 		helpTestMatch("aaaa", "%aaa", MatchCriteria.NULL_ESCAPE_CHAR, true);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 	
-	public void testMatch17() throws Exception {
+	@Test public void testMatch17() throws Exception {
 		helpTestMatch("aaxaa", "%aaa", MatchCriteria.NULL_ESCAPE_CHAR, false);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 	
-	public void testMatch18() throws Exception {
+	@Test public void testMatch18() throws Exception {
 		helpTestMatch("", "a%b%", MatchCriteria.NULL_ESCAPE_CHAR, false);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch19() throws Exception {
+	@Test public void testMatch19() throws Exception {
 		helpTestMatch("a", "a%b%", MatchCriteria.NULL_ESCAPE_CHAR, false);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 	
-	public void testMatch20() throws Exception {
+	@Test public void testMatch20() throws Exception {
 		helpTestMatch("ab", "a%b%", MatchCriteria.NULL_ESCAPE_CHAR, true);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 	
-	public void testMatch21() throws Exception {
+	@Test public void testMatch21() throws Exception {
 		helpTestMatch("axb", "a%b%", MatchCriteria.NULL_ESCAPE_CHAR, true);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 	
-	public void testMatch22() throws Exception {
+	@Test public void testMatch22() throws Exception {
 		helpTestMatch("abx", "a%b%", MatchCriteria.NULL_ESCAPE_CHAR, true);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 	
-	public void testMatch23() throws Exception {
+	@Test public void testMatch23() throws Exception {
 		helpTestMatch("", "X%", 'X', false);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch24() throws Exception {
+	@Test public void testMatch24() throws Exception {
 		helpTestMatch("x", "X%", 'X', false);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch25() throws Exception {
+	@Test public void testMatch25() throws Exception {
 		helpTestMatch("xx", "X%", 'X', false);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch26() throws Exception {
+	@Test public void testMatch26() throws Exception {
 		helpTestMatch("a%", "aX%", 'X', true);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch27() throws Exception {
+	@Test public void testMatch27() throws Exception {
 		helpTestMatch("aX%", "aX%", 'X', false);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch28() throws Exception {
+	@Test public void testMatch28() throws Exception {
 		helpTestMatch("a%bb", "aX%b%", 'X', true);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch29() throws Exception {
+	@Test public void testMatch29() throws Exception {
 		helpTestMatch("aX%bb", "aX%b%", 'X', false);		 //$NON-NLS-1$ //$NON-NLS-2$
 	}
 	
-	public void testMatch30() throws Exception {
+	@Test public void testMatch30() throws Exception {
 		helpTestMatch("", "_", MatchCriteria.NULL_ESCAPE_CHAR, false); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch31() throws Exception {
+	@Test public void testMatch31() throws Exception {
 		helpTestMatch("X", "_", MatchCriteria.NULL_ESCAPE_CHAR, true); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch32() throws Exception {
+	@Test public void testMatch32() throws Exception {
 		helpTestMatch("XX", "_", MatchCriteria.NULL_ESCAPE_CHAR, false); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch33() throws Exception {
+	@Test public void testMatch33() throws Exception {
 		helpTestMatch("", "__", MatchCriteria.NULL_ESCAPE_CHAR, false); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch34() throws Exception {
+	@Test public void testMatch34() throws Exception {
 		helpTestMatch("X", "__", MatchCriteria.NULL_ESCAPE_CHAR, false); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch35() throws Exception {
+	@Test public void testMatch35() throws Exception {
 		helpTestMatch("XX", "__", MatchCriteria.NULL_ESCAPE_CHAR, true); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch36() throws Exception {
+	@Test public void testMatch36() throws Exception {
 		helpTestMatch("XX", "_%_", MatchCriteria.NULL_ESCAPE_CHAR, true); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch37() throws Exception {
+	@Test public void testMatch37() throws Exception {
 		helpTestMatch("XaaY", "_%_", MatchCriteria.NULL_ESCAPE_CHAR, true); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch38() throws Exception {
+	@Test public void testMatch38() throws Exception {
 		helpTestMatch("a.b.c", "a.b.c", MatchCriteria.NULL_ESCAPE_CHAR, true); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch39() throws Exception {
+	@Test public void testMatch39() throws Exception {
 		helpTestMatch("a.b.c", "a%.c", MatchCriteria.NULL_ESCAPE_CHAR, true); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testMatch40() throws Exception {
+	@Test public void testMatch40() throws Exception {
 		helpTestMatch("a.b.", "a.b.", MatchCriteria.NULL_ESCAPE_CHAR, true); //$NON-NLS-1$ //$NON-NLS-2$
 	}
     
-    public void testMatch41() throws Exception {
+    @Test public void testMatch41() throws Exception {
         helpTestMatch("asjdfajsdf (&). asdfasdf\nkjhkjh", "%&%", MatchCriteria.NULL_ESCAPE_CHAR, true);     //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testMatch42() throws Exception {
+    @Test public void testMatch42() throws Exception {
         helpTestMatch("x", "", MatchCriteria.NULL_ESCAPE_CHAR, true, true); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testMatch43() throws Exception {
+    @Test public void testMatch43() throws Exception {
         helpTestMatch("a.b.", "a.b.", MatchCriteria.NULL_ESCAPE_CHAR, true, false); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testMatch44() throws Exception {
+    @Test public void testMatch44() throws Exception {
         helpTestMatch(null, "a.b.", MatchCriteria.NULL_ESCAPE_CHAR, false); //$NON-NLS-1$ 
     }
     
-    public void testMatch45() throws Exception {
+    @Test public void testMatch45() throws Exception {
         helpTestMatch("a.b.", null, MatchCriteria.NULL_ESCAPE_CHAR, false); //$NON-NLS-1$ 
     }
     
-    public void testMatch46() throws Exception {
+    @Test public void testMatch46() throws Exception {
         helpTestMatch("ab\r\n", "ab%", MatchCriteria.NULL_ESCAPE_CHAR, true); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testMatch47() throws Exception {
+    @Test public void testMatch47() throws Exception {
         helpTestMatch("", "", 'a', true); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     //should succeed - should be able to escape the escape char
-    public void testMatch48() throws Exception {
+    @Test public void testMatch48() throws Exception {
         helpTestMatch("abc", "aa%", 'a', true); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     //should fail - invalid match sequence
-    public void testMatch49() throws Exception {
+    @Test public void testMatch49() throws Exception {
         try {
             helpTestMatch("abc", "a", 'a', true); //$NON-NLS-1$ //$NON-NLS-2$
         } catch (CriteriaEvaluationException cee) {
@@ -342,7 +340,7 @@
     }
     
     //should fail - can't escape a non match char
-    public void testMatch50() throws Exception {
+    @Test public void testMatch50() throws Exception {
         try {
             helpTestMatch("abc", "ab", 'a', true); //$NON-NLS-1$ //$NON-NLS-2$
         } catch (CriteriaEvaluationException cee) {
@@ -351,43 +349,43 @@
     }
     
     //should be able to use a regex reserved char as the escape char
-    public void testMatch51() throws Exception {
+    @Test public void testMatch51() throws Exception {
         helpTestMatch("$", "$$", '$', true); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testMatch52() throws Exception {
+    @Test public void testMatch52() throws Exception {
         helpTestMatch("abc\nde", "a%e", MatchCriteria.NULL_ESCAPE_CHAR, true); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testMatch53() throws Exception {
+    @Test public void testMatch53() throws Exception {
         helpTestMatch("\\", "\\%", MatchCriteria.NULL_ESCAPE_CHAR, true); //$NON-NLS-1$ //$NON-NLS-2$
     }
     
-    public void testSetCriteria1() throws Exception {
+    @Test public void testSetCriteria1() throws Exception {
         helpTestSetCriteria(1000, false, true);
     }
     
-    public void testSetCriteria2() throws Exception {
+    @Test public void testSetCriteria2() throws Exception {
         helpTestSetCriteria(1, false, false);
     }
     
-    public void testSetCriteria3() throws Exception {
+    @Test public void testSetCriteria3() throws Exception {
         helpTestSetCriteria(1000, true, false);
     }
     
-    public void testSetCriteria4() throws Exception {
+    @Test public void testSetCriteria4() throws Exception {
         helpTestSetCriteria(1, true, true);
     }
     
-    public void testSetCriteria5() throws Exception {
+    @Test public void testSetCriteria5() throws Exception {
         helpTestSetCriteria(null, true, false);
     }
     
-    public void testSetCriteria6() throws Exception {
+    @Test public void testSetCriteria6() throws Exception {
         helpTestSetCriteria(null, false, false);
     }
     
-    public void testExistsCriteria() throws Exception {
+    @Test public void testExistsCriteria() throws Exception {
         ExistsCriteria crit = new ExistsCriteria(new Query());
         ArrayList values = new ArrayList();
         values.add("a"); //$NON-NLS-1$
@@ -396,7 +394,7 @@
         helpTestCompareSubqueryCriteria(crit, true, values);
     }
 
-    public void testExistsCriteria2() throws Exception {
+    @Test public void testExistsCriteria2() throws Exception {
         ExistsCriteria crit = new ExistsCriteria(new Query());
         helpTestCompareSubqueryCriteria(crit, false, Collections.emptyList());
     }
@@ -405,7 +403,7 @@
      * If rows are returned but they contain null, the result should
      * still be true.
      */
-    public void testExistsCriteria3() throws Exception {
+    @Test public void testExistsCriteria3() throws Exception {
         ExistsCriteria crit = new ExistsCriteria(new Query());
         ArrayList values = new ArrayList();
         values.add(null);
@@ -418,7 +416,7 @@
      * Special case: if ALL is specified and the subquery returns no rows,
      * the result is true.
      */
-    public void testCompareSubqueryCriteriaNoRows() throws Exception {
+    @Test public void testCompareSubqueryCriteriaNoRows() throws Exception {
         SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.ALL);
         helpTestCompareSubqueryCriteria(crit, true, Collections.emptyList()); 
     }
@@ -427,7 +425,7 @@
      * Special case: if ANY/SOME is specified and the subquery returns no rows,
      * the result is false.
      */
-    public void testCompareSubqueryCriteriaNoRows2() throws Exception {
+    @Test public void testCompareSubqueryCriteriaNoRows2() throws Exception {
         SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.SOME);
         helpTestCompareSubqueryCriteria(crit, false, Collections.emptyList()); 
     }
@@ -436,12 +434,12 @@
      * Special case: if no predicate quantifier is specified and the subquery returns no rows,
      * the result is false.
      */
-    public void testCompareSubqueryCriteriaNoRows3() throws Exception {
+    @Test public void testCompareSubqueryCriteriaNoRows3() throws Exception {
         SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.NO_QUANTIFIER);
         helpTestCompareSubqueryCriteria(crit, false, Collections.emptyList()); 
     }
 
-    public void testCompareSubqueryCriteria2() throws Exception {
+    @Test public void testCompareSubqueryCriteria2() throws Exception {
         SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.ALL);
         ArrayList values = new ArrayList();
         values.add("a"); //$NON-NLS-1$
@@ -450,7 +448,7 @@
         helpTestCompareSubqueryCriteria(crit, false, values); 
     }
 
-    public void testCompareSubqueryCriteria3() throws Exception {
+    @Test public void testCompareSubqueryCriteria3() throws Exception {
         SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.SOME);
         ArrayList values = new ArrayList();
         values.add("a"); //$NON-NLS-1$
@@ -459,7 +457,7 @@
         helpTestCompareSubqueryCriteria(crit, true, values); 
     }
     
-    public void testCompareSubqueryCriteria4() throws Exception {
+    @Test public void testCompareSubqueryCriteria4() throws Exception {
         SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.SOME);
         ArrayList values = new ArrayList();
         values.add("b"); //$NON-NLS-1$
@@ -467,7 +465,7 @@
         helpTestCompareSubqueryCriteria(crit, false, values); 
     }
 
-    public void testCompareSubqueryCriteria5() throws Exception {
+    @Test public void testCompareSubqueryCriteria5() throws Exception {
         SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.SOME);
         ArrayList values = new ArrayList();
         values.add("a"); //$NON-NLS-1$
@@ -476,14 +474,14 @@
         helpTestCompareSubqueryCriteria(crit, true, values); 
     }
 
-    public void testCompareSubqueryCriteria6() throws Exception {
+    @Test public void testCompareSubqueryCriteria6() throws Exception {
         SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.NO_QUANTIFIER);
         ArrayList values = new ArrayList();
         values.add("a"); //$NON-NLS-1$
         helpTestCompareSubqueryCriteria(crit, true, values); 
     }
 
-    public void testCompareSubqueryCriteria7() throws Exception {
+    @Test public void testCompareSubqueryCriteria7() throws Exception {
         SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.NO_QUANTIFIER);
         ArrayList values = new ArrayList();
         values.add("b"); //$NON-NLS-1$
@@ -496,7 +494,7 @@
      * have a predicate quantifier, but there is more than one value in the
      * ValueIterator
      */
-    public void testCompareSubqueryCriteriaFails1() throws Exception {
+    @Test public void testCompareSubqueryCriteriaFails1() throws Exception {
         SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.NO_QUANTIFIER);
         ArrayList values = new ArrayList();
         values.add("a"); //$NON-NLS-1$
@@ -509,14 +507,14 @@
         }
     }
 
-    public void testCompareSubqueryCriteriaNulls2() throws Exception {
+    @Test public void testCompareSubqueryCriteriaNulls2() throws Exception {
         SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.NO_QUANTIFIER);
         ArrayList values = new ArrayList();
         values.add(null);
         helpTestCompareSubqueryCriteria(crit, false, values); 
     }
 
-    public void testCompareSubqueryCriteriaNulls3() throws Exception {
+    @Test public void testCompareSubqueryCriteriaNulls3() throws Exception {
         SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.ALL);
         ArrayList values = new ArrayList();
         values.add(null);
@@ -524,7 +522,7 @@
         helpTestCompareSubqueryCriteria(crit, false, values); 
     }
 
-    public void testCompareSubqueryCriteriaNulls4() throws Exception {
+    @Test public void testCompareSubqueryCriteriaNulls4() throws Exception {
         SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.SOME);
         ArrayList values = new ArrayList();
         values.add(null);
@@ -532,7 +530,7 @@
         helpTestCompareSubqueryCriteria(crit, false, values); 
     }
 
-    public void testCompareSubqueryCriteriaNulls5() throws Exception {
+    @Test public void testCompareSubqueryCriteriaNulls5() throws Exception {
         SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.SOME);
         ArrayList values = new ArrayList();
         values.add(null);
@@ -541,7 +539,7 @@
         helpTestCompareSubqueryCriteria(crit, true, values); 
     }
 
-    public void testCompareSubqueryCriteriaNulls6() throws Exception {
+    @Test public void testCompareSubqueryCriteriaNulls6() throws Exception {
         SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.EQ, SubqueryCompareCriteria.SOME);
         ArrayList values = new ArrayList();
         values.add("a"); //$NON-NLS-1$
@@ -553,7 +551,7 @@
     /**
      * null is unknown
      */
-    public void testCompareSubqueryCriteriaNulls7() throws Exception{
+    @Test public void testCompareSubqueryCriteriaNulls7() throws Exception{
         SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.LT, SubqueryCompareCriteria.ALL);
         ArrayList values = new ArrayList();
         values.add(null);
@@ -564,11 +562,20 @@
     /**
      * null is unknown
      */
-    public void testCompareSubqueryCriteriaNulls8() throws Exception {
+    @Test public void testCompareSubqueryCriteriaNulls8() throws Exception {
         SubqueryCompareCriteria crit = helpGetCompareSubqueryCriteria(SubqueryCompareCriteria.GT, SubqueryCompareCriteria.ALL);
         ArrayList values = new ArrayList();
         values.add(null);
         values.add(null);
         helpTestCompareSubqueryCriteria(crit, false, values); 
     }
+    
+    /**
+     * Big decimal comparisons should ignore precision.
+     */
+    @Test public void testBigDecimalEquality() throws Exception {
+    	CompareCriteria crit = new CompareCriteria(new Constant(new BigDecimal("3.10")), CompareCriteria.EQ, new Constant(new BigDecimal("3.1"))); //$NON-NLS-1$ //$NON-NLS-2$
+    	assertTrue(Evaluator.evaluate(crit));
+    }
+
 }




More information about the teiid-commits mailing list