Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 2829D1337B90 for ; Wed, 23 Feb 2011 12:42:31 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 07413-01 for ; Wed, 23 Feb 2011 16:42:23 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from milan.hostgo.com (milan.hostgo.com [72.52.99.130]) by mail.postgresql.org (Postfix) with ESMTP id 296951337B8D for ; Wed, 23 Feb 2011 12:42:22 -0400 (AST) Received: from [217.10.134.34] (helo=[192.168.1.71]) by milan.hostgo.com with esmtpa (Exim 4.69) (envelope-from ) id 1PsHnA-0001Jp-LS for pgsql-jdbc@postgresql.org; Wed, 23 Feb 2011 11:42:20 -0500 Message-ID: <4D6538EA.8080905@mlfowler.com> Date: Wed, 23 Feb 2011 16:42:18 +0000 From: Mike Fowler User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Failing test in org.postgresql.test.jdbc2.DateTest Content-Type: multipart/mixed; boundary="------------090805030906020400070102" X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - milan.hostgo.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - mlfowler.com X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201102/134 X-Sequence-Number: 21532 This is a multi-part message in MIME format. --------------090805030906020400070102 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 String 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 --------------090805030906020400070102 Content-Type: text/x-diff; name="dateTest.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="dateTest.patch" ? project-1.patch Index: org/postgresql/test/jdbc2/DateTest.java =================================================================== RCS file: /cvsroot/jdbc/pgjdbc/org/postgresql/test/jdbc2/DateTest.java,v retrieving revision 1.14 diff -c -r1.14 DateTest.java *** org/postgresql/test/jdbc2/DateTest.java 8 Jan 2008 06:56:31 -0000 1.14 --- org/postgresql/test/jdbc2/DateTest.java 23 Feb 2011 16:38:13 -0000 *************** *** 108,123 **** ps.setObject(1, "1934-02-28", java.sql.Types.DATE); assertEquals(1, ps.executeUpdate()); ! ps.setObject(1, "1969-04-3", java.sql.Types.DATE); assertEquals(1, ps.executeUpdate()); ps.setObject(1, "1982-08-03", java.sql.Types.DATE); assertEquals(1, ps.executeUpdate()); ! ps.setObject(1, "2012-3-15", java.sql.Types.DATE); assertEquals(1, ps.executeUpdate()); ! ps.setObject(1, java.sql.Date.valueOf("1912-5-1"), java.sql.Types.DATE); assertEquals(1, ps.executeUpdate()); ps.setObject(1, java.sql.Date.valueOf("1971-12-15"), java.sql.Types.DATE); --- 108,123 ---- ps.setObject(1, "1934-02-28", java.sql.Types.DATE); assertEquals(1, ps.executeUpdate()); ! ps.setObject(1, "1969-04-03", java.sql.Types.DATE); assertEquals(1, ps.executeUpdate()); ps.setObject(1, "1982-08-03", java.sql.Types.DATE); assertEquals(1, ps.executeUpdate()); ! ps.setObject(1, "2012-03-15", java.sql.Types.DATE); assertEquals(1, ps.executeUpdate()); ! ps.setObject(1, java.sql.Date.valueOf("1912-05-01"), java.sql.Types.DATE); assertEquals(1, ps.executeUpdate()); ps.setObject(1, java.sql.Date.valueOf("1971-12-15"), java.sql.Types.DATE); *************** *** 126,135 **** ps.setObject(1, java.sql.Date.valueOf("1984-12-03"), java.sql.Types.DATE); assertEquals(1, ps.executeUpdate()); ! ps.setObject(1, java.sql.Date.valueOf("2000-1-1"), java.sql.Types.DATE); assertEquals(1, ps.executeUpdate()); ! ps.setObject(1, java.sql.Date.valueOf("23456-1-1"), java.sql.Types.DATE); assertEquals(1, ps.executeUpdate()); // We can't use valueOf on BC dates. --- 126,135 ---- ps.setObject(1, java.sql.Date.valueOf("1984-12-03"), java.sql.Types.DATE); assertEquals(1, ps.executeUpdate()); ! ps.setObject(1, java.sql.Date.valueOf("2000-01-01"), java.sql.Types.DATE); assertEquals(1, ps.executeUpdate()); ! ps.setObject(1, java.sql.Date.valueOf("23456-01-01"), java.sql.Types.DATE); assertEquals(1, ps.executeUpdate()); // We can't use valueOf on BC dates. --------------090805030906020400070102--