Author: shawkins
Date: 2012-05-09 14:40:59 -0400 (Wed, 09 May 2012)
New Revision: 4085
Modified:
branches/7.7.x/common-core/src/main/java/org/teiid/core/types/basic/StringToDateTransform.java
branches/7.7.x/common-core/src/main/java/org/teiid/core/types/basic/StringToTimestampTransform.java
branches/7.7.x/common-core/src/test/java/org/teiid/core/types/basic/TestTransforms.java
Log:
TEIID-1995 adding back full checks for valid representations
Modified:
branches/7.7.x/common-core/src/main/java/org/teiid/core/types/basic/StringToDateTransform.java
===================================================================
---
branches/7.7.x/common-core/src/main/java/org/teiid/core/types/basic/StringToDateTransform.java 2012-05-09
18:40:58 UTC (rev 4084)
+++
branches/7.7.x/common-core/src/main/java/org/teiid/core/types/basic/StringToDateTransform.java 2012-05-09
18:40:59 UTC (rev 4085)
@@ -62,7 +62,7 @@
}
throw new TransformationException(e, "ERR.003.029.0018",
CorePlugin.Util.getString("ERR.003.029.0018", value)); //$NON-NLS-1$
//$NON-NLS-2$
}
- if (validate && !result.toString().equals(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:
branches/7.7.x/common-core/src/main/java/org/teiid/core/types/basic/StringToTimestampTransform.java
===================================================================
---
branches/7.7.x/common-core/src/main/java/org/teiid/core/types/basic/StringToTimestampTransform.java 2012-05-09
18:40:58 UTC (rev 4084)
+++
branches/7.7.x/common-core/src/main/java/org/teiid/core/types/basic/StringToTimestampTransform.java 2012-05-09
18:40:59 UTC (rev 4085)
@@ -63,7 +63,7 @@
throw new TransformationException(e, "ERR.003.029.0024",
CorePlugin.Util.getString("ERR.003.029.0024", value)); //$NON-NLS-1$
//$NON-NLS-2$
}
//validate everything except for fractional seconds
- if (validate && !((String)value).startsWith(result.toString().substring(0,
19))) {
+ 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:
branches/7.7.x/common-core/src/test/java/org/teiid/core/types/basic/TestTransforms.java
===================================================================
---
branches/7.7.x/common-core/src/test/java/org/teiid/core/types/basic/TestTransforms.java 2012-05-09
18:40:58 UTC (rev 4084)
+++
branches/7.7.x/common-core/src/test/java/org/teiid/core/types/basic/TestTransforms.java 2012-05-09
18:40:59 UTC (rev 4085)
@@ -232,6 +232,10 @@
helpTestTransform(" 2005-12-01 11:13:01 ",
TimestampUtil.createTimestamp(105, 11, 1, 11, 13, 1, 0)); //$NON-NLS-1$
}
+ @Test public void testStringToTimestampFails() throws Exception {
+ helpTransformException("2005-12-01 11:88:60", Timestamp.class, "The
string representation '2005-12-01 11:88:60' of a Timestamp value is not
valid."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
@Test public void testStringToLongWithWS() throws Exception {
helpTestTransform(" 1 ", Long.valueOf(1)); //$NON-NLS-1$
}
Show replies by date