svn commit: r917369 - in /ofbiz/trunk/framework/base/src/org/ofbiz/base: conversion/DateTimeConverters.java util/test/ObjectTypeTests.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r917369 - in /ofbiz/trunk/framework/base/src/org/ofbiz/base: conversion/DateTimeConverters.java util/test/ObjectTypeTests.java

doogie-3
Author: doogie
Date: Mon Mar  1 03:17:02 2010
New Revision: 917369

URL: http://svn.apache.org/viewvc?rev=917369&view=rev
Log:
BUG FIX: Forbid SqlDateToSqlTime and SqlTimeToSqlDate conversions.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java?rev=917369&r1=917368&r2=917369&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java Mon Mar  1 03:17:02 2010
@@ -323,6 +323,26 @@
         }
     }
 
+    public static class SqlDateToTime extends AbstractConverter<java.sql.Date, java.sql.Time> {
+        public SqlDateToTime() {
+            super(java.sql.Date.class, java.sql.Time.class);
+        }
+
+        public java.sql.Time convert(java.sql.Date obj) throws ConversionException {
+            throw new ConversionException("Conversion from Date to Time not supported");
+       }
+    }
+
+    public static class SqlTimeToSqlDate extends AbstractConverter<java.sql.Time, java.sql.Date> {
+        public SqlTimeToSqlDate() {
+            super(java.sql.Time.class, java.sql.Date.class);
+        }
+
+        public java.sql.Date convert(java.sql.Time obj) throws ConversionException {
+            throw new ConversionException("Conversion from Time to Date not supported");
+        }
+    }
+
     public static class SqlTimeToList extends AbstractConverter<java.sql.Time, List<java.sql.Time>> {
         public SqlTimeToList() {
             super(java.sql.Time.class, List.class);

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java?rev=917369&r1=917368&r2=917369&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java Mon Mar  1 03:17:02 2010
@@ -322,7 +322,7 @@
         simpleTypeConvertTestSingleMulti("SqlDate->List", sqlDt, new String[] {"List", "java.util.List"}, list(sqlDt));
         simpleTypeConvertTestSingleMulti("SqlDate->Set", sqlDt, new String[] {"Set", "java.util.Set"}, set(sqlDt));
         simpleTypeConvertTestSingleMulti("SqlDate->Long", sqlDt, new String[] {"Long", "java.lang.Long"}, Long.valueOf("-129600000"));
-        simpleTypeConvertTestError("SqlDate->error", sqlDt, new String[] {/*BUG "Time", "java.sql.Time" */});
+        simpleTypeConvertTestError("SqlDate->error", sqlDt, new String[] {"Time", "java.sql.Time"});
     }
 
     public void testSqlTime() throws GeneralException {
@@ -333,7 +333,7 @@
         simpleTypeConvertTestSingleMulti("SqlTime->Timestamp", sqlTm, new String[] {"Timestamp", "java.sql.Timestamp"}, new Timestamp(2096000));
         simpleTypeConvertTestSingleMulti("SqlTime->List", sqlTm, new String[] {"List", "java.util.List"}, list(sqlTm));
         simpleTypeConvertTestSingleMulti("SqlTime->Set", sqlTm, new String[] {"Set", "java.util.Set"}, set(sqlTm));
-        //BUG simpleTypeConvertTestError("SqlTime->error", sqlTm, new String[] {/*BUG "Date", "java.sql.Date" */});
+        simpleTypeConvertTestError("SqlTime->error", sqlTm, new String[] {"Date", "java.sql.Date"});
     }
 
     public void testTimestamp() throws GeneralException {