|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Test case failure for TestDefaultFormMap (proposed fix)Hi,
for a long long time I have a failure in the test suite for TestDefaultFormMap, key foo11. This test uses FormType.TIME to parse a Time created as Time sampleTime = new Time(df2.parse(df2.format(new Date())).getTime()); My default locale is FR, and this test has always been failing for me... I decided to catch it and here is what I think is happening : In FormType.TIME, the parsing code does : 1) create a DataFormat with 'DateFormat.getTimeInstance(DateFormat.SHORT, locale);' 2) parse the passed value with 'new Time(df.parse(origVal).getTime());' 3) if parsing fails (throws a exception), try again with a DateFormat.MEDIUM, LONG and then FULL. I guess US locale can't parse 12:52:12 as SHORT, but apparently FR can (this might be a bug in this locale, but...). It will parse "12:52:12" as 12:52:00. So in the unit test, the parsed time is different from the origVal, as it was parsed with the SHORT DateFormat. The fix I suggest is to reverse the order in which the format are tried : begin with FULL, then with LONG, MEDIUM and SHORT. This should avoid parsing that simply drop extra information... In my case (FR locale), FULL and LONG parsing fail, and MEDIUM works. It returns 12:52:12. Test passed :) Are you ok for this fix ? Franck -- Barracuda mailing list Barracuda@... http://www.objectweb.org/wws/lists/projects/barracuda |
|
|
Re: Test case failure for TestDefaultFormMap (proposed fix)Oh, and I should maybe apply the same logic for DATE and TIMESTAMP.
Franck Routier a écrit : > Hi, > > for a long long time I have a failure in the test suite for > TestDefaultFormMap, key foo11. > > This test uses FormType.TIME to parse a Time created as Time > sampleTime = new Time(df2.parse(df2.format(new Date())).getTime()); > > My default locale is FR, and this test has always been failing for > me... I decided to catch it and here is what I think is happening : > > In FormType.TIME, the parsing code does : > > 1) create a DataFormat with > 'DateFormat.getTimeInstance(DateFormat.SHORT, locale);' > 2) parse the passed value with 'new Time(df.parse(origVal).getTime());' > 3) if parsing fails (throws a exception), try again with a > DateFormat.MEDIUM, LONG and then FULL. > > I guess US locale can't parse 12:52:12 as SHORT, but apparently FR can > (this might be a bug in this locale, but...). It will parse "12:52:12" > as 12:52:00. > So in the unit test, the parsed time is different from the origVal, as > it was parsed with the SHORT DateFormat. > > The fix I suggest is to reverse the order in which the format are > tried : begin with FULL, then with LONG, MEDIUM and SHORT. This should > avoid parsing that simply drop extra information... > In my case (FR locale), FULL and LONG parsing fail, and MEDIUM works. > It returns 12:52:12. Test passed :) > > Are you ok for this fix ? > > Franck > > > > ------------------------------------------------------------------------ > > > > -- > > Barracuda mailing list > > Barracuda@... > > http://www.objectweb.org/wws/lists/projects/barracuda > > -- Barracuda mailing list Barracuda@... http://www.objectweb.org/wws/lists/projects/barracuda |
|
|
Re: Test case failure for TestDefaultFormMap (proposed fix)I would say yes, but the form mapping code was never something I delved into much. Hopefully someone more familiar can pipe up. If you don't hear anything, then go ahead and do it. Silence has stalled this project for too long. Jake At 06:22 AM 2/6/2007, you wrote: >Oh, and I should maybe apply the same logic for DATE and TIMESTAMP. > >Franck Routier a écrit : >> Hi, >> >> for a long long time I have a failure in the test suite for >> TestDefaultFormMap, key foo11. >> >> This test uses FormType.TIME to parse a Time created as Time >> sampleTime = new Time(df2.parse(df2.format(new Date())).getTime()); >> >> My default locale is FR, and this test has always been failing for >> me... I decided to catch it and here is what I think is happening : >> >> In FormType.TIME, the parsing code does : >> >> 1) create a DataFormat with >> 'DateFormat.getTimeInstance(DateFormat.SHORT, locale);' >> 2) parse the passed value with 'new Time(df.parse(origVal).getTime());' >> 3) if parsing fails (throws a exception), try again with a >> DateFormat.MEDIUM, LONG and then FULL. >> >> I guess US locale can't parse 12:52:12 as SHORT, but apparently FR can >> (this might be a bug in this locale, but...). It will parse "12:52:12" >> as 12:52:00. >> So in the unit test, the parsed time is different from the origVal, as >> it was parsed with the SHORT DateFormat. >> >> The fix I suggest is to reverse the order in which the format are >> tried : begin with FULL, then with LONG, MEDIUM and SHORT. This should >> avoid parsing that simply drop extra information... >> In my case (FR locale), FULL and LONG parsing fail, and MEDIUM works. >> It returns 12:52:12. Test passed :) >> >> Are you ok for this fix ? >> >> Franck >> >> >> >> ------------------------------------------------------------------------ >> >> >> >> -- >> >> Barracuda mailing list >> >> Barracuda@... >> >> http://www.objectweb.org/wws/lists/projects/barracuda >> >> > > > > > >-- >Barracuda mailing list >Barracuda@... >http://www.objectweb.org/wws/lists/projects/barracuda -- Barracuda mailing list Barracuda@... http://www.objectweb.org/wws/lists/projects/barracuda |
|
|
Re: Test case failure for TestDefaultFormMap (proposed fix)Hi Jake,
thanks for your response :) Ok, I have tested my changes with my default locale (FR), with a C locale and with a DE locale... All this works. So I go ahead and commit. Regards, Franck Jacob Kjome a écrit : > > I would say yes, but the form mapping code was never something I > delved into much. Hopefully someone more familiar can pipe up. If > you don't hear anything, then go ahead and do it. Silence has stalled > this project for too long. > > Jake > > At 06:22 AM 2/6/2007, you wrote: > >Oh, and I should maybe apply the same logic for DATE and TIMESTAMP. > > > >Franck Routier a écrit : > >> Hi, > >> > >> for a long long time I have a failure in the test suite for > >> TestDefaultFormMap, key foo11. > >> > >> This test uses FormType.TIME to parse a Time created as Time > >> sampleTime = new Time(df2.parse(df2.format(new Date())).getTime()); > >> > >> My default locale is FR, and this test has always been failing for > >> me... I decided to catch it and here is what I think is happening : > >> > >> In FormType.TIME, the parsing code does : > >> > >> 1) create a DataFormat with > >> 'DateFormat.getTimeInstance(DateFormat.SHORT, locale);' > >> 2) parse the passed value with 'new > Time(df.parse(origVal).getTime());' > >> 3) if parsing fails (throws a exception), try again with a > >> DateFormat.MEDIUM, LONG and then FULL. > >> > >> I guess US locale can't parse 12:52:12 as SHORT, but apparently FR can > >> (this might be a bug in this locale, but...). It will parse "12:52:12" > >> as 12:52:00. > >> So in the unit test, the parsed time is different from the origVal, as > >> it was parsed with the SHORT DateFormat. > >> > >> The fix I suggest is to reverse the order in which the format are > >> tried : begin with FULL, then with LONG, MEDIUM and SHORT. This should > >> avoid parsing that simply drop extra information... > >> In my case (FR locale), FULL and LONG parsing fail, and MEDIUM works. > >> It returns 12:52:12. Test passed :) > >> > >> Are you ok for this fix ? > >> > >> Franck > >> > >> > >> > >> > ------------------------------------------------------------------------ > >> > >> > >> > >> -- > >> > >> Barracuda mailing list > >> > >> Barracuda@... > >> > >> http://www.objectweb.org/wws/lists/projects/barracuda > >> > >> > > > > > > > > > > > >-- > >Barracuda mailing list > >Barracuda@... > >http://www.objectweb.org/wws/lists/projects/barracuda > > > ------------------------------------------------------------------------ > > > > -- > > Barracuda mailing list > > Barracuda@... > > http://www.objectweb.org/wws/lists/projects/barracuda > > -- Barracuda mailing list Barracuda@... http://www.objectweb.org/wws/lists/projects/barracuda |
| Free Forum Powered by Nabble | Forum Help |