Failing test in org.postgresql.test.jdbc2.DateTest - Mailing list pgsql-jdbc

From Mike Fowler
Subject Failing test in org.postgresql.test.jdbc2.DateTest
Date
Msg-id 4D6538EA.8080905@mlfowler.com
Whole thread Raw
Responses Re: Failing test in org.postgresql.test.jdbc2.DateTest  (Mike Fowler <mike@mlfowler.com>)
Re: Failing test in org.postgresql.test.jdbc2.DateTest  (Lew <noone@lewscanon.com>)
List pgsql-jdbc
Hi all,

I have just pulled out the source from CVS and run the build and test
and found a failure in the class noted in the subject. Specifically the
test that fails is:

79    public void testSetDate() throws SQLException
80    {
...
111        ps.setObject(1, "1969-04-3", java.sql.Types.DATE);
112        assertEquals(1, ps.executeUpdate());
...
120        ps.setObject(1, java.sql.Date.valueOf("1912-5-1"),
java.sql.Types.DATE);
121        assertEquals(1, ps.executeUpdate());
...

This only fails in my JDK 1.6 - it passes in 1.5. Looking at the
java.sql.Date in the two source jars I have it's easy to see that the
valueOf method has been completely rewritten in 1.6 (well, at least
1.6.0_21 possibly earlier). Having looked at the API documentation has
remained unchanged in 1.3, 1.4, 1.5 and 1.6 (1.2 I couldn't find by
guessing) and reads:

* @param s a <code>String</code> object representing a date in
*        in the format "yyyy-mm-dd"

So it appears that the method now implements the API largely correctly,
however as you can see above a single digit date is still accepted.
Given that the API seems unchanged for so long, I'd recommend changing
the tests to reflect the API.

I've attached a patch to do just that and it's been tested with the
following JDKs:

1.4.2_19
1.5.0_22
1.6.0_21

Regards,

--
Mike Fowler
Registered Linux user: 379787


Attachment

pgsql-jdbc by date:

Previous
From: "Maurin, Marion"
Date:
Subject: Re: PGXAConnection and autocommit problem
Next
From: Mike Fowler
Date:
Subject: Re: Failing test in org.postgresql.test.jdbc2.DateTest