Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 288FA1337B49 for ; Mon, 28 Feb 2011 06:23:28 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 07869-05 for ; Mon, 28 Feb 2011 10:23:21 +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 366191337B39 for ; Mon, 28 Feb 2011 06:23:20 -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 1Pu0G5-0000w0-He for pgsql-jdbc@postgresql.org; Mon, 28 Feb 2011 05:23:17 -0500 Message-ID: <4D6B7795.1060400@mlfowler.com> Date: Mon, 28 Feb 2011 10:23:17 +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: Re: Failing test in org.postgresql.test.jdbc2.DateTest References: <4D6538EA.8080905@mlfowler.com> <4D655262.5060804@mlfowler.com> In-Reply-To: <4D655262.5060804@mlfowler.com> Content-Type: multipart/mixed; boundary="------------060008060508040900080600" 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/155 X-Sequence-Number: 21553 This is a multi-part message in MIME format. --------------060008060508040900080600 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 23/02/11 18:30, Mike Fowler wrote: > On 23/02/11 16:42, I wrote: >> >> 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, >> > Oops, hold the phone. The test still broke on 1.6 but I didn't notice > the error as the "build succeeded". The year value 23456 causes the > test to fail as the maximum year in java.sql.date is 9999. However, > when I change the year to 3456 the test fails: > > [junit] expected:<3456-01-01> but was:<456-01-01> Turns out there was another place where a date was being set to 23456-01-01, which was misinterpreted by the 1.6 java.sql.Date. Attached is the patch that brings all the date tests in line with the published API. This has been tested on the three JDKs as noted above, and for all three the test output is: runtest: [mkdir] Created dir: /home/mike/oss/pgjdbc/build/testresults [junit] Testsuite: org.postgresql.test.jdbc2.Jdbc2TestSuite [junit] Tests run: 293, Failures: 0, Errors: 0, Time elapsed: 61.521 sec [junit] [junit] Testsuite: org.postgresql.test.jdbc2.optional.OptionalTestSuite [junit] Tests run: 40, Failures: 0, Errors: 0, Time elapsed: 3.564 sec [junit] [junit] Testsuite: org.postgresql.test.jdbc3.Jdbc3TestSuite [junit] Tests run: 66, Failures: 0, Errors: 0, Time elapsed: 5.959 sec [junit] [junit] Testsuite: org.postgresql.test.xa.XATestSuite [junit] Tests run: 0, Failures: 0, Errors: 0, Time elapsed: 0.072 sec [junit] [junit] ------------- Standard Output --------------- [junit] Skipping XA tests because max_prepared_transactions = 0. [junit] ------------- ---------------- --------------- Regards, -- Mike Fowler Registered Linux user: 379787 --------------060008060508040900080600 Content-Type: text/x-diff; name="dateTest-v2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="dateTest-v2.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 28 Feb 2011 10:17:35 -0000 *************** *** 63,69 **** assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'1971-12-15'"))); assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'1984-12-03'"))); assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'2000-01-01'"))); ! assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'23456-01-01'"))); assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'0101-01-01 BC'"))); /* dateTest() contains all of the tests */ --- 63,69 ---- assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'1971-12-15'"))); assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'1984-12-03'"))); assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'2000-01-01'"))); ! assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'3456-01-01'"))); assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'0101-01-01 BC'"))); /* dateTest() contains all of the tests */ *************** *** 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("3456-01-01"), java.sql.Types.DATE); assertEquals(1, ps.executeUpdate()); // We can't use valueOf on BC dates. *************** *** 240,246 **** assertTrue(rs.next()); d = rs.getDate(1); assertNotNull(d); ! assertEquals(makeDate(23456, 1, 1), d); assertTrue(rs.next()); d = rs.getDate(1); --- 240,246 ---- assertTrue(rs.next()); d = rs.getDate(1); assertNotNull(d); ! assertEquals(makeDate(3456, 1, 1), d); assertTrue(rs.next()); d = rs.getDate(1); --------------060008060508040900080600--