Unit test patches - Mailing list pgsql-jdbc

From John Lister
Subject Unit test patches
Date
Msg-id 49FAC740.1060607@kickstone.com
Whole thread Raw
Responses Re: Unit test patches  (Kris Jurka <books@ejurka.com>)
List pgsql-jdbc
Hi, running the unit tests against the latest cvs, i get 3 failures...

Patches attached to correct them.

The first occurs in DatabaseMetaDataTest.testTables line 104:

It fetches all the columns for any table beginning with test - i happen
to have other tables named test... which causes this to fail. I've
modified it to look for the testmetadata table, alternatively the docs
should be altered to state that the test database should be clean.

The second in TimeTest.timeTest : line 269 & 283:
The timezone tests fail because the as it happens local daylight savings
is in effect, the code tries to test for this by submitting the time
being tested, but this actually works out daylight savings for the time
at the epoch (1/1/1970). I've modified it to use DST_OFFSET instead
(note -  this may fail if ran during the switchover period).

and finally TimeTest.testGetTimeZone : line 84:
Fails because although the timezone offset is added to local_offset, the
dst isn't taken into account. If DST is in effect the offset is out.
I've corrected this by adding the DST_OFFSET value;


Also i did get an error on MiscTest.testSingleThreadCancel - but i can't
repeat this... Is this expected?

    [junit] Testcase:
testSingleThreadCancel(org.postgresql.test.jdbc2.MiscTest)
:       Caused an ERROR
    [junit] ERROR: canceling statement due to user request
    [junit] org.postgresql.util.PSQLException: ERROR: canceling
statement due to
 user request
    [junit]     at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse
(QueryExecutorImpl.java:1646)
    [junit]     at
org.postgresql.core.v3.QueryExecutorImpl.processResults(Query
ExecutorImpl.java:1380)
...


Thanks

JOHN

Index: DatabaseMetaDataTest.java
===================================================================
RCS file: /cvsroot/jdbc/pgjdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java,v
retrieving revision 1.44
diff -u -r1.44 DatabaseMetaDataTest.java
--- DatabaseMetaDataTest.java    7 Nov 2008 09:11:37 -0000    1.44
+++ DatabaseMetaDataTest.java    29 Apr 2009 19:44:51 -0000
@@ -99,7 +99,7 @@
         assertTrue( "getTables() returned too many rows", rs.next() == false);
         rs.close();

-        rs = dbmd.getColumns("", "", "test%", "%" );
+        rs = dbmd.getColumns("", "", "testmetadat%", "%" );
         assertTrue( rs.next() );
         assertEquals( "testmetadata", rs.getString("TABLE_NAME") );
         assertEquals( "id", rs.getString("COLUMN_NAME") );
@@ -498,7 +498,7 @@
         assertEquals("b", rs.getString(4));

         assertTrue(!rs.next());
-
+
         rs.close();
     }

Index: TimeTest.java
===================================================================
RCS file: /cvsroot/jdbc/pgjdbc/org/postgresql/test/jdbc2/TimeTest.java,v
retrieving revision 1.18
diff -u -r1.18 TimeTest.java
--- TimeTest.java    8 Jan 2008 06:56:31 -0000    1.18
+++ TimeTest.java    30 Apr 2009 10:34:54 -0000
@@ -59,7 +59,7 @@

         cal.setTimeZone(TimeZone.getTimeZone("GMT"));

-        long localOffset = Calendar.getInstance().get(Calendar.ZONE_OFFSET);
+        long localOffset = Calendar.getInstance().get(Calendar.ZONE_OFFSET) +
Calendar.getInstance().get(Calendar.DST_OFFSET);

         /* set the time to midnight to make this easy */
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testtime", "'00:00:00','00:00:00'")));
@@ -266,10 +266,8 @@
             assertNotNull(t);
             java.sql.Time tmpTime = java.sql.Time.valueOf("5:1:2");
             int localoffset = java.util.Calendar.getInstance().getTimeZone().getRawOffset();
-            if (java.util.Calendar.getInstance().getTimeZone().inDaylightTime(tmpTime))
-            {
-                localoffset += 60 * 60 * 1000;
-            }
+            localoffset += java.util.Calendar.getInstance().get(Calendar.DST_OFFSET);
+
             int Timeoffset = 3 * 60 * 60 * 1000;
             tmpTime.setTime(tmpTime.getTime() + Timeoffset + localoffset);
             assertEquals(makeTime(tmpTime.getHours(), tmpTime.getMinutes(), tmpTime.getSeconds()), t);
@@ -279,10 +277,7 @@
             assertNotNull(t);
             tmpTime = java.sql.Time.valueOf("23:59:59");
             localoffset = java.util.Calendar.getInstance().getTimeZone().getRawOffset();
-            if (java.util.Calendar.getInstance().getTimeZone().inDaylightTime(tmpTime))
-            {
-                localoffset += 60 * 60 * 1000;
-            }
+            localoffset += java.util.Calendar.getInstance().get(Calendar.DST_OFFSET);
             Timeoffset = -11 * 60 * 60 * 1000;
             tmpTime.setTime(tmpTime.getTime() + Timeoffset + localoffset);
             assertEquals(makeTime(tmpTime.getHours(), tmpTime.getMinutes(), tmpTime.getSeconds()), t);



pgsql-jdbc by date:

Previous
From: Oliver Jowett
Date:
Subject: Re: Very strange performance decrease when reusing a PreparedStatement
Next
From: Frédérik Bilhaut
Date:
Subject: Re: Very strange performance decrease when reusing a PreparedStatement