Author: shawkins
Date: 2009-07-28 16:59:49 -0400 (Tue, 28 Jul 2009)
New Revision: 1199
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBigDecimalTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBigIntegerTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBooleanTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToByteTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToDateTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToIntegerTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToLongTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToShortTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToTimeTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToTimestampTransform.java
trunk/common-core/src/main/resources/com/metamatrix/core/i18n.properties
trunk/common-core/src/test/java/com/metamatrix/common/types/basic/TestTransforms.java
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java
trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java
trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java
Log:
TEIID-745 ensuring that all the parse routines obey the same rules and updating the
reference.
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBigDecimalTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBigDecimalTransform.java 2009-07-28
18:53:00 UTC (rev 1198)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBigDecimalTransform.java 2009-07-28
20:59:49 UTC (rev 1199)
@@ -45,7 +45,7 @@
}
try {
- return new BigDecimal((String)value);
+ return new BigDecimal(((String)value).trim());
} catch(NumberFormatException e) {
throw new TransformationException(ErrorMessageKeys.TYPES_ERR_0014,
CorePlugin.Util.getString(ErrorMessageKeys.TYPES_ERR_0014, value));
}
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBigIntegerTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBigIntegerTransform.java 2009-07-28
18:53:00 UTC (rev 1198)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBigIntegerTransform.java 2009-07-28
20:59:49 UTC (rev 1199)
@@ -45,7 +45,7 @@
}
try {
- return new BigInteger((String)value);
+ return new BigInteger(((String)value).trim());
} catch(NumberFormatException e) {
throw new TransformationException(ErrorMessageKeys.TYPES_ERR_0015,
CorePlugin.Util.getString(ErrorMessageKeys.TYPES_ERR_0015, value));
}
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBooleanTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBooleanTransform.java 2009-07-28
18:53:00 UTC (rev 1198)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBooleanTransform.java 2009-07-28
20:59:49 UTC (rev 1199)
@@ -42,7 +42,7 @@
if(value == null) {
return value;
}
- String str = (String)value;
+ String str = ((String)value).trim();
if (TRUE.equals(str)) {
return Boolean.TRUE;
}
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToByteTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToByteTransform.java 2009-07-28
18:53:00 UTC (rev 1198)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToByteTransform.java 2009-07-28
20:59:49 UTC (rev 1199)
@@ -43,7 +43,7 @@
}
try {
- return Byte.valueOf((String)value);
+ return Byte.valueOf(((String)value).trim());
} catch(NumberFormatException e) {
throw new TransformationException(ErrorMessageKeys.TYPES_ERR_0016,
CorePlugin.Util.getString(ErrorMessageKeys.TYPES_ERR_0016, value));
}
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToDateTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToDateTransform.java 2009-07-28
18:53:00 UTC (rev 1198)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToDateTransform.java 2009-07-28
20:59:49 UTC (rev 1199)
@@ -43,12 +43,17 @@
if(value == null) {
return value;
}
-
+ value = ((String) value).trim();
+ Date result = null;
try {
- return Date.valueOf( (String) value );
+ result = Date.valueOf( (String) value );
} catch(Exception e) {
throw new TransformationException(e, ErrorMessageKeys.TYPES_ERR_0018,
CorePlugin.Util.getString(ErrorMessageKeys.TYPES_ERR_0018, value));
}
+ if (!result.toString().equals(value)) {
+ throw new
TransformationException(CorePlugin.Util.getString("transform.invalid_string_for_date",
value, getTargetType().getSimpleName())); //$NON-NLS-1$
+ }
+ return result;
}
/**
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToIntegerTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToIntegerTransform.java 2009-07-28
18:53:00 UTC (rev 1198)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToIntegerTransform.java 2009-07-28
20:59:49 UTC (rev 1199)
@@ -43,7 +43,7 @@
}
try {
- return Integer.valueOf((String)value);
+ return Integer.valueOf(((String)value).trim());
} catch(NumberFormatException e) {
throw new TransformationException(ErrorMessageKeys.TYPES_ERR_0021,
CorePlugin.Util.getString(ErrorMessageKeys.TYPES_ERR_0021, value));
}
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToLongTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToLongTransform.java 2009-07-28
18:53:00 UTC (rev 1198)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToLongTransform.java 2009-07-28
20:59:49 UTC (rev 1199)
@@ -43,7 +43,7 @@
}
try {
- return Long.valueOf((String)value);
+ return Long.valueOf(((String)value).trim());
} catch(NumberFormatException e) {
throw new TransformationException(ErrorMessageKeys.TYPES_ERR_0022,
CorePlugin.Util.getString(ErrorMessageKeys.TYPES_ERR_0022, value));
}
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToShortTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToShortTransform.java 2009-07-28
18:53:00 UTC (rev 1198)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToShortTransform.java 2009-07-28
20:59:49 UTC (rev 1199)
@@ -43,7 +43,7 @@
}
try {
- return Short.valueOf((String)value);
+ return Short.valueOf(((String)value).trim());
} catch(NumberFormatException e) {
throw new TransformationException(ErrorMessageKeys.TYPES_ERR_0023,
CorePlugin.Util.getString(ErrorMessageKeys.TYPES_ERR_0023, value));
}
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToTimeTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToTimeTransform.java 2009-07-28
18:53:00 UTC (rev 1198)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToTimeTransform.java 2009-07-28
20:59:49 UTC (rev 1199)
@@ -43,12 +43,17 @@
if(value == null) {
return value;
}
-
+ value = ((String) value).trim();
+ Time result = null;
try {
- return Time.valueOf( (String) value );
+ result = Time.valueOf((String)value);
} catch(Exception e) {
throw new TransformationException(e, ErrorMessageKeys.TYPES_ERR_0025,
CorePlugin.Util.getString(ErrorMessageKeys.TYPES_ERR_0025, value));
}
+ if (!result.toString().equals(value)) {
+ throw new
TransformationException(CorePlugin.Util.getString("transform.invalid_string_for_date",
value, getTargetType().getSimpleName())); //$NON-NLS-1$
+ }
+ return result;
}
/**
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToTimestampTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToTimestampTransform.java 2009-07-28
18:53:00 UTC (rev 1198)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToTimestampTransform.java 2009-07-28
20:59:49 UTC (rev 1199)
@@ -43,12 +43,18 @@
if(value == null) {
return value;
}
-
+ value = ((String) value).trim();
+ Timestamp result = null;
try {
- return Timestamp.valueOf( (String) value );
+ result = Timestamp.valueOf( (String) value );
} catch(Exception e) {
throw new TransformationException(e, ErrorMessageKeys.TYPES_ERR_0024,
CorePlugin.Util.getString(ErrorMessageKeys.TYPES_ERR_0024, value));
}
+ //validate everything except for fractional seconds
+ if (!((String)value).startsWith(result.toString().substring(0, 19))) {
+ throw new
TransformationException(CorePlugin.Util.getString("transform.invalid_string_for_date",
value, getTargetType().getSimpleName())); //$NON-NLS-1$
+ }
+ return result;
}
/**
Modified: trunk/common-core/src/main/resources/com/metamatrix/core/i18n.properties
===================================================================
--- trunk/common-core/src/main/resources/com/metamatrix/core/i18n.properties 2009-07-28
18:53:00 UTC (rev 1198)
+++ trunk/common-core/src/main/resources/com/metamatrix/core/i18n.properties 2009-07-28
20:59:49 UTC (rev 1199)
@@ -402,4 +402,6 @@
ERR.003.030.0181=Failed to connect to the Database at {0} check connection properties.
ExceptionHolder.converted_exception=Remote exception: {0} ... Original type hierarchy
{1}.
-PropertiesUtils.failed_to_resolve_property=failed to completely resolve the property
value for key {0}
\ No newline at end of file
+PropertiesUtils.failed_to_resolve_property=failed to completely resolve the property
value for key {0}
+
+transform.invalid_string_for_date=The string representation ''{0}'' of a
{1} value is out of range.
\ No newline at end of file
Modified:
trunk/common-core/src/test/java/com/metamatrix/common/types/basic/TestTransforms.java
===================================================================
---
trunk/common-core/src/test/java/com/metamatrix/common/types/basic/TestTransforms.java 2009-07-28
18:53:00 UTC (rev 1198)
+++
trunk/common-core/src/test/java/com/metamatrix/common/types/basic/TestTransforms.java 2009-07-28
20:59:49 UTC (rev 1199)
@@ -22,13 +22,15 @@
package com.metamatrix.common.types.basic;
+import static org.junit.Assert.*;
+
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
-import junit.framework.TestCase;
+import org.junit.Test;
import com.metamatrix.common.types.ClobType;
import com.metamatrix.common.types.DataTypeManager;
@@ -39,12 +41,13 @@
import com.metamatrix.common.types.XMLType;
import com.metamatrix.common.types.DataTypeManager.DefaultDataClasses;
import com.metamatrix.common.types.DataTypeManager.DefaultDataTypes;
+import com.metamatrix.query.unittest.TimestampUtil;
/**
* @since 4.2
*/
-public class TestTransforms extends TestCase {
+public class TestTransforms {
private static void helpTestTransform(Object value, Object expectedValue) throws
TransformationException {
Transform transform = DataTypeManager.getTransform(value.getClass(),
expectedValue.getClass());
@@ -64,21 +67,27 @@
}
}
- private static void helpTransformException(Object value, Object expectedValue) {
+ private static void helpTransformException(Object value, Class<?> target) {
+ helpTransformException(value, target, null);
+ }
+
+ private static void helpTransformException(Object value, Class<?> target,
String msg) {
try {
- Transform transform = DataTypeManager.getTransform(value.getClass(),
expectedValue.getClass());
+ Transform transform = DataTypeManager.getTransform(value.getClass(),
target);
transform.transform(value);
fail("Expected to get an exception during the transformation");
//$NON-NLS-1$
} catch (TransformationException e) {
- assertTrue(true);
+ if (msg != null) {
+ assertEquals(msg, e.getMessage());
+ }
}
}
- public void testBigDecimalToBigInteger_Defect16875() throws TransformationException
{
+ @Test public void testBigDecimalToBigInteger_Defect16875() throws
TransformationException {
helpTestTransform(new BigDecimal("0.5867"), new
BigInteger("0")); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testString2Boolean() throws TransformationException {
+ @Test public void testString2Boolean() throws TransformationException {
helpTestTransform(new String("1"), Boolean.TRUE); //$NON-NLS-1$
helpTestTransform(new String("0"), Boolean.FALSE); //$NON-NLS-1$
helpTestTransform(new String("true"), Boolean.TRUE); //$NON-NLS-1$
@@ -86,34 +95,34 @@
helpTestTransform(new String("foo"), Boolean.FALSE); //$NON-NLS-1$
}
- public void testByte2Boolean() throws TransformationException {
+ @Test public void testByte2Boolean() throws TransformationException {
helpTestTransform(new Byte((byte)1), Boolean.TRUE);
helpTestTransform(new Byte((byte)0), Boolean.FALSE);
- helpTransformException(new Byte((byte)12), Boolean.FALSE);
+ helpTransformException(new Byte((byte)12),
DataTypeManager.DefaultDataClasses.BOOLEAN);
}
- public void testShort2Boolean() throws TransformationException {
+ @Test public void testShort2Boolean() throws TransformationException {
helpTestTransform(new Short((short)1), Boolean.TRUE);
helpTestTransform(new Short((short)0), Boolean.FALSE);
- helpTransformException(new Short((short)12), Boolean.FALSE);
+ helpTransformException(new Short((short)12),
DataTypeManager.DefaultDataClasses.BOOLEAN);
}
- public void testInteger2Boolean() throws TransformationException {
+ @Test public void testInteger2Boolean() throws TransformationException {
helpTestTransform(new Integer(1), Boolean.TRUE);
helpTestTransform(new Integer(0), Boolean.FALSE);
- helpTransformException(new Integer(12), Boolean.FALSE);
+ helpTransformException(new Integer(12),
DataTypeManager.DefaultDataClasses.BOOLEAN);
}
- public void testLong2Boolean() throws TransformationException {
+ @Test public void testLong2Boolean() throws TransformationException {
helpTestTransform(new Long(1), Boolean.TRUE);
helpTestTransform(new Long(0), Boolean.FALSE);
- helpTransformException(new Long(12), Boolean.FALSE);
+ helpTransformException(new Long(12),
DataTypeManager.DefaultDataClasses.BOOLEAN);
}
- public void testBigInteger2Boolean() throws TransformationException {
+ @Test public void testBigInteger2Boolean() throws TransformationException {
helpTestTransform(new BigInteger("1"), Boolean.TRUE); //$NON-NLS-1$
helpTestTransform(new BigInteger("0"), Boolean.FALSE); //$NON-NLS-1$
- helpTransformException(new BigInteger("12"), Boolean.FALSE);
//$NON-NLS-1$
+ helpTransformException(new BigInteger("12"),
DataTypeManager.DefaultDataClasses.BOOLEAN); //$NON-NLS-1$
}
static Object[][] testData = {
@@ -155,7 +164,7 @@
|| (src.equals(DataTypeManager.DefaultDataTypes.BIG_DECIMAL) &&
tgt.equals(DataTypeManager.DefaultDataTypes.BOOLEAN) && source ==
testData[10][2]);
}
- public void testAllConversions() throws TransformationException {
+ @Test public void testAllConversions() throws TransformationException {
for (int src = 0; src < dataTypes.length; src++) {
for (int tgt =0; tgt < dataTypes.length; tgt++) {
char c = conversions[src][tgt];
@@ -173,7 +182,7 @@
}
}
- public void testAllConversionsAsObject() throws TransformationException {
+ @Test public void testAllConversionsAsObject() throws TransformationException {
for (int src = 0; src < dataTypes.length; src++) {
for (int tgt =0; tgt < dataTypes.length; tgt++) {
char c = conversions[src][tgt];
@@ -191,7 +200,7 @@
}
}
- public void testObjectToAnyTransformFailure() {
+ @Test public void testObjectToAnyTransformFailure() {
Transform transform = DataTypeManager.getTransform(DefaultDataClasses.OBJECT,
DefaultDataClasses.TIME);
try {
transform.transform("1"); //$NON-NLS-1$
@@ -201,7 +210,7 @@
}
}
- public void testSQLXMLToStringTransform() throws Exception {
+ @Test public void testSQLXMLToStringTransform() throws Exception {
StringBuffer xml = new StringBuffer();
int iters = DataTypeManager.MAX_STRING_LENGTH/10;
for (int i = 0; i < iters; i++) {
@@ -217,4 +226,17 @@
helpTestTransform(new StringToSQLXMLTransform().transform(xml.toString()),
expected);
}
+
+ @Test public void testStringToTimestampOutOfRange() throws Exception {
+ helpTransformException("2005-13-01 11:13:01",
DefaultDataClasses.TIMESTAMP, "The string representation '2005-13-01
11:13:01' of a Timestamp value is out of range."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testStringToTimeTimestampWithWS() throws Exception {
+ helpTestTransform(" 2005-12-01 11:13:01 ",
TimestampUtil.createTimestamp(105, 11, 1, 11, 13, 1, 0)); //$NON-NLS-1$
+ }
+
+ @Test public void testStringToLongWithWS() throws Exception {
+ helpTestTransform(" 1 ", Long.valueOf(1)); //$NON-NLS-1$
+ }
+
}
Modified:
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
===================================================================
---
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2009-07-28
18:53:00 UTC (rev 1198)
+++
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2009-07-28
20:59:49 UTC (rev 1199)
@@ -505,8 +505,8 @@
numeric string formats by visiting the Sun Java Web site at the
following
<ulink
-
url="http://java.sun.com/j2se/1.4.2/docs/api/java/text/DecimalFormat...
for Sun Java</ulink>
- .
+
url="http://java.sun.com/javase/6/docs/api/java/text/DecimalFormat.h...
for Sun Java</ulink>
+ . In addition to the Java conventions, parse strings have leading and trailing
whitespace removed automatically and cannot contain characters after a valid parse
prefix.
</para>
<para>For example, you could use these function calls, with the
formatting string that adheres to the java.text.DecimalFormat
@@ -618,7 +618,7 @@
defines numeric string formats by visiting the Sun Java Web site
at the following
<ulink
-
url="http://java.sun.com/j2se/1.4.2/docs/api/java/text/DecimalFormat...
for Sun Java</ulink>
+
url="http://java.sun.com/javase/6/docs/api/java/text/DecimalFormat.h...
for Sun Java</ulink>
.
</para>
<para>For example, you could use these function calls, with the
@@ -1038,7 +1038,16 @@
</sect1>
<sect1 id="date_time_functions">
<title>Date/Time Functions</title>
- <para>Date and time functions return dates, times, or timestamps.
</para>
+ <para>Date and time functions return or operate on dates, times, or timestamps.
</para>
+ <para>Parse and format Date/Time functions use the convention established
within
+ the java.text.SimpleDateFormat class to define the formats you can
+ use with these functions. You can learn more about how this class
+ defines formats by visiting the Sun Java Web site
+ at the following
+ <ulink
+
url="http://java.sun.com/javase/6/docs/api/java/text/SimpleDateForma...
for Sun Java</ulink>
+ . In addition to the Java conventions, parse strings have leading and trailing
whitespace removed automatically and cannot contain characters after a valid parse
prefix.
+ </para>
<informaltable frame="all">
<tgroup cols="3">
<thead>
Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java 2009-07-28
18:53:00 UTC (rev 1198)
+++
trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java 2009-07-28
20:59:49 UTC (rev 1199)
@@ -29,6 +29,7 @@
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.DecimalFormat;
+import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
@@ -1120,42 +1121,32 @@
}
// ================== Parse String TO date/time/timestamp ==================
- public static Object parseDate(String date, String format)
- throws FunctionExecutionException {
- try {
- DateFormat df= new SimpleDateFormat(format);
- Date parsedDate = df.parse(date);
- return TimestampWithTimezone.createDate(parsedDate);
- } catch (java.text.ParseException pe) {
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0043,
QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0043 ,
- date, format));
+ private static Date parseDateHelper(String date, String format)
+ throws FunctionExecutionException {
+ date = date.trim();
+ DateFormat df = new SimpleDateFormat(format);
+ df.setLenient(false);
+ ParsePosition pp = new ParsePosition(0);
+ Date parsedDate = df.parse(date, pp);
+ if (parsedDate == null || pp.getIndex() < date.length()) {
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0043,
QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0043, date, format));
}
+ return parsedDate;
}
-
- public static Object parseTime(String time, String format)
+
+ public static Date parseDate(String date, String format)
throws FunctionExecutionException {
-
- try {
- DateFormat df= new SimpleDateFormat(format);
- Date date = df.parse(time);
- return TimestampWithTimezone.createTime(date);
- } catch (java.text.ParseException pe) {
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0043,
QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0043 ,
- time,format));
- }
+ return TimestampWithTimezone.createDate(parseDateHelper(date, format));
}
- public static Object parseTimestamp(String timestamp, String format)
+ public static Time parseTime(String time, String format)
throws FunctionExecutionException {
+ return TimestampWithTimezone.createTime(parseDateHelper(time, format));
+ }
- try {
- DateFormat df= new SimpleDateFormat(format);
- Date date = df.parse(timestamp);
- return new Timestamp(date.getTime());
- } catch (java.text.ParseException pe) {
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0043,
QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0043 ,
- timestamp,format));
- }
+ public static Timestamp parseTimestamp(String timestamp, String format)
+ throws FunctionExecutionException {
+ return new Timestamp(parseDateHelper(timestamp, format).getTime());
}
// ================== Format number TO String ==================
@@ -1189,37 +1180,37 @@
}
// ================== Parse String TO numbers ==================
- public static Object parseInteger(Object number, Object format)
+ public static Object parseInteger(String number, String format)
throws FunctionExecutionException {
Number intNum = parseNumberHelper(number, format);
return new Integer(intNum.intValue());
}
- public static Object parseLong(Object number, Object format)
+ public static Object parseLong(String number, String format)
throws FunctionExecutionException {
Number longNum = parseNumberHelper(number, format);
return new Long(longNum.longValue());
}
- public static Object parseDouble(Object number, Object format)
+ public static Object parseDouble(String number, String format)
throws FunctionExecutionException {
Number doubleNum = parseNumberHelper(number, format);
return new Double(doubleNum.doubleValue());
}
- public static Object parseFloat(Object number, Object format)
+ public static Object parseFloat(String number, String format)
throws FunctionExecutionException {
Number longNum = parseNumberHelper(number, format);
return new Float(longNum.floatValue());
}
- public static Object parseBigInteger(Object number, Object format)
+ public static Object parseBigInteger(String number, String format)
throws FunctionExecutionException {
Number bigIntegerNum = parseNumberHelper(number, format);
return new BigInteger(bigIntegerNum.toString());
}
- public static Object parseBigDecimal(Object number, Object format)
+ public static Object parseBigDecimal(String number, String format)
throws FunctionExecutionException {
Number bigDecimalNum = parseNumberHelper(number, format);
return new BigDecimal(bigDecimalNum.toString());
@@ -1241,24 +1232,16 @@
}
}
- private static Number parseNumberHelper(Object number, Object format)
+ private static Number parseNumberHelper(String number, String format)
throws FunctionExecutionException {
-
- Number num = null;
- if (number == null || format == null) {
- return null;
- }
-
- if (number instanceof String && format instanceof String) {
- try {
- DecimalFormat df= new DecimalFormat((String) format);
- num = df.parse((String) number);
- } catch (java.text.ParseException pe) {
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0043,
QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0043 ,
+ number = number.trim();
+ DecimalFormat df= new DecimalFormat(format);
+ ParsePosition pp = new ParsePosition(0);
+ Number num = df.parse(number, pp);
+ if (num == null || pp.getIndex() < number.length()) {
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0043,
QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0043 ,
number,format));
- }
}
-
return num;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java 2009-07-28
18:53:00 UTC (rev 1198)
+++ trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java 2009-07-28
20:59:49 UTC (rev 1199)
@@ -62,6 +62,7 @@
import com.metamatrix.query.function.FunctionDescriptor;
import com.metamatrix.query.function.FunctionLibrary;
import com.metamatrix.query.function.FunctionLibraryManager;
+import com.metamatrix.query.function.FunctionMethods;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.metadata.SupportConstants;
import com.metamatrix.query.metadata.TempMetadataAdapter;
@@ -1829,19 +1830,17 @@
// Passed all the checks, so build the optimized version
try {
- SimpleDateFormat timestampFormatter = new SimpleDateFormat(dateFormat +
timeFormat);
- java.util.Date parsedTimestamp = timestampFormatter.parse(timestampValue);
-
- Constant dateConstant = new
Constant(TimestampWithTimezone.createDate(parsedTimestamp));
+ Timestamp ts = FunctionMethods.parseTimestamp(timestampValue, dateFormat +
timeFormat);
+ Constant dateConstant = new Constant(TimestampWithTimezone.createDate(ts));
CompareCriteria dateCompare = new
CompareCriteria(formatDateFunction.getArgs()[0], CompareCriteria.EQ, dateConstant);
- Constant timeConstant = new
Constant(TimestampWithTimezone.createTime(parsedTimestamp));
+ Constant timeConstant = new Constant(TimestampWithTimezone.createTime(ts));
CompareCriteria timeCompare = new
CompareCriteria(formatTimeFunction.getArgs()[0], CompareCriteria.EQ, timeConstant);
CompoundCriteria compCrit = new CompoundCriteria(CompoundCriteria.AND,
dateCompare, timeCompare);
return compCrit;
- } catch(ParseException e) {
+ } catch(FunctionExecutionException e) {
return criteria;
}
}
@@ -1983,7 +1982,6 @@
//space(x) => repeat(' ', x)
if (function.getName().equalsIgnoreCase(FunctionLibrary.SPACE)) {
- //change the function into timestampadd
Function result = new Function(SourceSystemFunctions.REPEAT,
new Expression[] {new Constant(" "), function.getArg(0)}); //$NON-NLS-1$
//resolve the function
@@ -1996,7 +1994,6 @@
//from_unixtime(a) => timestampadd(SQL_TSI_SECOND, a, new Timestamp(0))
if (function.getName().equalsIgnoreCase(FunctionLibrary.FROM_UNIXTIME)) {
- //change the function into timestampadd
Function result = new Function(FunctionLibrary.TIMESTAMPADD,
new Expression[] {new Constant(ReservedWords.SQL_TSI_SECOND), function.getArg(0),
new Constant(new Timestamp(0)) });
//resolve the function
@@ -2007,7 +2004,7 @@
return rewriteFunction(result, procCommand, context, metadata);
}
- //rewrite nullif => case when (a = b) then null else a
+ //rewrite nullif(a, b) => case when (a = b) then null else a
if (function.getName().equalsIgnoreCase(FunctionLibrary.NULLIF)) {
List when = Arrays.asList(new Criteria[] {new CompareCriteria(function.getArg(0),
CompareCriteria.EQ, function.getArg(1))});
Constant nullConstant = new Constant(null, function.getType());
Modified: trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java 2009-07-28
18:53:00 UTC (rev 1198)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java 2009-07-28
20:59:49 UTC (rev 1199)
@@ -22,6 +22,8 @@
package com.metamatrix.query.function;
+import static org.junit.Assert.*;
+
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Date;
@@ -30,7 +32,7 @@
import java.util.Calendar;
import java.util.Properties;
-import junit.framework.TestCase;
+import org.junit.Test;
import com.metamatrix.api.exception.query.FunctionExecutionException;
import com.metamatrix.query.sql.ReservedWords;
@@ -38,17 +40,9 @@
import com.metamatrix.query.unittest.TimestampUtil;
import com.metamatrix.query.util.CommandContext;
-public class TestFunction extends TestCase {
+public class TestFunction {
- // ################################## FRAMEWORK ################################
-
- public TestFunction(String name) {
- super(name);
- }
-
- // ################################## TEST HELPERS ################################
-
- private void helpConcat(String s1, String s2, Object expected) throws
FunctionExecutionException {
+ private void helpConcat(String s1, String s2, Object expected) {
Object actual = FunctionMethods.concat(s1, s2);
assertEquals("concat(" + s1 + ", " + s2 + ")
failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
@@ -79,12 +73,12 @@
assertEquals("replace(" + str + "," + sub + "," +
replace + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$ //$NON-NLS-4$
}
- public static void helpSubstring(String str, Integer start, Integer length, Object
expected) throws FunctionExecutionException {
+ public static void helpSubstring(String str, Integer start, Integer length, Object
expected) {
Object actual = FunctionMethods.substring(str, start, length);
assertEquals("substring(" + str + "," + start + ","
+ length + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$ //$NON-NLS-4$
}
- public static void helpSubstring(String str, Integer start, Object expected) throws
FunctionExecutionException {
+ public static void helpSubstring(String str, Integer start, Object expected) {
Object actual = FunctionMethods.substring(str, start);
assertEquals("substring(" + str + "," + start + ")
failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
@@ -132,7 +126,7 @@
assertEquals("Didn't get expected result from translate", expected,
actual); //$NON-NLS-1$
}
- public static void helpTestLocate(String locateString, String input, int
expectedLocation) throws FunctionExecutionException {
+ public static void helpTestLocate(String locateString, String input, int
expectedLocation) {
Integer location = (Integer) FunctionMethods.locate(locateString, input);
int actualLocation = location.intValue();
assertEquals("Didn't get expected result from locate",
expectedLocation, actualLocation); //$NON-NLS-1$
@@ -144,33 +138,33 @@
assertEquals("Didn't get expected result from locate",
expectedLocation, actualLocation); //$NON-NLS-1$
}
- public static void helpTestRound(Integer number, Integer places, Object expected)
throws FunctionExecutionException {
+ public static void helpTestRound(Integer number, Integer places, Object expected) {
Object actual = FunctionMethods.round(number, places);
assertEquals("round(" + number + "," + places + ")
failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public static void helpTestRound(Float number, Integer places, Object expected)
throws FunctionExecutionException {
+ public static void helpTestRound(Float number, Integer places, Object expected) {
Object actual = FunctionMethods.round(number, places);
assertEquals("round(" + number + "," + places + ")
failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public static void helpTestRound(Double number, Integer places, Object expected)
throws FunctionExecutionException {
+ public static void helpTestRound(Double number, Integer places, Object expected) {
Object actual = FunctionMethods.round(number, places);
assertEquals("round(" + number + "," + places + ")
failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public static void helpTestRound(BigDecimal number, Integer places, Object expected)
throws FunctionExecutionException {
+ public static void helpTestRound(BigDecimal number, Integer places, Object expected)
{
Object actual = FunctionMethods.round(number, places);
assertEquals("round(" + number + "," + places + ")
failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public static void helpTestHour1(String timeStr, int expected) throws
FunctionExecutionException {
+ public static void helpTestHour1(String timeStr, int expected) {
Time t = Time.valueOf(timeStr);
Object actual = FunctionMethods.hour(t);
assertEquals("hour(" + t + ") failed", new Integer(expected),
actual); //$NON-NLS-1$ //$NON-NLS-2$
}
- public static void helpTestHour2(String timestampStr, int expected) throws
FunctionExecutionException {
+ public static void helpTestHour2(String timestampStr, int expected) {
Timestamp ts = Timestamp.valueOf(timestampStr);
Object actual = FunctionMethods.hour(ts);
assertEquals("hour(" + ts + ") failed", new
Integer(expected), actual); //$NON-NLS-1$ //$NON-NLS-2$
@@ -182,7 +176,7 @@
expected, actual.toString());
}
- public static void helpTestTimestampDiff(String intervalType, Timestamp timeStamp1,
Timestamp timeStamp2, Long expected) throws FunctionExecutionException {
+ public static void helpTestTimestampDiff(String intervalType, Timestamp timeStamp1,
Timestamp timeStamp2, Long expected) {
Object actual = FunctionMethods.timestampDiff(intervalType, timeStamp1,
timeStamp2);
assertEquals("timestampDiff(" + intervalType + ", " +
timeStamp1 + ", " + timeStamp2 + ") failed", //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
expected, actual);
@@ -194,7 +188,7 @@
expected2, actual2);
}
- public static void helpTestTimestampDiff(String intervalType, Time timeStamp1, Time
timeStamp2, Long expected) throws FunctionExecutionException {
+ public static void helpTestTimestampDiff(String intervalType, Time timeStamp1, Time
timeStamp2, Long expected) {
Object actual = FunctionMethods.timestampDiff(intervalType, timeStamp1,
timeStamp2);
assertEquals("timestampDiff(" + intervalType + ", " +
timeStamp1 + ", " + timeStamp2 + ") failed", //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
expected, actual);
@@ -216,301 +210,301 @@
// ------------------------------ CONCAT ------------------------------
- public void testConcat1() throws FunctionExecutionException {
+ @Test public void testConcat1() throws Exception {
helpConcat("x", "y", "xy"); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
}
- public void testConcat5() throws FunctionExecutionException {
+ @Test public void testConcat5() throws Exception {
helpConcat("", "", ""); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
}
// ------------------------------ TRIM ------------------------------
- public void testTrim3() throws FunctionExecutionException {
+ @Test public void testTrim3() throws Exception {
helpTrim("", true, ""); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testTrim4() throws FunctionExecutionException {
+ @Test public void testTrim4() throws Exception {
helpTrim("", false, ""); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testTrim5() throws FunctionExecutionException {
+ @Test public void testTrim5() throws Exception {
helpTrim("x", true, "x"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testTrim6() throws FunctionExecutionException {
+ @Test public void testTrim6() throws Exception {
helpTrim("x", false, "x"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testTrim7() throws FunctionExecutionException {
+ @Test public void testTrim7() throws Exception {
helpTrim(" x", true, "x"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testTrim8() throws FunctionExecutionException {
+ @Test public void testTrim8() throws Exception {
helpTrim(" x ", true, "x "); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testTrim9() throws FunctionExecutionException {
+ @Test public void testTrim9() throws Exception {
helpTrim("x ", false, "x"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testTrim10() throws FunctionExecutionException {
+ @Test public void testTrim10() throws Exception {
helpTrim(" x x ", false, " x x"); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testTrim11() throws FunctionExecutionException {
+ @Test public void testTrim11() throws Exception {
helpTrim(" ", true, ""); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testTrim12() throws FunctionExecutionException {
+ @Test public void testTrim12() throws Exception {
helpTrim(" ", false, ""); //$NON-NLS-1$ //$NON-NLS-2$
}
// ------------------------------ LEFT ------------------------------
- public void testLeft1() throws FunctionExecutionException {
+ @Test public void testLeft1() throws Exception {
helpLeft("abcd", 0, ""); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testLeft2() throws FunctionExecutionException {
+ @Test public void testLeft2() throws Exception {
helpLeft("abcd", 3, "abc"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testLeft4() throws FunctionExecutionException {
+ @Test public void testLeft4() throws Exception {
helpLeft("", 0, ""); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testLeft5() throws FunctionExecutionException {
+ @Test public void testLeft5() throws Exception {
helpLeft("", 2, ""); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testLeft6() throws FunctionExecutionException {
+ @Test public void testLeft6() throws Exception {
helpLeft("abcd", 5, "abcd"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testLeft7() throws FunctionExecutionException {
+ @Test public void testLeft7() throws Exception {
helpLeft("abcd", 4, "abcd"); //$NON-NLS-1$ //$NON-NLS-2$
}
// ------------------------------ RIGHT ------------------------------
- public void testRight1() throws FunctionExecutionException {
+ @Test public void testRight1() throws Exception {
helpRight("abcd", 0, ""); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRight2() throws FunctionExecutionException {
+ @Test public void testRight2() throws Exception {
helpRight("abcd", 3, "bcd"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRight4() throws FunctionExecutionException {
+ @Test public void testRight4() throws Exception {
helpRight("", 0, ""); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRight5() throws FunctionExecutionException {
+ @Test public void testRight5() throws Exception {
helpRight("", 2, ""); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRight6() throws FunctionExecutionException {
+ @Test public void testRight6() throws Exception {
helpRight("abcd", 5, "abcd"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRight7() throws FunctionExecutionException {
+ @Test public void testRight7() throws Exception {
helpRight("abcd", 4, "abcd"); //$NON-NLS-1$ //$NON-NLS-2$
}
// ------------------------------ SUBSTRING ------------------------------
- public void testSubstring1() throws FunctionExecutionException {
+ @Test public void testSubstring1() throws Exception {
helpSubstring("abc", new Integer(1), new Integer(1), "a");
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testSubstring2() throws FunctionExecutionException {
+ @Test public void testSubstring2() throws Exception {
helpSubstring("abc", new Integer(2), new Integer(2), "bc");
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testSubstring3() throws FunctionExecutionException {
+ @Test public void testSubstring3() throws Exception {
helpSubstring("abc", new Integer(3), new Integer(3), "c");
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testSubstring4() throws FunctionExecutionException {
+ @Test public void testSubstring4() throws Exception {
helpSubstring("abc", new Integer(3), new Integer(0), "");
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testSubstring6() throws FunctionExecutionException {
+ @Test public void testSubstring6() throws Exception {
helpSubstring("abc", new Integer(3), "c"); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testSubstring7() throws FunctionExecutionException {
+ @Test public void testSubstring7() throws Exception {
helpSubstring("abc", new Integer(1), "abc"); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testSubstring8() throws FunctionExecutionException {
+ @Test public void testSubstring8() throws Exception {
helpSubstring("abc", new Integer(-1), "c"); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testSubstring9() throws FunctionExecutionException {
+ @Test public void testSubstring9() throws Exception {
helpSubstring("abc", new Integer(-3), "abc"); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testSubstring10() throws FunctionExecutionException {
+ @Test public void testSubstring10() throws Exception {
helpSubstring("abc", new Integer(-4), null); //$NON-NLS-1$
}
- public void testSubstring11() throws FunctionExecutionException {
+ @Test public void testSubstring11() throws Exception {
helpSubstring("abc", new Integer(-1), new Integer(2), "c");
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testSubstring12() throws FunctionExecutionException {
+ @Test public void testSubstring12() throws Exception {
helpSubstring("abc", new Integer(-3), new Integer(2), "ab");
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testSubstring13() throws FunctionExecutionException {
+ @Test public void testSubstring13() throws Exception {
helpSubstring("abc", new Integer(0), new Integer(2), "ab");
//$NON-NLS-1$ //$NON-NLS-2$
}
// ------------------------------ REPLACE ------------------------------
- public void testReplace1() throws FunctionExecutionException {
+ @Test public void testReplace1() throws Exception {
helpReplace("", "x", "y", "");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testReplace2() throws FunctionExecutionException {
+ @Test public void testReplace2() throws Exception {
helpReplace("", "", "z", "");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testReplace3() throws FunctionExecutionException {
+ @Test public void testReplace3() throws Exception {
helpReplace("x", "x", "y", "y");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testReplace4() throws FunctionExecutionException {
+ @Test public void testReplace4() throws Exception {
helpReplace("xx", "x", "y", "yy");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testReplace5() throws FunctionExecutionException {
+ @Test public void testReplace5() throws Exception {
helpReplace("x x", "x", "y", "y y");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testReplace6() throws FunctionExecutionException {
+ @Test public void testReplace6() throws Exception {
helpReplace("x x", "x", "", " ");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testReplace7() throws FunctionExecutionException {
+ @Test public void testReplace7() throws Exception {
helpReplace("x x", "x", "yz", "yz yz");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testReplace8() throws FunctionExecutionException {
+ @Test public void testReplace8() throws Exception {
helpReplace("xx xx", "xx", "y", "y y");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
// ------------------------------ CONVERT ------------------------------
- public void testConvertStringBoolean1() throws FunctionExecutionException {
+ @Test public void testConvertStringBoolean1() throws Exception {
helpConvert("true", "boolean", Boolean.TRUE); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testConvertStringBoolean2() throws FunctionExecutionException {
+ @Test public void testConvertStringBoolean2() throws Exception {
helpConvert("false", "boolean", Boolean.FALSE); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testConvertStringBoolean3() throws FunctionExecutionException {
+ @Test public void testConvertStringBoolean3() throws Exception {
helpConvert("x", "boolean", Boolean.FALSE); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testConvertStringBoolean4() throws FunctionExecutionException {
+ @Test public void testConvertStringBoolean4() throws Exception {
helpConvert("TrUe", "boolean", Boolean.TRUE); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testConvertStringBoolean5() throws FunctionExecutionException {
+ @Test public void testConvertStringBoolean5() throws Exception {
helpConvert("FAlsE", "boolean", Boolean.FALSE); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testConvertStringChar1() throws FunctionExecutionException {
+ @Test public void testConvertStringChar1() throws Exception {
helpConvert("a", "char", new Character('a'));
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testConvertStringChar2() {
+ @Test public void testConvertStringChar2() throws Exception {
helpConvertFail("xx", "char"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testConvertStringByte1() throws FunctionExecutionException {
+ @Test public void testConvertStringByte1() throws Exception {
helpConvert("5", "byte", new Byte((byte) 5)); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testConvertStringShort1() throws FunctionExecutionException {
+ @Test public void testConvertStringShort1() throws Exception {
helpConvert("5", "short", new Short((short) 5));
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testConvertStringInteger1() throws FunctionExecutionException {
+ @Test public void testConvertStringInteger1() throws Exception {
helpConvert("5", "integer", new Integer(5)); //$NON-NLS-1$
//$NON-NLS-2$
}
// Integer > Integer.MAX_VALUE - should fail
- public void testConvertStringInteger2() {
+ @Test public void testConvertStringInteger2() throws Exception {
helpConvertFail("" + Integer.MAX_VALUE + "1",
"integer"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public void testConvertStringInteger3() {
+ @Test public void testConvertStringInteger3() throws Exception {
helpConvertFail("5.99", "integer"); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testConvertStringLong1() throws FunctionExecutionException {
+ @Test public void testConvertStringLong1() throws Exception {
helpConvert("5", "long", new Long(5)); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testConvertStringBigInteger1() throws FunctionExecutionException {
+ @Test public void testConvertStringBigInteger1() throws Exception {
helpConvert("5", "biginteger", new
BigInteger("5")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public void testConvertStringBigInteger2() throws FunctionExecutionException {
+ @Test public void testConvertStringBigInteger2() throws Exception {
String bigInt = "" + Integer.MAX_VALUE + "111"; //$NON-NLS-1$
//$NON-NLS-2$
helpConvert(bigInt, "biginteger", new BigInteger(bigInt));
//$NON-NLS-1$
}
- public void testConvertStringFloat1() throws FunctionExecutionException {
+ @Test public void testConvertStringFloat1() throws Exception {
helpConvert("5.2", "float", new Float(5.2f)); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testConvertStringDouble1() throws FunctionExecutionException {
+ @Test public void testConvertStringDouble1() throws Exception {
helpConvert("5.2", "double", new Double(5.2d)); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testConvertStringBigDecimal1() throws FunctionExecutionException {
+ @Test public void testConvertStringBigDecimal1() throws Exception {
helpConvert("5.2", "bigdecimal", new
BigDecimal("5.2")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public void testConvertDoubleBigInteger() throws FunctionExecutionException {
+ @Test public void testConvertDoubleBigInteger() throws Exception {
helpConvert(new Double(1.0d), "biginteger", new
BigInteger("1")); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testConvertFloatBigInteger() throws FunctionExecutionException {
+ @Test public void testConvertFloatBigInteger() throws Exception {
helpConvert(new Float(1.0), "biginteger", new
BigInteger("1")); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testConvertBigDecimalBigInteger() throws FunctionExecutionException {
+ @Test public void testConvertBigDecimalBigInteger() throws Exception {
helpConvert(new BigDecimal("1.0"), "biginteger", new
BigInteger("1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public void testConvertDoubleLong() throws FunctionExecutionException {
+ @Test public void testConvertDoubleLong() throws Exception {
helpConvert(new Double(1.0d), "long", new Long("1"));
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testConvertTimestampString() throws FunctionExecutionException {
+ @Test public void testConvertTimestampString() throws Exception {
Timestamp ts = TimestampUtil.createTimestamp(103, 7, 22, 22, 43, 53, 3333333);
helpConvert(ts, "string", "2003-08-22 22:43:53.003333333");
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testAscii1() throws FunctionExecutionException {
+ @Test public void testAscii1() throws Exception {
Integer code = (Integer) FunctionMethods.ascii(new Character(' '));
assertEquals("Didn't get expected code", 32, code.intValue());
//$NON-NLS-1$
}
- public void testAscii2() throws FunctionExecutionException {
+ @Test public void testAscii2() throws Exception {
Integer code = (Integer) FunctionMethods.ascii(" "); //$NON-NLS-1$
assertEquals("Didn't get expected code", 32, code.intValue());
//$NON-NLS-1$
}
- public void testAscii4() {
+ @Test public void testAscii4() throws Exception {
try {
FunctionMethods.ascii(""); //$NON-NLS-1$
fail("Expected function exception"); //$NON-NLS-1$
@@ -518,100 +512,100 @@
}
}
- public void testAscii5() throws FunctionExecutionException {
+ @Test public void testAscii5() throws Exception {
Integer code = (Integer) FunctionMethods.ascii("abc"); //$NON-NLS-1$
assertEquals("Didn't get expected code", 97, code.intValue());
//$NON-NLS-1$
}
- public void testChr1() {
+ @Test public void testChr1() throws Exception {
Character chr = (Character) FunctionMethods.chr(new Integer(32));
assertEquals("Didn't get expected character", ' ',
chr.charValue()); //$NON-NLS-1$
}
- public void testNvl1() {
+ @Test public void testNvl1() throws Exception {
String ret = (String) FunctionMethods.ifnull("x", "y");
//$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Didn't get expected value", "x", ret);
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testNvl2() {
+ @Test public void testNvl2() throws Exception {
String ret = (String) FunctionMethods.ifnull(null, "y"); //$NON-NLS-1$
assertEquals("Didn't get expected value", "y", ret);
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testNvl3() {
+ @Test public void testNvl3() throws Exception {
String ret = (String) FunctionMethods.ifnull(null, null);
assertEquals("Didn't get expected value", null, ret);
//$NON-NLS-1$
}
- public void testInitCap2() throws Exception {
+ @Test public void testInitCap2() throws Exception {
helpTestInitCap("abc", "Abc"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testInitCap3() throws FunctionExecutionException {
+ @Test public void testInitCap3() throws Exception {
helpTestInitCap(" test some\tweird\rspaces\nhere", " Test
Some\tWeird\rSpaces\nHere"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testInitCap4() throws FunctionExecutionException {
+ @Test public void testInitCap4() throws Exception {
helpTestInitCap("x y ", "X Y "); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testInitCap5() throws FunctionExecutionException {
+ @Test public void testInitCap5() throws Exception {
helpTestInitCap("cows are FUN", "Cows Are Fun");
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testLpad1() throws FunctionExecutionException {
+ @Test public void testLpad1() throws Exception {
helpTestLpad("x", 4, " x"); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testLpad3() throws FunctionExecutionException {
+ @Test public void testLpad3() throws Exception {
helpTestLpad("x", 1, "x"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testLpad4() throws FunctionExecutionException {
+ @Test public void testLpad4() throws Exception {
helpTestLpad("xx", 1, "x"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testLpad5() throws FunctionExecutionException {
+ @Test public void testLpad5() throws Exception {
helpTestLpad("", 4, "x", "xxxx"); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
}
- public void testLpad6() throws FunctionExecutionException {
+ @Test public void testLpad6() throws Exception {
helpTestLpad("10", 6, "0", "000010"); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
}
- public void testLpad7() throws FunctionExecutionException {
+ @Test public void testLpad7() throws Exception {
helpTestLpad("x", 4, "yq", "qyqx" ); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
}
- public void testRpad1() throws FunctionExecutionException {
+ @Test public void testRpad1() throws Exception {
helpTestRpad("x", 4, "x "); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRpad3() throws FunctionExecutionException {
+ @Test public void testRpad3() throws Exception {
helpTestRpad("x", 1, "x"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRpad4() throws FunctionExecutionException {
+ @Test public void testRpad4() throws Exception {
helpTestRpad("xx", 1, "x"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRpad5() throws FunctionExecutionException {
+ @Test public void testRpad5() throws Exception {
helpTestRpad("", 4, "x", "xxxx"); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
}
- public void testRpad6() throws FunctionExecutionException {
+ @Test public void testRpad6() throws Exception {
helpTestRpad("10", 6, "0", "100000"); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
}
- public void testTranslate1() throws FunctionExecutionException {
+ @Test public void testTranslate1() throws Exception {
helpTestTranslate("This is my test", "ty", "yt",
"This is mt yesy"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testTranslate2() throws FunctionExecutionException {
+ @Test public void testTranslate2() throws Exception {
helpTestTranslate("", "ty", "yt", "");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testTranslate3() {
+ @Test public void testTranslate3() throws Exception {
try {
FunctionMethods.translate("test", "x", "yz");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
fail("Did not get expected exception on differing src and dest
lengths"); //$NON-NLS-1$
@@ -619,278 +613,278 @@
}
}
- public void testTranslate4() throws FunctionExecutionException {
+ @Test public void testTranslate4() throws Exception {
helpTestTranslate("test", "xy", "ab",
"test"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testLocate1() throws FunctionExecutionException {
+ @Test public void testLocate1() throws Exception {
helpTestLocate(",", "Metamatrix, John Quincy", 11);
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testLocate2() throws FunctionExecutionException {
+ @Test public void testLocate2() throws Exception {
helpTestLocate(" ", "Metamatrix, John Quincy", 12);
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testLocate3() throws FunctionExecutionException {
+ @Test public void testLocate3() throws Exception {
helpTestLocate("x", "xx", 1); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testLocate4() throws FunctionExecutionException {
+ @Test public void testLocate4() throws Exception {
helpTestLocate("y", "xx", 0); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testLocate5() throws Exception {
+ @Test public void testLocate5() throws Exception {
helpTestLocate("b", "abab", 3, 4); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testLocate6() throws Exception {
+ @Test public void testLocate6() throws Exception {
helpTestLocate("z", "abab", 0, 0); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testLocate7() throws Exception {
+ @Test public void testLocate7() throws Exception {
helpTestLocate("z", "abab", null, 0); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testLocate8() throws Exception {
+ @Test public void testLocate8() throws Exception {
helpTestLocate("z", "abab", -1, 0); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testBitand() throws Exception {
+ @Test public void testBitand() throws Exception {
// Both values are integers
Integer result = (Integer) FunctionMethods.bitand(new Integer(0xFFF), new
Integer(0x0F0));
assertNotNull("Result should not be null", result); //$NON-NLS-1$
assertEquals("result should be 0x0F0", 0x0F0, result.intValue());
//$NON-NLS-1$
}
- public void testBitor() throws Exception {
+ @Test public void testBitor() throws Exception {
// Both values are integers
Integer result = (Integer) FunctionMethods.bitor(new Integer(0xFFF), new
Integer(0x0F0));
assertNotNull("Result should not be null", result); //$NON-NLS-1$
assertEquals("result should be 0xFFF", 0xFFF, result.intValue());
//$NON-NLS-1$
}
- public void testBitxor() throws Exception {
+ @Test public void testBitxor() throws Exception {
// Both values are integers
Integer result = (Integer) FunctionMethods.bitxor(new Integer(0xFFF), new
Integer(0x0F0));
assertNotNull("Result should not be null", result); //$NON-NLS-1$
assertEquals("result should be 0xF0F", 0xF0F, result.intValue());
//$NON-NLS-1$
}
- public void testBitnot() {
+ @Test public void testBitnot() throws Exception {
// Both values are integers
Integer result = (Integer) FunctionMethods.bitnot(new Integer(0xF0F));
assertNotNull("Result should not be null", result); //$NON-NLS-1$
assertEquals("result should be 0xFFFFF0F0", 0xFFFFF0F0,
result.intValue()); //$NON-NLS-1$
}
- public void testRoundInteger1() throws FunctionExecutionException {
+ @Test public void testRoundInteger1() throws Exception {
helpTestRound(new Integer(1928), new Integer(0), new Integer(1928));
}
- public void testRoundInteger2() throws FunctionExecutionException {
+ @Test public void testRoundInteger2() throws Exception {
helpTestRound(new Integer(1928), new Integer(-1), new Integer(1930));
}
- public void testRoundInteger3() throws FunctionExecutionException {
+ @Test public void testRoundInteger3() throws Exception {
helpTestRound(new Integer(1928), new Integer(-2), new Integer(1900));
}
- public void testRoundInteger4() throws FunctionExecutionException {
+ @Test public void testRoundInteger4() throws Exception {
helpTestRound(new Integer(1928), new Integer(-3), new Integer(2000));
}
- public void testRoundInteger5() throws FunctionExecutionException {
+ @Test public void testRoundInteger5() throws Exception {
helpTestRound(new Integer(1928), new Integer(-4), new Integer(0));
}
- public void testRoundInteger6() throws FunctionExecutionException {
+ @Test public void testRoundInteger6() throws Exception {
helpTestRound(new Integer(1928), new Integer(-5), new Integer(0));
}
- public void testRoundInteger7() throws FunctionExecutionException {
+ @Test public void testRoundInteger7() throws Exception {
helpTestRound(new Integer(1928), new Integer(1), new Integer(1928));
}
- public void testRoundFloat1() throws FunctionExecutionException {
+ @Test public void testRoundFloat1() throws Exception {
helpTestRound(new Float(123.456F), new Integer(4), new Float(123.456F));
}
- public void testRoundFloat2() throws FunctionExecutionException {
+ @Test public void testRoundFloat2() throws Exception {
helpTestRound(new Float(123.456F), new Integer(3), new Float(123.456F));
}
- public void testRoundFloat3() throws FunctionExecutionException {
+ @Test public void testRoundFloat3() throws Exception {
helpTestRound(new Float(123.456F), new Integer(2), new Float(123.46F));
}
- public void testRoundFloat4() throws FunctionExecutionException {
+ @Test public void testRoundFloat4() throws Exception {
helpTestRound(new Float(123.456F), new Integer(1), new Float(123.5F));
}
- public void testRoundFloat5() throws FunctionExecutionException {
+ @Test public void testRoundFloat5() throws Exception {
helpTestRound(new Float(123.456F), new Integer(0), new Float(123F));
}
- public void testRoundFloat6() throws FunctionExecutionException {
+ @Test public void testRoundFloat6() throws Exception {
helpTestRound(new Float(123.456F), new Integer(-1), new Float(120F));
}
- public void testRoundFloat7() throws FunctionExecutionException {
+ @Test public void testRoundFloat7() throws Exception {
helpTestRound(new Float(123.456F), new Integer(-2), new Float(100F));
}
- public void testRoundFloat8() throws FunctionExecutionException {
+ @Test public void testRoundFloat8() throws Exception {
helpTestRound(new Float(123.456F), new Integer(-3), new Float(0F));
}
- public void testRoundFloat9() throws FunctionExecutionException {
+ @Test public void testRoundFloat9() throws Exception {
helpTestRound(new Float(123.456F), new Integer(-4), new Float(0F));
}
- public void testRoundFloat10() throws FunctionExecutionException {
+ @Test public void testRoundFloat10() throws Exception {
helpTestRound(new Float(123.456F), new Integer(4000), new Float(123.456F));
}
- public void testRoundDouble1() throws FunctionExecutionException {
+ @Test public void testRoundDouble1() throws Exception {
helpTestRound(new Double(123.456), new Integer(4), new Double(123.456));
}
- public void testRoundDouble2() throws FunctionExecutionException {
+ @Test public void testRoundDouble2() throws Exception {
helpTestRound(new Double(123.456), new Integer(3), new Double(123.456));
}
- public void testRoundDouble3() throws FunctionExecutionException {
+ @Test public void testRoundDouble3() throws Exception {
helpTestRound(new Double(123.456), new Integer(2), new Double(123.46));
}
- public void testRoundDouble4() throws FunctionExecutionException {
+ @Test public void testRoundDouble4() throws Exception {
helpTestRound(new Double(123.456), new Integer(1), new Double(123.5));
}
- public void testRoundDouble5() throws FunctionExecutionException {
+ @Test public void testRoundDouble5() throws Exception {
helpTestRound(new Double(123.456), new Integer(0), new Double(123));
}
- public void testRoundDouble6() throws FunctionExecutionException {
+ @Test public void testRoundDouble6() throws Exception {
helpTestRound(new Double(123.456), new Integer(-1), new Double(120));
}
- public void testRoundDouble7() throws FunctionExecutionException {
+ @Test public void testRoundDouble7() throws Exception {
helpTestRound(new Double(123.456), new Integer(-2), new Double(100));
}
- public void testRoundDouble8() throws FunctionExecutionException {
+ @Test public void testRoundDouble8() throws Exception {
helpTestRound(new Double(123.456), new Integer(-3), new Double(0));
}
- public void testRoundDouble9() throws FunctionExecutionException {
+ @Test public void testRoundDouble9() throws Exception {
helpTestRound(new Double(123.456), new Integer(-4), new Double(0));
}
- public void testRoundDouble10() throws FunctionExecutionException {
+ @Test public void testRoundDouble10() throws Exception {
helpTestRound(new Double(-3.5), new Integer(0), new Double(-4));
}
- public void testRoundBigDecimal1() throws FunctionExecutionException {
+ @Test public void testRoundBigDecimal1() throws Exception {
helpTestRound(new BigDecimal("123.456"), new Integer(4), new
BigDecimal("123.456")); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRoundBigDecimal2() throws FunctionExecutionException {
+ @Test public void testRoundBigDecimal2() throws Exception {
helpTestRound(new BigDecimal("123.456"), new Integer(3), new
BigDecimal("123.456")); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRoundBigDecimal3() throws FunctionExecutionException {
+ @Test public void testRoundBigDecimal3() throws Exception {
helpTestRound(new BigDecimal("123.456"), new Integer(2), new
BigDecimal("123.460")); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRoundBigDecimal4() throws FunctionExecutionException {
+ @Test public void testRoundBigDecimal4() throws Exception {
helpTestRound(new BigDecimal("123.456"), new Integer(1), new
BigDecimal("123.500")); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRoundBigDecimal5() throws FunctionExecutionException {
+ @Test public void testRoundBigDecimal5() throws Exception {
helpTestRound(new BigDecimal("123.456"), new Integer(0), new
BigDecimal("123.000")); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRoundBigDecimal6() throws FunctionExecutionException {
+ @Test public void testRoundBigDecimal6() throws Exception {
helpTestRound(new BigDecimal("123.456"), new Integer(-1), new
BigDecimal("120.000")); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRoundBigDecimal7() throws FunctionExecutionException {
+ @Test public void testRoundBigDecimal7() throws Exception {
helpTestRound(new BigDecimal("123.456"), new Integer(-2), new
BigDecimal("100.000")); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRoundBigDecimal8() throws FunctionExecutionException {
+ @Test public void testRoundBigDecimal8() throws Exception {
helpTestRound(new BigDecimal("123.456"), new Integer(-3), new
BigDecimal("0.000")); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRoundBigDecimal9() throws FunctionExecutionException {
+ @Test public void testRoundBigDecimal9() throws Exception {
helpTestRound(new BigDecimal("123.456"), new Integer(-4), new
BigDecimal("0.000")); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testHour1() throws FunctionExecutionException {
+ @Test public void testHour1() throws Exception {
helpTestHour1("00:00:00", 0); //$NON-NLS-1$
}
- public void testHour2() throws FunctionExecutionException {
+ @Test public void testHour2() throws Exception {
helpTestHour1("11:00:00", 11); //$NON-NLS-1$
}
- public void testHour3() throws FunctionExecutionException {
+ @Test public void testHour3() throws Exception {
helpTestHour1("12:00:00", 12); //$NON-NLS-1$
}
- public void testHour4() throws FunctionExecutionException {
+ @Test public void testHour4() throws Exception {
helpTestHour1("13:00:00", 13); //$NON-NLS-1$
}
- public void testHour5() throws FunctionExecutionException {
+ @Test public void testHour5() throws Exception {
helpTestHour1("23:59:59", 23); //$NON-NLS-1$
}
- public void testHour6() throws FunctionExecutionException {
+ @Test public void testHour6() throws Exception {
helpTestHour2("2002-01-01 00:00:00", 0); //$NON-NLS-1$
}
- public void testHour7() throws FunctionExecutionException {
+ @Test public void testHour7() throws Exception {
helpTestHour2("2002-01-01 11:00:00", 11); //$NON-NLS-1$
}
- public void testHour8() throws FunctionExecutionException {
+ @Test public void testHour8() throws Exception {
helpTestHour2("2002-01-01 12:00:00", 12); //$NON-NLS-1$
}
- public void testHour9() throws FunctionExecutionException {
+ @Test public void testHour9() throws Exception {
helpTestHour2("2002-01-01 13:00:00", 13); //$NON-NLS-1$
}
- public void testHour10() throws FunctionExecutionException {
+ @Test public void testHour10() throws Exception {
helpTestHour2("2002-01-01 23:59:59", 23); //$NON-NLS-1$
}
- public void testTimestampCreate1() {
+ @Test public void testTimestampCreate1() throws Exception {
helpTestTimestampCreate(TimestampUtil.createDate(103, 11, 1),
TimestampUtil.createTime(23, 59, 59), "2003-12-01 23:59:59.0"); //$NON-NLS-1$
}
- public void testTimestampAdd1() throws Exception {
+ @Test public void testTimestampAdd1() throws Exception {
assertEquals(TimestampUtil.createDate(103, 11, 4),
FunctionMethods.timestampAdd(ReservedWords.SQL_TSI_DAY, 3, TimestampUtil.createDate(103,
11, 1)));
}
- public void testTimestampAdd2() throws Exception {
+ @Test public void testTimestampAdd2() throws Exception {
assertEquals(TimestampUtil.createTimestamp(103, 11, 1, 18, 20, 30, 0),
FunctionMethods.timestampAdd(ReservedWords.SQL_TSI_HOUR, 3,
TimestampUtil.createTimestamp(103, 11, 1, 15, 20, 30, 0)));
}
- public void testTimestampAdd3() throws Exception {
+ @Test public void testTimestampAdd3() throws Exception {
assertEquals(TimestampUtil.createTime(11, 50, 30),
FunctionMethods.timestampAdd(ReservedWords.SQL_TSI_MINUTE, 90,
TimestampUtil.createTime(10, 20, 30)));
}
- public void testTimestampDiffTimeStamp_FracSec_1() throws FunctionExecutionException
{
+ @Test public void testTimestampDiffTimeStamp_FracSec_1() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35,
1),
TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35,
100000000),
new Long(99999999));
}
- public void testTimestampDiffTimeStamp_FracSec_2() throws FunctionExecutionException
{
+ @Test public void testTimestampDiffTimeStamp_FracSec_2() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
// 1 day (8.64 x 10^10 nanos) and 1 nano
TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35,
2),
@@ -898,7 +892,7 @@
new Long(86400000000001L));
}
- public void testTimestampDiffTimeStamp_FracSec_3() throws FunctionExecutionException
{
+ @Test public void testTimestampDiffTimeStamp_FracSec_3() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
// 1 day (8.64 x 10^10 nanos) less 1 nano
TimestampUtil.createTimestamp((2001-1900), 5, 22, 3, 9, 35,
2),
@@ -906,28 +900,28 @@
new Long(-86399999999999L));
}
- public void testTimestampDiffTimeStamp_FracSec_4() throws FunctionExecutionException
{
+ @Test public void testTimestampDiffTimeStamp_FracSec_4() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
TimestampUtil.createTimestamp((2001-1900), 5, 21, 0, 0, 0,
1),
TimestampUtil.createTimestamp((2001-1900), 5, 21, 0, 0, 0,
3),
new Long(00000002));
}
- public void testTimestampDiffTimeStamp_FracSec_5() throws FunctionExecutionException
{
+ @Test public void testTimestampDiffTimeStamp_FracSec_5() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
TimestampUtil.createTimestamp((2004-1900), 5, 22, 0, 0, 0,
1),
TimestampUtil.createTimestamp((2004-1900), 5, 22, 0, 0, 0,
10),
new Long(9));
}
- public void testTimestampDiffTimeStamp_FracSec_6() throws FunctionExecutionException
{
+ @Test public void testTimestampDiffTimeStamp_FracSec_6() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
TimestampUtil.createTimestamp((2001-1900), 5, 22, 0, 0, 0,
2),
TimestampUtil.createTimestamp((2001-1900), 5, 22, 0, 0, 0,
3),
new Long(1));
}
- public void testTimestampDiffTimeStamp_FracSec_7() throws FunctionExecutionException
{
+ @Test public void testTimestampDiffTimeStamp_FracSec_7() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
// 1 nano diff
TimestampUtil.createTimestamp((2004-1900), 5, 22, 3, 9, 35,
2),
@@ -935,7 +929,7 @@
new Long(1));
}
- public void testTimestampDiffTimeStamp_FracSec_8() throws FunctionExecutionException
{
+ @Test public void testTimestampDiffTimeStamp_FracSec_8() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_FRAC_SECOND,
// 1 nano diff
TimestampUtil.createTimestamp((2004-1900), 5, 22, 3, 9, 35,
3),
@@ -943,105 +937,105 @@
new Long(-1));
}
- public void testTimestampDiffTimeStamp_Min_1() throws FunctionExecutionException {
+ @Test public void testTimestampDiffTimeStamp_Min_1() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_MINUTE,
TimestampUtil.createTimestamp(0, 0, 0, 2, 34, 12, 0),
TimestampUtil.createTimestamp(0, 0, 0, 12, 0, 0, 0),
new Long(565));
}
- public void testTimestampDiffTimeStamp_Min_2() throws FunctionExecutionException {
+ @Test public void testTimestampDiffTimeStamp_Min_2() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_MINUTE,
TimestampUtil.createTimestamp((2001-1900), 0, 0, 2, 0, 0,
0),
TimestampUtil.createTimestamp((2001-1900), 0, 0, 0, 33, 12,
0),
new Long(-86));
}
- public void testTimestampDiffTimeStamp_Min_3() throws FunctionExecutionException {
+ @Test public void testTimestampDiffTimeStamp_Min_3() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_MINUTE,
TimestampUtil.createTimestamp((2001-1900), 8, 26, 12, 07,
58, 65497),
TimestampUtil.createTimestamp((2001-1900), 8, 29, 11, 25,
42, 483219),
new Long(4277));
}
- public void testTimestampDiffTimeStamp_Min_4() throws FunctionExecutionException {
+ @Test public void testTimestampDiffTimeStamp_Min_4() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_MINUTE,
TimestampUtil.createTimestamp((2001-1900), 8, 26, 12, 07,
58, 0),
TimestampUtil.createTimestamp((2001-1900), 8, 29, 11, 25,
42, 0),
new Long(4277));
}
- public void testTimestampDiffTimeStamp_Min_5() throws FunctionExecutionException {
+ @Test public void testTimestampDiffTimeStamp_Min_5() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_MINUTE,
TimestampUtil.createTimestamp((2001-1900), 8, 26, 12, 0, 0,
1),
TimestampUtil.createTimestamp((2001-1900), 8, 26, 12, 0, 0,
0),
new Long(0));
}
- public void testTimestampDiffTimeStamp_Hour_1() throws FunctionExecutionException {
+ @Test public void testTimestampDiffTimeStamp_Hour_1() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_HOUR,
TimestampUtil.createTimestamp((2004-1900), 8, 26, 12, 0, 0,
0),
TimestampUtil.createTimestamp((2004-1900), 8, 26, 12, 59,
59, 999999999),
new Long(0));
}
- public void testTimestampDiffTimeStamp_Week_1() throws FunctionExecutionException {
+ @Test public void testTimestampDiffTimeStamp_Week_1() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_WEEK,
TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35,
100),
TimestampUtil.createTimestamp((2001-1900), 4, 2, 5, 19, 35,
500),
new Long(-7));
}
- public void testTimestampDiffTimeStamp_Month_1() throws FunctionExecutionException {
+ @Test public void testTimestampDiffTimeStamp_Month_1() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_MONTH,
TimestampUtil.createTimestamp((2004-1900), 4, 19, 0, 0, 0,
0),
TimestampUtil.createTimestamp((2004-1900), 11, 20, 12, 0,
0, 0),
new Long(7));
}
- public void testTimestampDiffTimeStamp_Month_2() throws FunctionExecutionException {
+ @Test public void testTimestampDiffTimeStamp_Month_2() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_MONTH,
TimestampUtil.createTimestamp((2004-1900), 5, 1, 0, 0, 0,
1000000),
TimestampUtil.createTimestamp((2004-1900), 11, 1, 12, 0, 0,
1),
new Long(6));
}
- public void testTimestampDiffTimeStamp_Month_3() throws FunctionExecutionException {
+ @Test public void testTimestampDiffTimeStamp_Month_3() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_MONTH,
TimestampUtil.createTimestamp((2004-1900), 4, 19, 0, 0, 0,
1),
TimestampUtil.createTimestamp((2004-1900), 11, 18, 12, 0,
0, 1000000),
new Long(7));
}
- public void testTimestampDiffTimeStamp_Month_4() throws FunctionExecutionException {
+ @Test public void testTimestampDiffTimeStamp_Month_4() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_MONTH,
TimestampUtil.createTimestamp((2004-1900), 4, 1, 0, 0, 0,
1000000),
TimestampUtil.createTimestamp((2004-1900), 11, 1, 0, 0, 0,
0),
new Long(7));
}
- public void testTimestampDiffTimeStamp_Month_5() throws FunctionExecutionException {
+ @Test public void testTimestampDiffTimeStamp_Month_5() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_MONTH,
TimestampUtil.createTimestamp((2004-1900), 4, 1, 0, 0, 1,
0),
TimestampUtil.createTimestamp((2004-1900), 11, 1, 0, 0, 0,
0),
new Long(7));
}
- public void testTimestampDiffTimeStamp_Month_6() throws FunctionExecutionException {
+ @Test public void testTimestampDiffTimeStamp_Month_6() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_MONTH,
TimestampUtil.createTimestamp((2004-1900), 4, 1, 0, 0, 1,
0),
TimestampUtil.createTimestamp((2004-1900), 11, 1, 0, 0, 2,
0),
new Long(7));
}
- public void testTimestampDiffTimeStamp_Day_1() throws FunctionExecutionException {
+ @Test public void testTimestampDiffTimeStamp_Day_1() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_DAY,
TimestampUtil.createTimestamp((2004-1900), 2, 1, 0, 0, 0,
0),
TimestampUtil.createTimestamp((2004-1900), 3, 1, 0, 0, 0,
0),
new Long(31));
}
- public void testTimestampDiffTimeStamp_Day_2() throws FunctionExecutionException {
+ @Test public void testTimestampDiffTimeStamp_Day_2() throws Exception {
// Leap year
helpTestTimestampDiff(ReservedWords.SQL_TSI_DAY,
TimestampUtil.createTimestamp((2004-1900), 1, 1, 0, 0, 0,
0),
@@ -1049,21 +1043,21 @@
new Long(29));
}
- public void testTimestampDiffTime_Hour_1() throws FunctionExecutionException {
+ @Test public void testTimestampDiffTime_Hour_1() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_HOUR,
TimestampUtil.createTime(3, 4, 45),
TimestampUtil.createTime(5, 5, 36),
new Long(2));
}
- public void testTimestampDiffTime_Hour_2() throws FunctionExecutionException {
+ @Test public void testTimestampDiffTime_Hour_2() throws Exception {
helpTestTimestampDiff(ReservedWords.SQL_TSI_HOUR,
TimestampUtil.createTime(5, 0, 30),
TimestampUtil.createTime(3, 0, 31),
new Long(-1));
}
- public void testParseTimestamp1() throws FunctionExecutionException {
+ @Test public void testParseTimestamp1() throws Exception {
helpTestParseTimestamp("1993-04-24 3:59:59 PM", "yyyy-MM-dd
hh:mm:ss aa", "{ts'1993-04-24 15:59:59.0'}"); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
}
@@ -1090,28 +1084,28 @@
* against the system default timezone (not the startTz shown below). The fianl date
value is also being read
* against the default timezone and not the endTz shown.
*/
- public void testModifyTimeZoneGMT() throws Exception {
+ @Test public void testModifyTimeZoneGMT() throws Exception {
helpTestModifyTimeZone("2004-10-03 15:19:59.123456789",
"GMT+00:00", "GMT-01:00", "2004-10-03 16:19:59.123456789");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testModifyTimeZoneGMTPartialHour() throws Exception {
+ @Test public void testModifyTimeZoneGMTPartialHour() throws Exception {
helpTestModifyTimeZone("2004-10-03 15:30:59.123456789",
"GMT+00:00", "GMT-01:45", "2004-10-03 17:15:59.123456789");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testModifyTimeZoneNamedTZ() throws Exception {
+ @Test public void testModifyTimeZoneNamedTZ() throws Exception {
helpTestModifyTimeZone("2004-10-03 15:19:59.123456789",
"America/New_York", "America/Chicago", "2004-10-03
16:19:59.123456789"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testModifyTimeZoneNamedTZ2() throws Exception {
+ @Test public void testModifyTimeZoneNamedTZ2() throws Exception {
helpTestModifyTimeZone("2004-10-03 15:19:59.123456789",
"America/Chicago", "America/New_York", "2004-10-03
14:19:59.123456789"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testModifyTimeZoneStartLocal() throws Exception {
+ @Test public void testModifyTimeZoneStartLocal() throws Exception {
helpTestModifyTimeZone("2004-10-03 15:19:59.123456789",
"America/Chicago", "America/Los_Angeles", "2004-10-03
17:19:59.123456789"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
// case 2458
- public void testCurrentDate() {
+ @Test public void testCurrentDate() throws Exception {
Date curDate = (Date)FunctionMethods.currentDate();
@@ -1126,7 +1120,7 @@
}
// case 2458
- public void testCurrentTime() {
+ @Test public void testCurrentTime() throws Exception {
Time curDate = (Time)FunctionMethods.currentTime();
@@ -1141,7 +1135,7 @@
}
- public void testRand() throws FunctionExecutionException {
+ @Test public void testRand() throws Exception {
Double d = (Double)FunctionMethods.rand(new CommandContext(), new Integer(100));
assertEquals(new Double(0.7220096548596434), d);
@@ -1154,7 +1148,7 @@
FunctionMethods.rand(new CommandContext());
}
- public void testEnv() throws FunctionExecutionException {
+ @Test public void testEnv() throws Exception {
Properties p = new Properties();
String envProperty = "EnvProperty"; //$NON-NLS-1$
String systemProperty = "SystemProperty"; //$NON-NLS-1$
@@ -1173,4 +1167,16 @@
assertEquals(systemProperty+"_lowercase", FunctionMethods.env(context,
systemProperty.toUpperCase())); //$NON-NLS-1$
}
+ @Test(expected=FunctionExecutionException.class) public void testParseIntStrictness()
throws Exception {
+ FunctionMethods.parseInteger("1 a", "#"); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+
+ @Test(expected=FunctionExecutionException.class) public void
testParseDateStrictness() throws Exception {
+ FunctionMethods.parseDate("2007-13-01", "yyyy-MM-dd");
//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testParseTimeWhitespace() throws Exception {
+ assertEquals(TimestampUtil.createTime(15, 0, 0), FunctionMethods.parseTime("
15:00:00 ", "HH:mm:ss")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java 2009-07-28
18:53:00 UTC (rev 1198)
+++
trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java 2009-07-28
20:59:49 UTC (rev 1199)
@@ -22,6 +22,8 @@
package com.metamatrix.query.rewriter;
+import static org.junit.Assert.*;
+
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
@@ -30,7 +32,7 @@
import java.util.Properties;
import java.util.TimeZone;
-import junit.framework.TestCase;
+import org.junit.Test;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixException;
@@ -71,17 +73,11 @@
import com.metamatrix.query.util.CommandContext;
import com.metamatrix.query.util.ContextProperties;
-public class TestQueryRewriter extends TestCase {
+public class TestQueryRewriter {
private static final String TRUE_STR = "1 = 1"; //$NON-NLS-1$
private static final String FALSE_STR = "1 = 0"; //$NON-NLS-1$
- // ################################## FRAMEWORK ################################
-
- public TestQueryRewriter(String name) {
- super(name);
- }
-
// ################################## TEST HELPERS ################################
private Criteria parseCriteria(String critStr, QueryMetadataInterface metadata) {
@@ -182,55 +178,55 @@
return rewriteCommand;
}
- public void testRewriteUnknown() {
+ @Test public void testRewriteUnknown() {
helpTestRewriteCriteria("pm1.g1.e1 = '1' and '1' =
convert(null, string)", "1 = 0"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteUnknown1() {
+ @Test public void testRewriteUnknown1() {
helpTestRewriteCriteria("pm1.g1.e1 = '1' or '1' =
convert(null, string)", "pm1.g1.e1 = '1'"); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testRewriteUnknown2() {
+ @Test public void testRewriteUnknown2() {
helpTestRewriteCriteria("not('1' = convert(null, string))",
"null <> null"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteUnknown3() {
+ @Test public void testRewriteUnknown3() {
helpTestRewriteCriteria("pm1.g1.e1 like convert(null, string))",
"null <> null"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteUnknown4() {
+ @Test public void testRewriteUnknown4() {
helpTestRewriteCriteria("null in ('a', 'b',
'c')", "null <> null"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteUnknown5() {
+ @Test public void testRewriteUnknown5() {
helpTestRewriteCriteria("(null <> null) and 1 = 0", "1 =
0"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteUnknown6() {
+ @Test public void testRewriteUnknown6() {
helpTestRewriteCriteria("not(pm1.g1.e1 = '1' and '1' =
convert(null, string))", "NOT ((pm1.g1.e1 = '1') and (NULL <>
NULL))"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteUnknown7() {
+ @Test public void testRewriteUnknown7() {
helpTestRewriteCriteria("not(pm1.g1.e1 = '1' or '1' =
convert(null, string))", "NOT ((pm1.g1.e1 = '1') or (NULL <>
NULL))"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteUnknown8() {
+ @Test public void testRewriteUnknown8() {
helpTestRewriteCriteria("pm1.g1.e1 in (2, null)", "pm1.g1.e1 =
'2'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteInCriteriaWithRepeats() {
+ @Test public void testRewriteInCriteriaWithRepeats() {
helpTestRewriteCriteria("pm1.g1.e1 in ('1', '1',
'2')", "pm1.g1.e1 IN ('1', '2')"); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testRewriteInCriteriaWithSingleValue() {
+ @Test public void testRewriteInCriteriaWithSingleValue() {
helpTestRewriteCriteria("pm1.g1.e1 in ('1')", "pm1.g1.e1 =
'1'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteInCriteriaWithSingleValue1() {
+ @Test public void testRewriteInCriteriaWithSingleValue1() {
helpTestRewriteCriteria("pm1.g1.e1 not in ('1')",
"pm1.g1.e1 != '1'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteInCriteriaWithNoValues() throws Exception {
+ @Test public void testRewriteInCriteriaWithNoValues() throws Exception {
Criteria crit = new SetCriteria(new ElementSymbol("e1"),
Collections.EMPTY_LIST); //$NON-NLS-1$
Criteria actual = QueryRewriter.rewriteCriteria(crit, null, null, null);
@@ -238,59 +234,59 @@
assertEquals(QueryRewriter.FALSE_CRITERIA, actual);
}
- public void testRewriteBetweenCriteria1() {
+ @Test public void testRewriteBetweenCriteria1() {
helpTestRewriteCriteria("pm1.g1.e1 BETWEEN 1000 AND 2000",
"(pm1.g1.e1 >= '1000') AND (pm1.g1.e1 <= '2000')");
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteBetweenCriteria2() {
+ @Test public void testRewriteBetweenCriteria2() {
helpTestRewriteCriteria("pm1.g1.e1 NOT BETWEEN 1000 AND 2000",
"(pm1.g1.e1 < '1000') OR (pm1.g1.e1 > '2000')");
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCrit1() {
+ @Test public void testRewriteCrit1() {
helpTestRewriteCriteria("concat('a','b') =
'ab'", "1 = 1"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCrit2() {
+ @Test public void testRewriteCrit2() {
helpTestRewriteCriteria("'x' = pm1.g1.e1", "(pm1.g1.e1 =
'x')"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCrit3() {
+ @Test public void testRewriteCrit3() {
helpTestRewriteCriteria("pm1.g1.e1 = convert('a', string)",
"pm1.g1.e1 = 'a'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCrit4() {
+ @Test public void testRewriteCrit4() {
helpTestRewriteCriteria("pm1.g1.e1 = CONVERT('a', string)",
"pm1.g1.e1 = 'a'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCrit5() {
+ @Test public void testRewriteCrit5() {
helpTestRewriteCriteria("pm1.g1.e1 in ('a')", "pm1.g1.e1 =
'a'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCrit6() {
+ @Test public void testRewriteCrit6() {
helpTestRewriteCriteria("1 = convert(pm1.g1.e1,integer) + 10",
"pm1.g1.e1 = '-9'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCrit7() {
+ @Test public void testRewriteCrit7() {
helpTestRewriteCriteria("((pm1.g1.e1 = 1) and (pm1.g1.e1 = 1))",
"pm1.g1.e1 = '1'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteMatchCritEscapeChar1() {
+ @Test public void testRewriteMatchCritEscapeChar1() {
helpTestRewriteCriteria("pm1.g1.e1 LIKE 'x_' ESCAPE
'\\'", "pm1.g1.e1 LIKE 'x_'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteMatchCritEscapeChar2() {
+ @Test public void testRewriteMatchCritEscapeChar2() {
helpTestRewriteCriteria("pm1.g1.e1 LIKE '#%x' ESCAPE
'#'", "pm1.g1.e1 LIKE '#%x' ESCAPE '#'");
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteMatchCritEscapeChar3() {
+ @Test public void testRewriteMatchCritEscapeChar3() {
helpTestRewriteCriteria("pm1.g1.e1 LIKE '#%x'", "pm1.g1.e1
LIKE '#%x'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteMatchCritEscapeChar4() {
+ @Test public void testRewriteMatchCritEscapeChar4() {
helpTestRewriteCriteria("pm1.g1.e1 LIKE pm1.g1.e1 ESCAPE '#'",
"pm1.g1.e1 LIKE pm1.g1.e1 ESCAPE '#'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteMatchCritEscapeChar5() throws Exception {
+ @Test public void testRewriteMatchCritEscapeChar5() throws Exception {
MatchCriteria mcrit = new MatchCriteria(new ElementSymbol("pm1.g1.e1"),
new Constant(null, DataTypeManager.DefaultDataClasses.STRING), '#');
//$NON-NLS-1$
Criteria expected = QueryRewriter.UNKNOWN_CRITERIA;
@@ -298,114 +294,114 @@
assertEquals("Did not get expected rewritten criteria", expected,
actual); //$NON-NLS-1$
}
- public void testRewriteMatchCrit1() {
+ @Test public void testRewriteMatchCrit1() {
helpTestRewriteCriteria("pm1.g1.e1 LIKE 'x' ESCAPE
'\\'", "pm1.g1.e1 = 'x'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteMatchCrit2() {
+ @Test public void testRewriteMatchCrit2() {
helpTestRewriteCriteria("pm1.g1.e1 NOT LIKE 'x'",
"pm1.g1.e1 <> 'x'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteMatchCrit3() {
+ @Test public void testRewriteMatchCrit3() {
helpTestRewriteCriteria("pm1.g1.e1 NOT LIKE '%'", "1 =
0"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCritTimestampCreate1() {
+ @Test public void testRewriteCritTimestampCreate1() {
helpTestRewriteCriteria("timestampCreate(pm3.g1.e2, pm3.g1.e3) =
{ts'2004-11-23 09:25:00'}", "(pm3.g1.e2 = {d'2004-11-23'}) AND
(pm3.g1.e3 = {t'09:25:00'})"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCritTimestampCreate2() {
+ @Test public void testRewriteCritTimestampCreate2() {
helpTestRewriteCriteria("{ts'2004-11-23 09:25:00'} =
timestampCreate(pm3.g1.e2, pm3.g1.e3)", "(pm3.g1.e2 = {d'2004-11-23'})
AND (pm3.g1.e3 = {t'09:25:00'})"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCritSwap1() {
+ @Test public void testRewriteCritSwap1() {
helpTestRewriteCriteria("'x' = pm1.g1.e1", "pm1.g1.e1 =
'x'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCritSwap2() {
+ @Test public void testRewriteCritSwap2() {
helpTestRewriteCriteria("'x' <> pm1.g1.e1",
"pm1.g1.e1 <> 'x'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCritSwap3() {
+ @Test public void testRewriteCritSwap3() {
helpTestRewriteCriteria("'x' < pm1.g1.e1", "pm1.g1.e1
> 'x'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCritSwap4() {
+ @Test public void testRewriteCritSwap4() {
helpTestRewriteCriteria("'x' <= pm1.g1.e1", "pm1.g1.e1
>= 'x'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCritSwap5() {
+ @Test public void testRewriteCritSwap5() {
helpTestRewriteCriteria("'x' > pm1.g1.e1", "pm1.g1.e1
< 'x'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCritSwap6() {
+ @Test public void testRewriteCritSwap6() {
helpTestRewriteCriteria("'x' >= pm1.g1.e1", "pm1.g1.e1
<= 'x'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCritExpr_op1() {
+ @Test public void testRewriteCritExpr_op1() {
helpTestRewriteCriteria("pm1.g1.e2 + 5 = 10", "pm1.g1.e2 =
5"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCritExpr_op2() {
+ @Test public void testRewriteCritExpr_op2() {
helpTestRewriteCriteria("pm1.g1.e2 - 5 = 10", "pm1.g1.e2 =
15"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCritExpr_op3() {
+ @Test public void testRewriteCritExpr_op3() {
helpTestRewriteCriteria("pm1.g1.e2 * 5 = 10", "pm1.g1.e2 =
2"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCritExpr_op4() {
+ @Test public void testRewriteCritExpr_op4() {
helpTestRewriteCriteria("pm1.g1.e2 / 5 = 10", "pm1.g1.e2 =
50"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCritExpr_signFlip1() {
+ @Test public void testRewriteCritExpr_signFlip1() {
helpTestRewriteCriteria("pm1.g1.e2 * -5 > 10", "pm1.g1.e2 <
-2"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCritExpr_signFlip2() {
+ @Test public void testRewriteCritExpr_signFlip2() {
helpTestRewriteCriteria("pm1.g1.e2 * -5 >= 10", "pm1.g1.e2
<= -2"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCritExpr_signFlip3() {
+ @Test public void testRewriteCritExpr_signFlip3() {
helpTestRewriteCriteria("pm1.g1.e2 * -5 < 10", "pm1.g1.e2 >
-2"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCritExpr_signFlip4() {
+ @Test public void testRewriteCritExpr_signFlip4() {
helpTestRewriteCriteria("pm1.g1.e2 * -5 <= 10", "pm1.g1.e2
>= -2"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCritExpr_backwards1() {
+ @Test public void testRewriteCritExpr_backwards1() {
helpTestRewriteCriteria("5 + pm1.g1.e2 <= 10", "pm1.g1.e2 <=
5"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCritExpr_backwards2() {
+ @Test public void testRewriteCritExpr_backwards2() {
helpTestRewriteCriteria("-5 * pm1.g1.e2 <= 10", "pm1.g1.e2
>= -2"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCritExpr_unhandled1() {
+ @Test public void testRewriteCritExpr_unhandled1() {
helpTestRewriteCriteria("5 / pm1.g1.e2 <= 10", "5 / pm1.g1.e2
<= 10"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCritExpr_unhandled2() {
+ @Test public void testRewriteCritExpr_unhandled2() {
helpTestRewriteCriteria("5 - pm1.g1.e2 <= 10", "5 - pm1.g1.e2
<= 10"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCrit_parseDate() {
+ @Test public void testRewriteCrit_parseDate() {
helpTestRewriteCriteria("PARSEDATE(pm3.g1.e1, 'yyyyMMdd') =
{d'2003-05-01'}", //$NON-NLS-1$
"pm3.g1.e1 = '20030501'" );
//$NON-NLS-1$
- }
-
- public void testRewriteCrit_parseDate1() {
+ }
+
+ @Test public void testRewriteCrit_parseDate1() {
helpTestRewriteCriteria("PARSEDATE(pm3.g1.e1, 'yyyyMM') =
{d'2003-05-01'}", //$NON-NLS-1$
"pm3.g1.e1 = '200305'" );
//$NON-NLS-1$
}
- public void testRewriteCrit_parseDate2() {
+ @Test public void testRewriteCrit_parseDate2() {
helpTestRewriteCriteria("PARSEDATE(pm3.g1.e1, 'yyyyMM') =
{d'2003-05-02'}", //$NON-NLS-1$
"1 = 0" ); //$NON-NLS-1$
}
- public void testRewriteCrit_invalidParseDate() {
+ @Test public void testRewriteCrit_invalidParseDate() {
QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
Criteria origCrit = parseCriteria("PARSEDATE(pm3.g1.e1,
'''') = {d'2003-05-01'}", metadata); //$NON-NLS-1$
@@ -417,136 +413,136 @@
}
}
- public void testRewriteCrit_parseTime() {
+ @Test public void testRewriteCrit_parseTime() {
helpTestRewriteCriteria("PARSETIME(pm3.g1.e1, 'HH mm ss') =
{t'13:25:04'}", //$NON-NLS-1$
"pm3.g1.e1 = '13 25 04'" );
//$NON-NLS-1$
}
- public void testRewriteCrit_parseTimestamp() {
+ @Test public void testRewriteCrit_parseTimestamp() {
helpTestRewriteCriteria("PARSETimestamp(pm3.g1.e1, 'yyyy dd mm') =
{ts'2003-05-01 13:25:04.5'}", //$NON-NLS-1$
"1 = 0" ); //$NON-NLS-1$
}
- public void testRewriteCrit_parseTimestamp1() {
+ @Test public void testRewriteCrit_parseTimestamp1() {
helpTestRewriteCriteria("PARSETimestamp(pm3.g1.e1, 'yyyy dd mm') =
{ts'2003-01-01 00:25:00.0'}", //$NON-NLS-1$
"pm3.g1.e1 = '2003 01 25'" );
//$NON-NLS-1$
}
- public void testRewriteCrit_parseTimestamp2() {
+ @Test public void testRewriteCrit_parseTimestamp2() {
helpTestRewriteCriteria("PARSETimestamp(CONVERT(pm3.g1.e2, string),
'yyyy-MM-dd') = {ts'2003-05-01 13:25:04.5'}", //$NON-NLS-1$
"1 = 0" ); //$NON-NLS-1$
}
- public void testRewriteCrit_parseTimestamp3() {
+ @Test public void testRewriteCrit_parseTimestamp3() {
helpTestRewriteCriteria("PARSETimestamp(pm3.g1.e1, 'yyyy dd mm')
<> {ts'2003-05-01 13:25:04.5'}", //$NON-NLS-1$
"1 = 1" ); //$NON-NLS-1$
}
- public void testRewriteCrit_parseTimestamp4() {
+ @Test public void testRewriteCrit_parseTimestamp4() {
helpTestRewriteCriteria("PARSETimestamp(CONVERT(pm3.g1.e2, string),
'yyyy-MM-dd') = {ts'2003-05-01 00:00:00.0'}", //$NON-NLS-1$
"pm3.g1.e2 = {d'2003-05-01'}" );
//$NON-NLS-1$
}
- public void testRewriteCrit_parseTimestamp_notEquality() {
+ @Test public void testRewriteCrit_parseTimestamp_notEquality() {
helpTestRewriteCriteria("PARSETimestamp(pm3.g1.e1, 'yyyy dd mm')
> {ts'2003-05-01 13:25:04.5'}", //$NON-NLS-1$
"PARSETimestamp(pm3.g1.e1, 'yyyy dd mm')
> {ts'2003-05-01 13:25:04.5'}" ); //$NON-NLS-1$
}
- public void testRewriteCrit_parseTimestamp_decompose() {
+ @Test public void testRewriteCrit_parseTimestamp_decompose() {
helpTestRewriteCriteria("PARSETIMESTAMP(CONCAT(FORMATDATE(pm3.g1.e2,
'yyyyMMdd'), FORMATTIME(pm3.g1.e3, 'HHmmss')), 'yyyyMMddHHmmss') =
PARSETIMESTAMP('19690920183045', 'yyyyMMddHHmmss')", //$NON-NLS-1$
"(pm3.g1.e2 = {d'1969-09-20'}) AND (pm3.g1.e3 =
{t'18:30:45'})" ); //$NON-NLS-1$
}
- public void testRewriteCrit_timestampCreate_decompose() {
+ @Test public void testRewriteCrit_timestampCreate_decompose() {
helpTestRewriteCriteria("timestampCreate(pm3.g1.e2, pm3.g1.e3) =
PARSETIMESTAMP('19690920183045', 'yyyyMMddHHmmss')", //$NON-NLS-1$
"(pm3.g1.e2 = {d'1969-09-20'}) AND (pm3.g1.e3 =
{t'18:30:45'})" ); //$NON-NLS-1$
}
- public void testRewriteCrit_parseInteger() {
+ @Test public void testRewriteCrit_parseInteger() {
helpTestRewriteCriteria("parseInteger(pm1.g1.e1, '#,##0') =
1234", //$NON-NLS-1$
"pm1.g1.e1 = '1,234'" );
//$NON-NLS-1$
}
- public void testRewriteCrit_parseLong() {
+ @Test public void testRewriteCrit_parseLong() {
helpTestRewriteCriteria("parseLong(pm1.g1.e1, '#,##0') =
convert(1234, long)", //$NON-NLS-1$
"pm1.g1.e1 = '1,234'" );
//$NON-NLS-1$
}
- public void testRewriteCrit_parseBigInteger() {
+ @Test public void testRewriteCrit_parseBigInteger() {
helpTestRewriteCriteria("parseBigInteger(pm1.g1.e1, '#,##0') =
convert(1234, biginteger)", //$NON-NLS-1$
"pm1.g1.e1 = '1,234'" );
//$NON-NLS-1$
}
- public void testRewriteCrit_parseFloat() {
+ @Test public void testRewriteCrit_parseFloat() {
helpTestRewriteCriteria("parseFloat(pm1.g1.e1, '#,##0.###') =
convert(1234.1234, float)", //$NON-NLS-1$
"pm1.g1.e1 = '1,234.123'" );
//$NON-NLS-1$
}
- public void testRewriteCrit_parseDouble() {
+ @Test public void testRewriteCrit_parseDouble() {
helpTestRewriteCriteria("parseDouble(pm1.g1.e1, '$#,##0.00') =
convert(1234.5, double)", //$NON-NLS-1$
"pm1.g1.e1 = '$1,234.50'" );
//$NON-NLS-1$
}
- public void testRewriteCrit_parseBigDecimal() {
+ @Test public void testRewriteCrit_parseBigDecimal() {
helpTestRewriteCriteria("parseBigDecimal(pm1.g1.e1, '#,##0.###') =
convert(1234.1234, bigdecimal)", //$NON-NLS-1$
"pm1.g1.e1 = '1,234.123'" );
//$NON-NLS-1$
}
- public void testRewriteCrit_formatDate() {
+ @Test public void testRewriteCrit_formatDate() {
helpTestRewriteCriteria("formatDate(pm3.g1.e2, 'yyyyMMdd') =
'20030501'", //$NON-NLS-1$
"pm3.g1.e2 = {d'2003-05-01'}" );
//$NON-NLS-1$
}
- public void testRewriteCrit_formatTime() {
+ @Test public void testRewriteCrit_formatTime() {
helpTestRewriteCriteria("formatTime(pm3.g1.e3, 'HH mm ss') = '13
25 04'", //$NON-NLS-1$
"pm3.g1.e3 = {t'13:25:04'}" );
//$NON-NLS-1$
}
- public void testRewriteCrit_formatTimestamp() {
+ @Test public void testRewriteCrit_formatTimestamp() {
helpTestRewriteCriteria("formatTimestamp(pm3.g1.e4, 'MM dd, yyyy -
HH:mm:ss') = '05 01, 1974 - 07:00:00'", //$NON-NLS-1$
"formatTimestamp(pm3.g1.e4, 'MM dd, yyyy -
HH:mm:ss') = '05 01, 1974 - 07:00:00'" ); //$NON-NLS-1$
}
- public void testRewriteCrit_formatTimestamp1() {
+ @Test public void testRewriteCrit_formatTimestamp1() {
helpTestRewriteCriteria("formatTimestamp(pm3.g1.e4, 'MM dd, yyyy -
HH:mm:ss.S') = '05 01, 1974 - 07:00:00.0'", //$NON-NLS-1$
"pm3.g1.e4 = {ts'1974-05-01
07:00:00.0'}" ); //$NON-NLS-1$
}
- public void testRewriteCrit_formatInteger() {
+ @Test public void testRewriteCrit_formatInteger() {
helpTestRewriteCriteria("formatInteger(pm1.g1.e2, '#,##0') =
'1,234'", //$NON-NLS-1$
"pm1.g1.e2 = 1234" ); //$NON-NLS-1$
}
- public void testRewriteCrit_formatInteger1() {
+ @Test public void testRewriteCrit_formatInteger1() {
helpTestRewriteCriteria("formatInteger(pm1.g1.e2, '#5') =
'105'", //$NON-NLS-1$
"formatInteger(pm1.g1.e2, '#5') =
'105'" ); //$NON-NLS-1$
}
- public void testRewriteCrit_formatLong() {
+ @Test public void testRewriteCrit_formatLong() {
helpTestRewriteCriteria("formatLong(convert(pm1.g1.e2, long),
'#,##0') = '1,234,567,890,123'", //$NON-NLS-1$
"1 = 0" ); //$NON-NLS-1$
}
- public void testRewriteCrit_formatLong1() {
+ @Test public void testRewriteCrit_formatLong1() {
helpTestRewriteCriteria("formatLong(convert(pm1.g1.e2, long),
'#,##0') = '1,234,567,890'", //$NON-NLS-1$
"pm1.g1.e2 = 1234567890" );
//$NON-NLS-1$
}
- public void testRewriteCrit_formatTimestampInvert() {
+ @Test public void testRewriteCrit_formatTimestampInvert() {
String original = "formatTimestamp(pm3.g1.e4, 'MM dd, yyyy -
HH:mm:ss.S') = ?"; //$NON-NLS-1$
String expected = "pm3.g1.e4 = parseTimestamp(?, 'MM dd, yyyy -
HH:mm:ss.S')"; //$NON-NLS-1$
helpTestRewriteCriteria(original, expected);
}
- public void testRewriteCrit_plusInvert() {
+ @Test public void testRewriteCrit_plusInvert() {
String original = "pm1.g1.e2 + 1.1 = ?"; //$NON-NLS-1$
String expected = "pm1.g1.e2 = ? - 1.1"; //$NON-NLS-1$
helpTestRewriteCriteria(original, expected);
}
- public void testRewriteCrit_formatBigInteger() throws Exception {
+ @Test public void testRewriteCrit_formatBigInteger() throws Exception {
String original = "formatBigInteger(convert(pm1.g1.e2, biginteger),
'#,##0') = '1,234,567,890'"; //$NON-NLS-1$
String expected = "pm1.g1.e2 = 1234567890"; //$NON-NLS-1$
@@ -559,7 +555,7 @@
assertEquals("Did not rewrite correctly: ", expectedCrit, actual);
//$NON-NLS-1$
}
- public void testRewriteCrit_formatFloat() throws Exception {
+ @Test public void testRewriteCrit_formatFloat() throws Exception {
String original = "formatFloat(convert(pm1.g1.e4, float),
'#,##0.###') = '1,234.123'"; //$NON-NLS-1$
String expected = "pm1.g1.e4 = 1234.123046875"; //$NON-NLS-1$
@@ -571,7 +567,7 @@
assertEquals("Did not rewrite correctly: ", expected,
actual.toString()); //$NON-NLS-1$
}
- public void testRewriteCrit_formatDouble() throws Exception {
+ @Test public void testRewriteCrit_formatDouble() throws Exception {
String original = "formatDouble(convert(pm1.g1.e4, double),
'$#,##0.00') = '$1,234.50'"; //$NON-NLS-1$
String expected = "pm1.g1.e4 = '1234.5'"; //$NON-NLS-1$
@@ -585,7 +581,7 @@
assertEquals("Did not rewrite correctly: ", expectedCrit, actual);
//$NON-NLS-1$
}
- public void testRewriteCrit_formatBigDecimal() throws Exception {
+ @Test public void testRewriteCrit_formatBigDecimal() throws Exception {
String original = "formatBigDecimal(convert(pm1.g1.e4, bigdecimal),
'#,##0.###') = convert(1234.5, bigdecimal)"; //$NON-NLS-1$
String expected = "pm1.g1.e4 = 1234.5"; //$NON-NLS-1$
@@ -598,207 +594,207 @@
assertEquals("Did not rewrite correctly: ", expectedCrit, actual);
//$NON-NLS-1$
}
- public void testRewriteCritTimestampDiffDate1() {
+ @Test public void testRewriteCritTimestampDiffDate1() {
helpTestRewriteCriteria("timestampdiff(SQL_TSI_DAY, {d'2003-05-15'},
{d'2003-05-17'} ) = 2", TRUE_STR); //$NON-NLS-1$
}
- public void testRewriteCritTimestampDiffDate2() {
+ @Test public void testRewriteCritTimestampDiffDate2() {
helpTestRewriteCriteria("timestampdiff(SQL_TSI_DAY, {d'2003-06-02'},
{d'2003-05-17'} ) = -16", TRUE_STR); //$NON-NLS-1$
}
- public void testRewriteCritTimestampDiffDate3() {
+ @Test public void testRewriteCritTimestampDiffDate3() {
helpTestRewriteCriteria("timestampdiff(SQL_TSI_QUARTER,
{d'2002-01-25'}, {d'2003-06-01'} ) = 5", TRUE_STR); //$NON-NLS-1$
}
- public void testRewriteCritTimestampDiffTime1() {
+ @Test public void testRewriteCritTimestampDiffTime1() {
helpTestRewriteCriteria("timestampdiff(SQL_TSI_HOUR, {t'03:04:45'},
{t'05:05:36'} ) = 2", TRUE_STR); //$NON-NLS-1$
}
- public void testRewriteCritTimestampDiffTime1_ignorecase() {
+ @Test public void testRewriteCritTimestampDiffTime1_ignorecase() {
helpTestRewriteCriteria("timestampdiff(SQL_tsi_HOUR, {t'03:04:45'},
{t'05:05:36'} ) = 2", TRUE_STR); //$NON-NLS-1$
}
- public void testRewriteOr1() {
+ @Test public void testRewriteOr1() {
helpTestRewriteCriteria("(5 = 5) OR (0 = 1)", TRUE_STR); //$NON-NLS-1$
}
- public void testRewriteOr2() {
+ @Test public void testRewriteOr2() {
helpTestRewriteCriteria("(0 = 1) OR (5 = 5)", TRUE_STR); //$NON-NLS-1$
}
- public void testRewriteOr3() {
+ @Test public void testRewriteOr3() {
helpTestRewriteCriteria("(1 = 1) OR (5 = 5)", TRUE_STR); //$NON-NLS-1$
}
- public void testRewriteOr4() {
+ @Test public void testRewriteOr4() {
helpTestRewriteCriteria("(0 = 1) OR (4 = 5)", FALSE_STR);
//$NON-NLS-1$
}
- public void testRewriteOr5() {
+ @Test public void testRewriteOr5() {
helpTestRewriteCriteria("(0 = 1) OR (4 = 5) OR (pm1.g1.e1 =
'x')", "(pm1.g1.e1 = 'x')"); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testRewriteOr6() {
+ @Test public void testRewriteOr6() {
helpTestRewriteCriteria("(0 = 1) OR (4 = 5) OR (pm1.g1.e1 = 'x') OR
(pm1.g1.e1 = 'y')", "(pm1.g1.e1 = 'x') OR (pm1.g1.e1 =
'y')"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteOr7() {
+ @Test public void testRewriteOr7() {
helpTestRewriteCriteria("(pm1.g1.e1 = 'x') OR (pm1.g1.e1 =
'y')", "(pm1.g1.e1 = 'x') OR (pm1.g1.e1 = 'y')");
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteAnd1() {
+ @Test public void testRewriteAnd1() {
helpTestRewriteCriteria("(5 = 5) AND (0 = 1)", FALSE_STR);
//$NON-NLS-1$
}
- public void testRewriteAnd2() {
+ @Test public void testRewriteAnd2() {
helpTestRewriteCriteria("(0 = 1) AND (5 = 5)", FALSE_STR);
//$NON-NLS-1$
}
- public void testRewriteAnd3() {
+ @Test public void testRewriteAnd3() {
helpTestRewriteCriteria("(1 = 1) AND (5 = 5)", TRUE_STR);
//$NON-NLS-1$
}
- public void testRewriteAnd4() {
+ @Test public void testRewriteAnd4() {
helpTestRewriteCriteria("(0 = 1) AND (4 = 5)", FALSE_STR);
//$NON-NLS-1$
}
- public void testRewriteAnd5() {
+ @Test public void testRewriteAnd5() {
helpTestRewriteCriteria("(1 = 1) AND (5 = 5) AND (pm1.g1.e1 =
'x')", "(pm1.g1.e1 = 'x')"); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testRewriteAnd6() {
+ @Test public void testRewriteAnd6() {
helpTestRewriteCriteria("(1 = 1) AND (5 = 5) AND (pm1.g1.e1 = 'x')
and (pm1.g1.e1 = 'y')", "(pm1.g1.e1 = 'x') AND (pm1.g1.e1 =
'y')"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteAnd7() {
+ @Test public void testRewriteAnd7() {
helpTestRewriteCriteria("(pm1.g1.e1 = 'x') AND (pm1.g1.e1 =
'y')", "(pm1.g1.e1 = 'x') AND (pm1.g1.e1 = 'y')");
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteMixed1() {
+ @Test public void testRewriteMixed1() {
helpTestRewriteCriteria("((1=1) AND (1=1)) OR ((1=1) AND (1=1))",
TRUE_STR); //$NON-NLS-1$
}
- public void testRewriteMixed2() {
+ @Test public void testRewriteMixed2() {
helpTestRewriteCriteria("((1=2) AND (1=1)) OR ((1=1) AND (1=1))",
TRUE_STR); //$NON-NLS-1$
}
- public void testRewriteMixed3() {
+ @Test public void testRewriteMixed3() {
helpTestRewriteCriteria("((1=1) AND (1=2)) OR ((1=1) AND (1=1))",
TRUE_STR); //$NON-NLS-1$
}
- public void testRewriteMixed4() {
+ @Test public void testRewriteMixed4() {
helpTestRewriteCriteria("((1=1) AND (1=1)) OR ((1=2) AND (1=1))",
TRUE_STR); //$NON-NLS-1$
}
- public void testRewriteMixed5() {
+ @Test public void testRewriteMixed5() {
helpTestRewriteCriteria("((1=1) AND (1=1)) OR ((1=1) AND (1=2))",
TRUE_STR); //$NON-NLS-1$
}
- public void testRewriteMixed6() {
+ @Test public void testRewriteMixed6() {
helpTestRewriteCriteria("((1=2) AND (1=1)) OR ((1=2) AND (1=1))",
FALSE_STR); //$NON-NLS-1$
}
- public void testRewriteMixed7() {
+ @Test public void testRewriteMixed7() {
helpTestRewriteCriteria("((1=1) AND (1=2)) OR ((1=1) AND (1=2))",
FALSE_STR); //$NON-NLS-1$
}
- public void testRewriteMixed8() {
+ @Test public void testRewriteMixed8() {
helpTestRewriteCriteria("((1=2) AND (1=2)) OR ((1=2) AND (1=2))",
FALSE_STR); //$NON-NLS-1$
}
- public void testRewriteMixed9() {
+ @Test public void testRewriteMixed9() {
helpTestRewriteCriteria("((1=1) OR (1=1)) AND ((1=1) OR (1=1))",
TRUE_STR); //$NON-NLS-1$
}
- public void testRewriteMixed10() {
+ @Test public void testRewriteMixed10() {
helpTestRewriteCriteria("((1=2) OR (1=1)) AND ((1=1) OR (1=1))",
TRUE_STR); //$NON-NLS-1$
}
- public void testRewriteMixed11() {
+ @Test public void testRewriteMixed11() {
helpTestRewriteCriteria("((1=1) OR (1=2)) AND ((1=1) OR (1=1))",
TRUE_STR); //$NON-NLS-1$
}
- public void testRewriteMixed12() {
+ @Test public void testRewriteMixed12() {
helpTestRewriteCriteria("((1=1) OR (1=1)) AND ((1=2) OR (1=1))",
TRUE_STR); //$NON-NLS-1$
}
- public void testRewriteMixed13() {
+ @Test public void testRewriteMixed13() {
helpTestRewriteCriteria("((1=1) OR (1=1)) AND ((1=1) OR (1=2))",
TRUE_STR); //$NON-NLS-1$
}
- public void testRewriteMixed14() {
+ @Test public void testRewriteMixed14() {
helpTestRewriteCriteria("((1=2) OR (1=1)) AND ((1=2) OR (1=1))",
TRUE_STR); //$NON-NLS-1$
}
- public void testRewriteMixed15() {
+ @Test public void testRewriteMixed15() {
helpTestRewriteCriteria("((1=1) OR (1=2)) AND ((1=1) OR (1=2))",
TRUE_STR); //$NON-NLS-1$
}
- public void testRewriteMixed16() {
+ @Test public void testRewriteMixed16() {
helpTestRewriteCriteria("((1=2) OR (1=2)) AND ((1=2) OR (1=2))",
FALSE_STR); //$NON-NLS-1$
}
- public void testRewriteNot1() {
+ @Test public void testRewriteNot1() {
helpTestRewriteCriteria("NOT (1=1)", FALSE_STR); //$NON-NLS-1$
}
- public void testRewriteNot2() {
+ @Test public void testRewriteNot2() {
helpTestRewriteCriteria("NOT (1=2)", TRUE_STR); //$NON-NLS-1$
}
- public void testRewriteNot3() {
+ @Test public void testRewriteNot3() {
helpTestRewriteCriteria("NOT (pm1.g1.e1='x')", "NOT
(pm1.g1.e1 = 'x')"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteDefect1() {
+ @Test public void testRewriteDefect1() {
helpTestRewriteCriteria("(('DE' = 'LN') AND (null >
'2002-01-01')) OR (('DE' = 'DE') AND (pm1.g1.e1 >
'9000000'))", "(pm1.g1.e1 > '9000000')");
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteQueryCriteriaAlwaysTrue() {
+ @Test public void testRewriteQueryCriteriaAlwaysTrue() {
helpTestRewriteCommand("SELECT e1 FROM pm1.g1 WHERE 0 = 0",
//$NON-NLS-1$
"SELECT e1 FROM pm1.g1"); //$NON-NLS-1$
}
- public void testSubquery1() {
+ @Test public void testSubquery1() {
helpTestRewriteCommand("SELECT e1 FROM (SELECT e1 FROM pm1.g1 WHERE (1 - 1)
= (0 + 0)) AS x", //$NON-NLS-1$
"SELECT e1 FROM (SELECT e1 FROM pm1.g1) AS x");
//$NON-NLS-1$
}
- public void testExistsSubquery() {
+ @Test public void testExistsSubquery() {
helpTestRewriteCommand("SELECT e1 FROM pm1.g1 WHERE EXISTS (SELECT e1 FROM
pm1.g2)", //$NON-NLS-1$
"SELECT e1 FROM pm1.g1 WHERE EXISTS (SELECT e1 FROM
pm1.g2)"); //$NON-NLS-1$
}
- public void testCompareSubqueryANY() {
+ @Test public void testCompareSubqueryANY() {
helpTestRewriteCommand("SELECT e1 FROM pm1.g1 WHERE '3' = ANY
(SELECT e1 FROM pm1.g2)", //$NON-NLS-1$
"SELECT e1 FROM pm1.g1 WHERE '3' = SOME
(SELECT e1 FROM pm1.g2)"); //$NON-NLS-1$
}
- public void testCompareSubquery() {
+ @Test public void testCompareSubquery() {
helpTestRewriteCommand("SELECT e1 FROM pm1.g1 WHERE '3' = SOME
(SELECT e1 FROM pm1.g2)", //$NON-NLS-1$
"SELECT e1 FROM pm1.g1 WHERE '3' = SOME
(SELECT e1 FROM pm1.g2)"); //$NON-NLS-1$
}
- public void testCompareSubqueryUnknown() {
+ @Test public void testCompareSubqueryUnknown() {
helpTestRewriteCommand("SELECT e1 FROM pm1.g1 WHERE null = SOME (SELECT e1
FROM pm1.g2)", //$NON-NLS-1$
"SELECT e1 FROM pm1.g1 WHERE null <>
null"); //$NON-NLS-1$
}
- public void testINClauseSubquery() {
+ @Test public void testINClauseSubquery() {
helpTestRewriteCommand("SELECT e1 FROM pm1.g1 WHERE '3' IN (SELECT
e1 FROM pm1.g2)", //$NON-NLS-1$
"SELECT e1 FROM pm1.g1 WHERE '3' IN (SELECT
e1 FROM pm1.g2)"); //$NON-NLS-1$
}
- public void testRewriteXMLCriteria1() {
+ @Test public void testRewriteXMLCriteria1() {
helpTestRewriteCriteria("context(pm1.g1.e1, pm1.g1.e1) = convert(5,
string)", "context(pm1.g1.e1, pm1.g1.e1) = '5'"); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testRewriteXMLCriteria2() {
+ @Test public void testRewriteXMLCriteria2() {
helpTestRewriteCriteria("context(pm1.g1.e1, convert(5, string)) = 2+3",
"context(pm1.g1.e1, '5') = '5'"); //$NON-NLS-1$ //$NON-NLS-2$
}
// HAS Criteria
- public void testRewriteProcedure1() {
+ @Test public void testRewriteProcedure1() {
String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
@@ -821,7 +817,7 @@
}
// HAS Criteria
- public void testRewriteProcedure2() {
+ @Test public void testRewriteProcedure2() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
@@ -849,7 +845,7 @@
}
// HAS Criteria
- public void testRewriteProcedure3() {
+ @Test public void testRewriteProcedure3() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
@@ -876,7 +872,7 @@
assertEquals("Rewritten command was not expected", rewritProc,
procReturned); //$NON-NLS-1$
}
- public void testRewriteProcedure4() {
+ @Test public void testRewriteProcedure4() {
String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
@@ -900,7 +896,7 @@
}
// CHANGING
- public void testRewriteProcedure5() {
+ @Test public void testRewriteProcedure5() {
String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
@@ -923,7 +919,7 @@
}
// CHANGING
- public void testRewriteProcedure6() {
+ @Test public void testRewriteProcedure6() {
String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
@@ -945,7 +941,7 @@
}
// TRANSLATE CRITERIA
- public void testRewriteProcedure7() {
+ @Test public void testRewriteProcedure7() {
String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
@@ -969,7 +965,7 @@
}
// TRANSLATE CRITERIA
- public void testRewriteProcedure8() {
+ @Test public void testRewriteProcedure8() {
String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
@@ -993,7 +989,7 @@
}
// rewrite input/ changing variables
- public void testRewriteProcedure9() {
+ @Test public void testRewriteProcedure9() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "Declare String var1;\n"; //$NON-NLS-1$
@@ -1021,7 +1017,7 @@
}
// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
- public void testRewriteProcedure10() {
+ @Test public void testRewriteProcedure10() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1043,7 +1039,7 @@
}
// virtual group elements used in procedure in if statement(HAS CRITERIA)
- public void testRewriteProcedure11() {
+ @Test public void testRewriteProcedure11() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE string var1;\n"; //$NON-NLS-1$
@@ -1066,7 +1062,7 @@
// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
// with complex query transform
- public void testRewriteProcedure12() {
+ @Test public void testRewriteProcedure12() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1089,7 +1085,7 @@
// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
// with complex query transform
- public void testRewriteProcedure13() {
+ @Test public void testRewriteProcedure13() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1111,7 +1107,7 @@
}
// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
- public void testRewriteProcedure14() {
+ @Test public void testRewriteProcedure14() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1133,7 +1129,7 @@
}
// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
- public void testRewriteProcedure15() {
+ @Test public void testRewriteProcedure15() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1155,7 +1151,7 @@
}
// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
- public void testRewriteProcedure16() {
+ @Test public void testRewriteProcedure16() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1177,7 +1173,7 @@
}
// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
- public void testRewriteProcedure17() {
+ @Test public void testRewriteProcedure17() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1199,7 +1195,7 @@
}
// Bug 8212 elements in INPUT and CHANGING special groups are cese sensitive
- public void testRewriteProcedure18() {
+ @Test public void testRewriteProcedure18() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "Select Input.E1, Input.e2, CHANGING.e2, CHANGING.E1
from pm1.g1;\n"; //$NON-NLS-1$
@@ -1220,7 +1216,7 @@
// elements being set in updates are dropped if INPUT var is not available, unless a
default is available
// Note that this test is a little odd in that it is an update inside of an insert
- public void testRewriteProcedure19() {
+ @Test public void testRewriteProcedure19() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "update pm1.g1 set e1=Input.E1, e2=Input.e2,
e3=Input.e3;\n"; //$NON-NLS-1$
@@ -1242,7 +1238,7 @@
// elements being set in updates are dropped if INPUT var is not available, unless a
default is supplied
//this test fails because the default for E1 'xyz' cannot be converted into a
integer
- public void testRewriteProcedure21() {
+ @Test public void testRewriteProcedure21() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "update pm1.g1 set e1=convert(Input.E1,
integer)+INPUT.E2, e2=Input.e2, e3=Input.e3;\n"; //$NON-NLS-1$
@@ -1258,7 +1254,7 @@
this.helpFailUpdateProcedure(procedure, userQuery,
FakeMetadataObject.Props.INSERT_PROCEDURE);
}
- public void testRewriteProcedure21a() {
+ @Test public void testRewriteProcedure21a() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "update pm1.g1 set e1=convert(Input.E1,
integer)+INPUT.E2, e2=Input.e2, e3=Input.e3;\n"; //$NON-NLS-1$
@@ -1279,7 +1275,7 @@
// none of input variables on update statement changing
- public void testRewriteProcedure22() {
+ @Test public void testRewriteProcedure22() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "update pm1.g1 set e1=convert(Input.E1,
integer)+INPUT.E2, e2=Input.e2;\n"; //$NON-NLS-1$
@@ -1298,7 +1294,7 @@
}
// none of input variables on update statement changing
- public void testRewriteProcedure23() {
+ @Test public void testRewriteProcedure23() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "update pm1.g1 set e2=Input.e2,
e3=Input.e3;\n"; //$NON-NLS-1$
@@ -1317,7 +1313,7 @@
}
//with an insert, defaults are used
- public void testRewriteProcedure23a() {
+ @Test public void testRewriteProcedure23a() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "update pm1.g1 set e2=Input.e2,
e3=Input.e3;\n"; //$NON-NLS-1$
@@ -1337,7 +1333,7 @@
}
// elements being set in updates are dropped if INPUT var is not available
- public void testRewriteProcedure24() {
+ @Test public void testRewriteProcedure24() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "UPDATE pm1.g1 SET e2=Input.e2 WHERE TRANSLATE LIKE
CRITERIA ON (e1) WITH (e1=concat(pm1.g1.e1, \"%\"));\n"; //$NON-NLS-1$
@@ -1357,7 +1353,7 @@
}
// INPUT vars in insert statements replaced by default variable when user's inser
ignores values
- public void testRewriteProcedure25() {
+ @Test public void testRewriteProcedure25() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "INSERT into pm1.g1 (e1,e2,e3,e4) values (Input.e1,
Input.e2, Input.e3, Input.e4);"; //$NON-NLS-1$
@@ -1377,7 +1373,7 @@
}
// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
- public void testRewriteProcedure26() {
+ @Test public void testRewriteProcedure26() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1399,7 +1395,7 @@
}
// virtual group elements used in procedure in if statement(TRANSLATE CRITERIA)
- public void testRewriteProcedure27() {
+ @Test public void testRewriteProcedure27() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -1430,7 +1426,7 @@
* descriptor couldn't be found for the "minus" operation for the two
types
* integer and MetaMatrix's null type.
*/
- public void testRewriteProcedure_9380() {
+ @Test public void testRewriteProcedure_9380() {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
@@ -1457,29 +1453,29 @@
}
//base test. no change is expected
- public void testRewriteLookupFunction1() {
+ @Test public void testRewriteLookupFunction1() {
String criteria = "lookup('pm1.g1','e1', 'e2', 1) =
'ab'"; //$NON-NLS-1$
CompareCriteria expected = (CompareCriteria)parseCriteria(criteria,
FakeMetadataFactory.example1Cached());
helpTestRewriteCriteria(criteria, expected,
FakeMetadataFactory.example1Cached());
}
- public void testRewriteLookupFunction1b() {
+ @Test public void testRewriteLookupFunction1b() {
helpTestRewriteCriteria("lookup('pm1.g1','e1', 'e2',
pm1.g1.e2) = 'ab'", "lookup('pm1.g1','e1', 'e2',
pm1.g1.e2) = 'ab'"); //$NON-NLS-1$ //$NON-NLS-2$
}
/** defect 11630 1 should still get rewritten as '1'*/
- public void testRewriteLookupFunctionCompoundCriteria() {
+ @Test public void testRewriteLookupFunctionCompoundCriteria() {
String criteria = "LOOKUP('pm1.g1','e1', 'e2', 1) IS
NULL AND pm1.g1.e1='1'"; //$NON-NLS-1$
CompoundCriteria expected = (CompoundCriteria)parseCriteria(criteria,
FakeMetadataFactory.example1Cached());
helpTestRewriteCriteria("LOOKUP('pm1.g1','e1', 'e2',
1) IS NULL AND pm1.g1.e1=1", expected, FakeMetadataFactory.example1Cached());
//$NON-NLS-1$
}
- public void testSelectWithNoFrom() {
+ @Test public void testSelectWithNoFrom() {
helpTestRewriteCommand("SELECT 5", "SELECT 5"); //$NON-NLS-1$
//$NON-NLS-2$
}
//defect 9822
- public void testStoredProcedure_9822() throws Exception {
+ @Test public void testStoredProcedure_9822() throws Exception {
QueryParser parser = new QueryParser();
Command command = parser.parseCommand("exec pm1.sp4(5)");
//$NON-NLS-1$
@@ -1501,7 +1497,7 @@
}
}
- public void testRewriteRecursive() {
+ @Test public void testRewriteRecursive() {
Command c = helpTestRewriteCommand("SELECT e2 FROM vm1.g33",
"SELECT e2 FROM vm1.g33"); //$NON-NLS-1$ //$NON-NLS-2$
Command innerCommand = (Command) c.getSubCommands().get(0);
@@ -1509,7 +1505,7 @@
}
- public void testRewriteFunctionThrowsEvaluationError() {
+ @Test public void testRewriteFunctionThrowsEvaluationError() {
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
Criteria origCrit = parseCriteria("5 / 0 = 5", metadata);
//$NON-NLS-1$
@@ -1523,7 +1519,7 @@
}
}
- public void testRewriteConvertThrowsEvaluationError() {
+ @Test public void testRewriteConvertThrowsEvaluationError() {
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
Criteria origCrit = parseCriteria("convert('x', integer) = 0",
metadata); //$NON-NLS-1$
@@ -1536,7 +1532,7 @@
}
}
- public void testDefect13458() {
+ @Test public void testDefect13458() {
String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
@@ -1558,15 +1554,15 @@
assertEquals("Rewritten command was not expected", rewritProc,
procReturned); //$NON-NLS-1$
}
- public void testRewriteCase1954() {
+ @Test public void testRewriteCase1954() {
helpTestRewriteCriteria("convert(pm1.g1.e2, string) = '3'",
"pm1.g1.e2 = 3"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCase1954a() {
+ @Test public void testRewriteCase1954a() {
helpTestRewriteCriteria("cast(pm1.g1.e2 as string) = '3'",
"pm1.g1.e2 = 3"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCase1954b() throws Exception{
+ @Test public void testRewriteCase1954b() throws Exception{
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
// Have to hand-build the criteria, because 3.0 gets parsed as a Float by
default
@@ -1582,143 +1578,143 @@
helpTestRewriteCriteria("convert(pm1.g1.e4, string) = '3'",
expected, metadata); //$NON-NLS-1$
}
- public void testRewriteCase1954c() {
+ @Test public void testRewriteCase1954c() {
helpTestRewriteCriteria("convert(pm1.g1.e1, string) = 'x'",
"pm1.g1.e1 = 'x'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCase1954d() {
+ @Test public void testRewriteCase1954d() {
helpTestRewriteCriteria("convert(pm1.g1.e1, timestamp) = {ts '2005-01-03
00:00:00.0'}", "pm1.g1.e1 = '2005-01-03 00:00:00.0'");
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCase1954e() {
+ @Test public void testRewriteCase1954e() {
helpTestRewriteCriteria("convert(pm1.g1.e4, integer) = 2",
"pm1.g1.e4 = 2.0"); //$NON-NLS-1$ //$NON-NLS-2$
}
/** Check that this fails, x is not convertable to an int */
- public void testRewriteCase1954f() {
+ @Test public void testRewriteCase1954f() {
helpTestRewriteCriteria("convert(pm1.g1.e2, string) = 'x'",
"1 = 0"); //$NON-NLS-1$ //$NON-NLS-2$
}
/** Check that this returns true, x is not convertable to an int */
- public void testRewriteCase1954f1() {
+ @Test public void testRewriteCase1954f1() {
helpTestRewriteCriteria("convert(pm1.g1.e2, string) != 'x'",
"1 = 1"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCase1954Set() {
+ @Test public void testRewriteCase1954Set() {
helpTestRewriteCriteria("convert(pm1.g1.e2, string) in ('2',
'3')", "pm1.g1.e2 IN (2,3)"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCase1954SetA() {
+ @Test public void testRewriteCase1954SetA() {
helpTestRewriteCriteria("convert(pm1.g1.e2, string) in ('2',
'x')", "pm1.g1.e2 = 2"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCase1954SetB() {
+ @Test public void testRewriteCase1954SetB() {
helpTestRewriteCriteria("cast(pm1.g1.e2 as string) in ('2',
'3')", "pm1.g1.e2 IN (2,3)"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCase1954SetC() {
+ @Test public void testRewriteCase1954SetC() {
helpTestRewriteCriteria("concat(pm1.g1.e2, 'string') in
('2', '3')", "concat(pm1.g1.e2, 'string') in
('2', '3')"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCase1954SetD() {
+ @Test public void testRewriteCase1954SetD() {
helpTestRewriteCriteria("convert(pm1.g1.e2, string) in ('2',
pm1.g1.e1)", "convert(pm1.g1.e2, string) in ('2', pm1.g1.e1)");
//$NON-NLS-1$ //$NON-NLS-2$
}
// First WHEN always true, so rewrite as THEN expression
- public void testRewriteCaseExpr1() {
+ @Test public void testRewriteCaseExpr1() {
helpTestRewriteCriteria("case when 0=0 then 1 else 2 end = 1", "1
= 1"); //$NON-NLS-1$ //$NON-NLS-2$
}
// First WHEN always false, so rewrite as ELSE expression
- public void testRewriteCaseExpr2() {
+ @Test public void testRewriteCaseExpr2() {
helpTestRewriteCriteria("case when 0=1 then 1 else 2 end = 1", "1
= 0"); //$NON-NLS-1$ //$NON-NLS-2$
}
// First WHEN can't be rewritten, so no changes
- public void testRewriteCaseExpr3() {
+ @Test public void testRewriteCaseExpr3() {
helpTestRewriteCriteria("case when 0 = pm1.g1.e2 then 1 else 2 end =
1", "CASE WHEN pm1.g1.e2 = 0 THEN 1 ELSE 2 END = 1"); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testRewriteCaseExpr4() {
+ @Test public void testRewriteCaseExpr4() {
helpTestRewriteCriteria("lookup('pm1.g1', 'e2',
'e1', case when 1=1 then pm1.g1.e1 end) = 0", "lookup('pm1.g1',
'e2', 'e1', pm1.g1.e1) = 0"); //$NON-NLS-1$ //$NON-NLS-2$
}
// First WHEN always false, so remove it
- public void testRewriteCaseExpr5() {
+ @Test public void testRewriteCaseExpr5() {
helpTestRewriteCriteria("case when 0=1 then 1 when 0 = pm1.g1.e2 then 2 else
3 end = 1", "CASE WHEN pm1.g1.e2 = 0 THEN 2 ELSE 3 END = 1"); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testRewriteCaseExprForCase5413aFrom502() {
+ @Test public void testRewriteCaseExprForCase5413aFrom502() {
helpTestRewriteCriteria("pm1.g2.e1 = case when 0 = pm1.g1.e2 then 2 else 2
end", "pm1.g2.e1 = '2'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCaseExprForCase5413bFrom502() {
+ @Test public void testRewriteCaseExprForCase5413bFrom502() {
helpTestRewriteCriteria("case when 0 = pm1.g1.e2 then null else null end IS
NULL", TRUE_STR); //$NON-NLS-1$
}
- public void testRewriteCaseExprForCase5413a() {
+ @Test public void testRewriteCaseExprForCase5413a() {
helpTestRewriteCriteria("pm1.g2.e1 = case when 0 = pm1.g1.e2 then 2 else 2
end", "pm1.g2.e1 = '2'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCaseExprForCase5413b() {
+ @Test public void testRewriteCaseExprForCase5413b() {
helpTestRewriteCriteria("case when 0 = pm1.g1.e2 then null else null end IS
NULL", TRUE_STR); //$NON-NLS-1$
}
// First WHEN always true, so rewrite as THEN expression
- public void testRewriteSearchedCaseExpr1() {
+ @Test public void testRewriteSearchedCaseExpr1() {
helpTestRewriteCriteria("case 0 when 0 then 1 else 2 end = 1", "1
= 1"); //$NON-NLS-1$ //$NON-NLS-2$
}
// First WHEN always false, so rewrite as ELSE expression
- public void testRewriteSearchedCaseExpr2() {
+ @Test public void testRewriteSearchedCaseExpr2() {
helpTestRewriteCriteria("case 0 when 1 then 1 else 2 end = 1", "1
= 0"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteSearchedCaseExpr3() {
+ @Test public void testRewriteSearchedCaseExpr3() {
helpTestRewriteCriteria("case 0 when pm1.g1.e2 then 1 else 2 end = 1",
"CASE WHEN pm1.g1.e2 = 0 THEN 1 ELSE 2 END = 1"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteSearchedCaseExpr4() {
+ @Test public void testRewriteSearchedCaseExpr4() {
String criteria = "lookup('pm1.g1', 'e2', 'e1',
'2') = 0"; //$NON-NLS-1$
CompareCriteria expected = (CompareCriteria)parseCriteria(criteria,
FakeMetadataFactory.example1Cached());
helpTestRewriteCriteria("lookup('pm1.g1', 'e2',
'e1', case 0 when 1 then pm1.g1.e1 else 2 end) = 0", expected,
FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
}
// First WHEN always false, so remove it
- public void testRewriteSearchedCaseExpr5() {
+ @Test public void testRewriteSearchedCaseExpr5() {
helpTestRewriteCriteria("case 0 when 1 then 1 when pm1.g1.e2 then 2 else 3
end = 1", "CASE WHEN pm1.g1.e2 = 0 THEN 2 ELSE 3 END = 1"); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testDefect16879_1(){
+ @Test public void testDefect16879_1(){
helpTestRewriteCommand("SELECT decodestring(e1, 'a, b') FROM
pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' ELSE e1 END FROM
pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testDefect16879_2(){
+ @Test public void testDefect16879_2(){
helpTestRewriteCommand("SELECT decodestring(e1, 'a, b, c, d') FROM
pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' WHEN e1 =
'c' THEN 'd' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testDefect16879_3(){
+ @Test public void testDefect16879_3(){
helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b') FROM
pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' ELSE e1 END FROM
pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testDefect16879_4(){
+ @Test public void testDefect16879_4(){
helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, c, d') FROM
pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' WHEN e1 =
'c' THEN 'd' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testDefect16879_5(){
+ @Test public void testDefect16879_5(){
helpTestRewriteCommand("SELECT decodeinteger(e1, 'null, b, c, d')
FROM pm1.g1", "SELECT CASE WHEN e1 IS NULL THEN 'b' WHEN e1 =
'c' THEN 'd' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testDefect16879_6(){
+ @Test public void testDefect16879_6(){
helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, null, d')
FROM pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' WHEN e1 IS
NULL THEN 'd' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testDefect16879_7(){
+ @Test public void testDefect16879_7(){
helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, null, d, e')
FROM pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' WHEN e1 IS
NULL THEN 'd' ELSE 'e' END FROM pm1.g1"); //$NON-NLS-1$
//$NON-NLS-2$
}
- public void testCaseExpressionThatResolvesToNull() {
+ @Test public void testCaseExpressionThatResolvesToNull() {
String sqlBefore = "SELECT CASE 'x' WHEN 'Old Inventory
System' THEN NULL WHEN 'New Inventory System' THEN NULL END";
//$NON-NLS-1$
String sqlAfter = "SELECT null"; //$NON-NLS-1$
@@ -1730,7 +1726,7 @@
//note that the env is now treated as deterministic, however it is really only
deterministic within a session
- public void testRewriteExecEnv() throws Exception {
+ @Test public void testRewriteExecEnv() throws Exception {
Command command = QueryParser.getQueryParser().parseCommand("exec
pm1.sq2(env('sessionid'))"); //$NON-NLS-1$
QueryResolver.resolveCommand(command, FakeMetadataFactory.example1Cached());
@@ -1744,7 +1740,7 @@
assertEquals("SELECT e1, e2 FROM pm1.g1 WHERE e1 = '1'",
rewriteCommand.toString()); //$NON-NLS-1$
}
- public void testRewriteExecCase6455() throws Exception {
+ @Test public void testRewriteExecCase6455() throws Exception {
Command command = QueryParser.getQueryParser().parseCommand("exec
pm1.sq2(env('sessionid')) OPTION PLANONLY DEBUG"); //$NON-NLS-1$
QueryResolver.resolveCommand(command, FakeMetadataFactory.example1Cached());
@@ -1759,23 +1755,23 @@
}
- public void testRewriteNestedFunctions() {
+ @Test public void testRewriteNestedFunctions() {
helpTestRewriteCommand("SELECT e1 FROM pm1.g1 where convert(parsedate(e1,
'yyyy-MM-dd'), string) = '2006-07-01'", "SELECT e1 FROM pm1.g1
WHERE e1 = '2006-07-01'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteWithReference() {
+ @Test public void testRewriteWithReference() {
helpTestRewriteCommand("SELECT e1 FROM pm1.g1 where parsetimestamp(e1,
'yyyy-MM-dd') != ?", "SELECT e1 FROM pm1.g1 WHERE e1 <>
formattimestamp(?, 'yyyy-MM-dd')"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewiteJoinCriteria() {
+ @Test public void testRewiteJoinCriteria() {
helpTestRewriteCommand("SELECT pm1.g1.e1 FROM pm1.g1 inner join pm1.g2 on
(pm1.g1.e1 = null)", "SELECT pm1.g1.e1 FROM pm1.g1 INNER JOIN pm1.g2 ON 1 =
0"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewiteCompoundCriteria() {
+ @Test public void testRewiteCompoundCriteria() {
helpTestRewriteCriteria("(pm1.g1.e1 = 1 and pm1.g1.e2 = 2) and (pm1.g1.e3 =
1 and pm1.g1.e4 = 2)", "(pm1.g1.e1 = '1') AND (pm1.g1.e2 = 2) AND
(pm1.g1.e3 = TRUE) AND (pm1.g1.e4 = 2.0)"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteWhile() throws Exception {
+ @Test public void testRewriteWhile() throws Exception {
String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
@@ -1802,7 +1798,7 @@
}
- public void testRewriteWhile1() {
+ @Test public void testRewriteWhile1() {
String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
@@ -1827,7 +1823,7 @@
/**
* Tests that VariableSubstitutionVisitor does not cause an NPE on count(*)
*/
- public void testRewriteProcedureWithCount() {
+ @Test public void testRewriteProcedureWithCount() {
String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
@@ -1850,7 +1846,7 @@
/**
* Test to ensure the update changing list retains e1 = ?
*/
- public void testVariableSubstitutionVisitor() throws Exception {
+ @Test public void testVariableSubstitutionVisitor() throws Exception {
String procedure1 = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure1 += "BEGIN\n"; //$NON-NLS-1$
procedure1 += "DECLARE string var1 = INPUT.e1;\n"; //$NON-NLS-1$
@@ -1877,7 +1873,7 @@
assertEquals(expected, command.getSubCommand().toString());
}
- public void testRemoveEmptyLoop() {
+ @Test public void testRemoveEmptyLoop() {
String procedure1 = "CREATE virtual PROCEDURE "; //$NON-NLS-1$
procedure1 += "BEGIN\n"; //$NON-NLS-1$
procedure1 += "loop on (select e1 from pm1.g1) as myCursor\n";
//$NON-NLS-1$
@@ -1891,7 +1887,7 @@
helpTestRewriteCommand(procedure1, expected);
}
- public void testRewriteDeclare() {
+ @Test public void testRewriteDeclare() {
String procedure1 = "CREATE virtual PROCEDURE "; //$NON-NLS-1$
procedure1 += "BEGIN\n"; //$NON-NLS-1$
procedure1 += "declare integer x = 1 + 1;\n"; //$NON-NLS-1$
@@ -1902,26 +1898,26 @@
helpTestRewriteCommand(procedure1, expected);
}
- public void testRewriteUnionJoin() {
+ @Test public void testRewriteUnionJoin() {
String sql = "select pm1.g1.e1 from pm1.g1 union join pm1.g2 where g1.e1 =
1"; //$NON-NLS-1$
String expected = "SELECT pm1.g1.e1 FROM pm1.g1 FULL OUTER JOIN pm1.g2 ON 1
= 0 WHERE g1.e1 = '1'"; //$NON-NLS-1$
helpTestRewriteCommand(sql, expected);
}
- public void testRewriteNonNullDependentFunction() {
+ @Test public void testRewriteNonNullDependentFunction() {
helpTestRewriteCriteria("pm1.g1.e1 = concat(null, pm1.g1.e2)",
"null <> null"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteInWithNull() {
+ @Test public void testRewriteInWithNull() {
helpTestRewriteCriteria("convert(null, string) in (pm1.g1.e1,
pm1.g1.e2)", "null <> null"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteXMLCriteriaCases5630And5640() {
+ @Test public void testRewriteXMLCriteriaCases5630And5640() {
helpTestRewriteCommand("select * from xmltest.doc1 where node1 = null",
"SELECT * FROM xmltest.doc1 WHERE node1 = null"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCorrelatedSubqueryInHaving() {
+ @Test public void testRewriteCorrelatedSubqueryInHaving() {
String sql = "select pm1.g1.e1 from pm1.g1 group by pm1.g1.e1 having
pm1.g1.e1 in (select pm1.g1.e1 from pm1.g2)"; //$NON-NLS-1$
String expected = "SELECT pm1.g1.e1 FROM pm1.g1 GROUP BY pm1.g1.e1 HAVING
pm1.g1.e1 IN (SELECT pm1.g1.e1 FROM pm1.g2)"; //$NON-NLS-1$
@@ -1934,7 +1930,7 @@
assertEquals(1, refs.size());
}
- public void testRewriteSelectInto() {
+ @Test public void testRewriteSelectInto() {
String sql = "select distinct pm1.g1.e1 into #temp from pm1.g1";
//$NON-NLS-1$
String expected = "SELECT DISTINCT pm1.g1.e1 INTO #temp FROM pm1.g1";
//$NON-NLS-1$
@@ -1944,34 +1940,34 @@
/**
* Accounts for type change with duplicate names
*/
- public void testRewriteSelectInto1() {
+ @Test public void testRewriteSelectInto1() {
String sql = "select distinct e2, e2, e3, e4 into pm1.g1 from pm1.g2";
//$NON-NLS-1$
String expected = "SELECT PM1_G1_1.E2 AS E2, PM1_G1_1.E2_0, PM1_G1_1.E3,
PM1_G1_1.E4 INTO pm1.g1 FROM (SELECT DISTINCT e2, e2 AS E2_0, e3, e4 FROM pm1.g2) AS
pm1_g1_1"; //$NON-NLS-1$
helpTestRewriteCommand(sql, expected);
}
- public void testUnionQueryNullInOneBranch() throws Exception {
+ @Test public void testUnionQueryNullInOneBranch() throws Exception {
verifyProjectedTypesOnUnionBranches("SELECT e1, e2 FROM pm1.g1 UNION ALL
SELECT e1, null FROM pm1.g2", //$NON-NLS-1$
new Class[] {
DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.INTEGER });
}
- public void testUnionQueryNullInOneBranch2() throws Exception {
+ @Test public void testUnionQueryNullInOneBranch2() throws Exception {
verifyProjectedTypesOnUnionBranches("SELECT e1, e2 FROM pm1.g1 UNION ALL
SELECT e1, e2 FROM pm1.g2 UNION ALL SELECT e1, null FROM pm1.g2", //$NON-NLS-1$
new Class[] {
DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.INTEGER });
}
- public void testUnionQueryNullInOneBranch3() throws Exception {
+ @Test public void testUnionQueryNullInOneBranch3() throws Exception {
verifyProjectedTypesOnUnionBranches("SELECT e1, null FROM pm1.g1 UNION ALL
SELECT e1, null FROM pm1.g2 UNION ALL SELECT e1, e2 FROM pm1.g2", //$NON-NLS-1$
new Class[] {
DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.INTEGER });
}
- public void testUnionQueryNullInAllBranches() throws Exception {
+ @Test public void testUnionQueryNullInAllBranches() throws Exception {
verifyProjectedTypesOnUnionBranches("SELECT e1, null FROM pm1.g1 UNION ALL
SELECT e1, null FROM pm1.g2 UNION ALL SELECT e1, null FROM pm1.g2", //$NON-NLS-1$
new Class[] {
DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING });
}
- public void testUnionQueryWithTypeConversion() throws Exception {
+ @Test public void testUnionQueryWithTypeConversion() throws Exception {
verifyProjectedTypesOnUnionBranches("SELECT e1 FROM pm1.g1 UNION ALL SELECT
e2 FROM pm1.g2", //$NON-NLS-1$
new Class[] {
DataTypeManager.DefaultDataClasses.STRING});
}
@@ -1990,11 +1986,11 @@
}
}
- public void testRewiteOrderBy() {
+ @Test public void testRewiteOrderBy() {
helpTestRewriteCommand("SELECT 1+1 as a FROM pm1.g1 order by a",
"SELECT 2 AS a FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewiteOrderBy1() {
+ @Test public void testRewiteOrderBy1() {
helpTestRewriteCommand("SELECT 1+1 as a FROM pm1.g1 union select pm1.g2.e1
from pm1.g2 order by a", "SELECT '2' AS a FROM pm1.g1 UNION SELECT
pm1.g2.e1 FROM pm1.g2 ORDER BY a"); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -2003,7 +1999,7 @@
*
* It also ensures that all project symbols are uniquely named in the inline view
*/
- public void testSelectIntoWithOrderByAndTypeConversion() throws Exception {
+ @Test public void testSelectIntoWithOrderByAndTypeConversion() throws Exception {
String procedure = "CREATE VIRTUAL PROCEDURE\n"; //$NON-NLS-1$
procedure += "BEGIN\n"; //$NON-NLS-1$
procedure += "CREATE local temporary table temp (x string, y integer, z
integer);\n"; //$NON-NLS-1$
@@ -2015,23 +2011,23 @@
}
- public void testInsertWithQuery() throws Exception {
+ @Test public void testInsertWithQuery() throws Exception {
String sql = "insert into pm1.g1 select e1, e2, e3, e4 from pm1.g2 union
select e1, e2, e3, e4 from pm1.g2"; //$NON-NLS-1$
helpTestRewriteCommand(sql, "SELECT PM1_G1_1.E1, PM1_G1_1.E2, PM1_G1_1.E3,
PM1_G1_1.E4 INTO pm1.g1 FROM (SELECT e1, e2, e3, e4 FROM pm1.g2 UNION SELECT e1, e2, e3,
e4 FROM pm1.g2) AS pm1_g1_1"); //$NON-NLS-1$
}
- public void testRewriteNot() {
+ @Test public void testRewriteNot() {
helpTestRewriteCriteria("not(not(pm1.g1.e1 = 1 + 1))", "pm1.g1.e1
= '2'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteQueryWithNoFrom() {
+ @Test public void testRewriteQueryWithNoFrom() {
String sql = "select 1 as a order by a"; //$NON-NLS-1$
helpTestRewriteCommand(sql, "SELECT 1 AS a"); //$NON-NLS-1$
}
- public void testOrderByDuplicateRemoval() {
+ @Test public void testOrderByDuplicateRemoval() {
String sql = "SELECT pm1.g1.e1, pm1.g1.e1 as
c1234567890123456789012345678901234567890 FROM pm1.g1 ORDER BY
c1234567890123456789012345678901234567890, e1 "; //$NON-NLS-1$
helpTestRewriteCommand(sql, "SELECT pm1.g1.e1, pm1.g1.e1 AS
c1234567890123456789012345678901234567890 FROM pm1.g1 ORDER BY
c1234567890123456789012345678901234567890"); //$NON-NLS-1$
}
@@ -2039,7 +2035,7 @@
/**
* Case 4814
*/
- public void testVirtualRightOuterJoinSwap() throws Exception {
+ @Test public void testVirtualRightOuterJoinSwap() throws Exception {
String sql = "SELECT sa.IntKey AS sa_IntKey, mb.IntKey AS mb_IntKey FROM
(select * from BQT1.smalla) sa RIGHT OUTER JOIN (select BQT1.mediumb.intkey from
BQT1.mediumb) mb ON sa.IntKey = mb.IntKey"; //$NON-NLS-1$
helpTestRewriteCommand(sql, "SELECT sa.IntKey AS sa_IntKey, mb.IntKey AS
mb_IntKey FROM (SELECT BQT1.mediumb.intkey FROM BQT1.mediumb) AS mb LEFT OUTER JOIN
(SELECT * FROM BQT1.smalla) AS sa ON sa.IntKey = mb.IntKey",
FakeMetadataFactory.exampleBQTCached()); //$NON-NLS-1$
}
@@ -2047,36 +2043,36 @@
/**
* Case 4814
*/
- public void testVirtualRightOuterJoinSwap1() throws Exception {
+ @Test public void testVirtualRightOuterJoinSwap1() throws Exception {
String sql = "SELECT sa.IntKey AS sa_IntKey, mb.IntKey AS mb_IntKey FROM
((select * from BQT1.smalla) sa inner join BQT1.smallb on sa.intkey = smallb.intkey) RIGHT
OUTER JOIN (select BQT1.mediumb.intkey from BQT1.mediumb) mb ON sa.IntKey =
mb.IntKey"; //$NON-NLS-1$
helpTestRewriteCommand(sql, "SELECT sa.IntKey AS sa_IntKey, mb.IntKey AS
mb_IntKey FROM (SELECT BQT1.mediumb.intkey FROM BQT1.mediumb) AS mb LEFT OUTER JOIN
((SELECT * FROM BQT1.smalla) AS sa INNER JOIN BQT1.smallb ON sa.intkey = smallb.intkey) ON
sa.IntKey = mb.IntKey", FakeMetadataFactory.exampleBQTCached()); //$NON-NLS-1$
}
- public void testRewriteConcat2() {
+ @Test public void testRewriteConcat2() {
helpTestRewriteCriteria("concat2('a','b') =
'ab'", "1 = 1"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteConcat2_1() {
+ @Test public void testRewriteConcat2_1() {
helpTestRewriteCriteria("concat2(null, null) is null", "1 =
1"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteConcat2_2() throws Exception {
+ @Test public void testRewriteConcat2_2() throws Exception {
helpTestRewriteCriteria("concat2(pm1.g1.e1, null) = 'xyz'",
"CASE WHEN pm1.g1.e1 IS NULL THEN null ELSE concat(ifnull(pm1.g1.e1, ''),
'') END = 'xyz'", true); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteConcat2_3() throws Exception {
+ @Test public void testRewriteConcat2_3() throws Exception {
helpTestRewriteCriteria("concat2(pm1.g1.e1, convert(pm1.g1.e2, string)) =
'xyz'", "CASE WHEN (pm1.g1.e1 IS NULL) AND (convert(pm1.g1.e2, string)
IS NULL) THEN null ELSE concat(ifnull(pm1.g1.e1, ''), ifnull(convert(pm1.g1.e2,
string), '')) END = 'xyz'", true); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteConcat2_4() throws Exception {
+ @Test public void testRewriteConcat2_4() throws Exception {
helpTestRewriteCriteria("concat2('a', pm1.g1.e1) =
'xyz'", "concat('a', ifnull(pm1.g1.e1, '')) =
'xyz'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewiteEvaluatableAggregate() {
+ @Test public void testRewiteEvaluatableAggregate() {
helpTestRewriteCommand("select pm1.g1.e1, max(1) from pm1.g1",
"SELECT pm1.g1.e1, 1 FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteFromUnixTime() throws Exception {
+ @Test public void testRewriteFromUnixTime() throws Exception {
TimestampWithTimezone.resetCalendar(TimeZone.getTimeZone("GMT-06:00"));
//$NON-NLS-1$
try {
helpTestRewriteCriteria("from_unixtime(pm1.g1.e2) = '1992-12-01
07:00:00'", "timestampadd(SQL_TSI_SECOND, pm1.g1.e2, {ts'1969-12-31
18:00:00.0'}) = {ts'1992-12-01 07:00:00.0'}"); //$NON-NLS-1$
//$NON-NLS-2$
@@ -2085,15 +2081,15 @@
}
}
- public void testRewriteNullIf() throws Exception {
+ @Test public void testRewriteNullIf() throws Exception {
helpTestRewriteCriteria("nullif(pm1.g1.e2, pm1.g1.e4) = 1", "CASE
WHEN pm1.g1.e2 = pm1.g1.e4 THEN convert(null, double) ELSE pm1.g1.e2 END = 1.0",
true); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testRewriteCoalesce() throws Exception {
+ @Test public void testRewriteCoalesce() throws Exception {
helpTestRewriteCriteria("coalesce(convert(pm1.g1.e2, double), pm1.g1.e4) =
1", "ifnull(convert(pm1.g1.e2, double), pm1.g1.e4) = 1", true);
//$NON-NLS-1$ //$NON-NLS-2$
}
- public void testProcWithNull() throws Exception {
+ @Test public void testProcWithNull() throws Exception {
String sql = "exec pm1.vsp26(1, null)"; //$NON-NLS-1$
try {
@@ -2133,7 +2129,7 @@
* @see com.metamatrix.query.sql.symbol.AggregateSymbol
* @see com.metamatrix.query.sql.symbol.SearchedCaseExpression
*/
- public void testAggregateWithBetweenInCaseInSelect() {
+ @Test public void testAggregateWithBetweenInCaseInSelect() {
// Define a list of aggregates to test against
List<String> aggregateCommands = Arrays.asList( new String[] {
"SUM", "MAX", "MIN", "AVG", "COUNT" } );
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
@@ -2178,7 +2174,7 @@
* @see com.metamatrix.query.sql.lang.CompoundCriteria
* @see com.metamatrix.query.sql.symbol.SearchedCaseExpression
*/
- public void testBetweenInCaseInSelect() {
+ @Test public void testBetweenInCaseInSelect() {
String sqlBefore = "SELECT CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END
FROM pm1.g1"; //$NON-NLS-1$
String sqlAfter = "SELECT CASE WHEN (e2 >= 3) AND (e2 <= 5) THEN e2 ELSE
-1 END FROM pm1.g1"; //$NON-NLS-1$
@@ -2210,7 +2206,7 @@
* @see com.metamatrix.query.sql.lang.CompoundCriteria
* @see com.metamatrix.query.sql.symbol.SearchedCaseExpression
*/
- public void testBetweenInCase() {
+ @Test public void testBetweenInCase() {
String sqlBefore = "SELECT * FROM pm1.g1 WHERE e3 = CASE WHEN e2 BETWEEN 3 AND
5 THEN e2 ELSE -1 END"; //$NON-NLS-1$
String sqlAfter = "SELECT * FROM pm1.g1 WHERE e3 = CASE WHEN (e2 >= 3) AND
(e2 <= 5) THEN e2 ELSE -1 END"; //$NON-NLS-1$
@@ -2219,5 +2215,5 @@
assertEquals( "e2 >= 3", ccrit.getCriteria(0).toString() );
//$NON-NLS-1$
assertEquals( "e2 <= 5", ccrit.getCriteria(1).toString() );
//$NON-NLS-1$
}
-
+
}