testGetTimeZone failures using CVS driver - Mailing list pgsql-jdbc

From Oliver Jowett
Subject testGetTimeZone failures using CVS driver
Date
Msg-id 406BD8BE.6060603@opencloud.com
Whole thread Raw
List pgsql-jdbc
I get this test failure with the CVS HEAD driver:

>     [junit] Testcase: testGetTimeZone(org.postgresql.test.jdbc2.TimeTest):      FAILED
>     [junit] expected:<100> but was:<-900>
>     [junit] junit.framework.AssertionFailedError: expected:<100> but was:<-900>
>     [junit]     at org.postgresql.test.jdbc2.TimeTest.testGetTimeZone(TimeTest.java:81)
>     [junit]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     [junit]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>     [junit]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

The failing line is this:

   assertEquals(100, time.getTime() % 1000);

For reference the same inserts/select that the test uses produce this
under psql here (note that my timezone is GMT+1200):

> Welcome to psql 7.4.1, the PostgreSQL interactive terminal.
>
> test=> create table testtime(tm time, tz time with time zone);
> CREATE TABLE
> test=> insert into testtime values ('00:00:00','00:00:00');
> INSERT 24302 1
> test=> insert into testtime values ('00:00:00.1','00:00:00.01');
> INSERT 24303 1
> test=> insert into testtime values (now(),now());
> INSERT 24304 1
> test=> select tm,tz from testtime;
>        tm        |         tz
> -----------------+--------------------
>  00:00:00        | 00:00:00+12
>  00:00:00.10     | 00:00:00.01+12
>  20:40:19.426658 | 20:40:19.426658+12
> (3 rows)

It looks like the problem is that 00:00:00.10 +1200 is actually before
the epoch in GMT, and the testcase explicitly sets the timezone to GMT,
so time.getTime() in the test is returning a negative value and
time.getTime()%1000 no longer returns the milliseconds part of the time
value.

I'm not really familiar enough with the guts of the Java timezone stuff
to be sure of this though -- if someone can confirm that it's a test
problem and not something deeper, I can provide a patch.

-O

pgsql-jdbc by date:

Previous
From: Oliver Jowett
Date:
Subject: Re: OutOfMemory
Next
From: Oliver Jowett
Date:
Subject: patch: enforce the requirements for scrollable resultsets