Unix Technical Forum

JDK5 and TimeTest

This is a discussion on JDK5 and TimeTest within the pgsql Interfaces jdbc forums, part of the PostgreSQL category; --> Hello, The TimeTest (jdbc2) fails for the tests with timezone while running the postgresql-jdbc tests using JDK5. This is ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Interfaces jdbc

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-16-2008, 12:14 AM
Hari
 
Posts: n/a
Default JDK5 and TimeTest

Hello,

The TimeTest (jdbc2) fails for the tests with timezone while running
the postgresql-jdbc tests using JDK5. This is using pgsql-jdbc version
8.0.311 and postgresql version 8.0.6.
I was wondering whether someone in the group has enountered the same
and if there is a fix. I am just beginning to debug this and I have a
feeling that it may be because the Calendar implementation JDK5 seems
very different. Any ideas?

Thanks very much!
-Hari
SpikeSource Inc.
http://developer.spikesource.com

----------------------
Where it fails (org/postgresql/test/jdbc2/TimeTest.java):
==> The time is set in testSetTime (this works):
....
....
ps.setObject(1, "5:1:2-03", java.sql.Types.TIME);
assertEquals(1, ps.executeUpdate());

ps.setObject(1, "23:59:59+11", java.sql.Types.TIME);
assertEquals(1, ps.executeUpdate());
....
....

==> in timeTest method, the above time is accessed and it fails:
....
....
// If we're checking for timezones.
if (testSetTime)
{
assertTrue(rs.next());
t = rs.getTime(1);
assertNotNull(t);
java.sql.Time tmpTime = java.sql.Time.valueOf("5:1:2");
int localoffset =
java.util.Calendar.getInstance().getTimeZone().get RawOffset();
if
(java.util.Calendar.getInstance().getTimeZone().in DaylightTime(tmpTime))
{
localoffset += 60 * 60 * 1000;
}
int Timeoffset = 3 * 60 * 60 * 1000;
tmpTime.setTime(tmpTime.getTime() + Timeoffset +
localoffset);
assertEquals(makeTime(tmpTime.getHours(),
tmpTime.getMinutes(), tmpTime.getSeconds()), t); // <=== fails here

....
....

The error message is:
expected:<00:01:02> but was:<05:01:02>
junit.framework.AssertionFailedError: expected:<00:01:02> but
was:<05:01:02> at
org.postgresql.test.jdbc2.TimeTest.timeTest(TimeTe st.java:275) at

org.postgresql.test.jdbc2.TimeTest.testSetTime(Tim eTest.java:201)


A simple Calendar code like this shows two different output under JDK
1.4 and JDK5:

import java.util.Calendar;

class TestCalendar {
public static void main(String[] args) {
Calendar c = Calendar.getInstance();
System.out.println(c.toString());
}
}

(Execute it and look at the difference in the SimpleTimeZone object
within the Calendar object. They look entirely different).

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-16-2008, 12:15 AM
Kris Jurka
 
Posts: n/a
Default Re: JDK5 and TimeTest



On Fri, 18 Aug 2006, Hari wrote:

> Hello,
>
> The TimeTest (jdbc2) fails for the tests with timezone while running
> the postgresql-jdbc tests using JDK5. This is using pgsql-jdbc version
> 8.0.311 and postgresql version 8.0.6.


I see no failure here with JDBC 8.0.317, server 8.0.8 and JDK 1.5.0_05.

> A simple Calendar code like this shows two different output under JDK
> 1.4 and JDK5:
>
> Calendar c = Calendar.getInstance();
> System.out.println(c.toString());


I see identical results for my timezone (US/Pacific). Perhaps this change
is specific to your zone (which you have not mentioned)?

Kris Jurka


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:10 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com