commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r471634 - /jakarta/commons/proper/dbutils/trunk/src/test/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java
Date Mon, 06 Nov 2006 04:46:20 GMT
Author: bayard
Date: Sun Nov  5 20:46:20 2006
New Revision: 471634

URL: http://svn.apache.org/viewvc?view=rev&rev=471634
Log:
Switched the URL test to use reflection so it works under a 1.3 build

Modified:
    jakarta/commons/proper/dbutils/trunk/src/test/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java

Modified: jakarta/commons/proper/dbutils/trunk/src/test/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/dbutils/trunk/src/test/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java?view=diff&rev=471634&r1=471633&r2=471634
==============================================================================
--- jakarta/commons/proper/dbutils/trunk/src/test/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java
(original)
+++ jakarta/commons/proper/dbutils/trunk/src/test/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java
Sun Nov  5 20:46:20 2006
@@ -462,18 +462,41 @@
     }
     
     /**
-     * Tests the getURL implementation.
-     */
-    public void testGetURL() throws SQLException, MalformedURLException {
-        assertEquals(null, rs.getURL(1));
-        assertTrue(rs.wasNull());
-        assertEquals(null, rs.getURL("column"));
-        assertTrue(rs.wasNull());
-        // Set what gets returned to something other than the default
-        URL u = new URL("http://www.apache.org");
-        rs2.setNullURL(u);
-        assertEquals(u, rs.getURL(1));
-        assertEquals(u, rs.getURL("column"));
+     * Tests the getURL and setNullURL implementations.
+     *
+     * Uses reflection to allow for building under JDK 1.3.
+     */
+    public void testURL() throws SQLException, MalformedURLException, 
+            IllegalAccessException, IllegalArgumentException, 
+            java.lang.reflect.InvocationTargetException 
+    {
+        Method getUrlInt = null;
+        Method getUrlString = null;
+        try {
+            getUrlInt = ResultSet.class.getMethod("getURL", 
+                        new Class[] { Integer.TYPE } );
+            getUrlString = ResultSet.class.getMethod("getURL", 
+                           new Class[] { String.class } );
+        } catch(NoSuchMethodException e) {
+            // ignore
+        } catch(SecurityException e) {
+            // ignore
+        }
+        if (getUrlInt != null && getUrlString != null) {
+            assertEquals(null, getUrlInt.invoke(rs, 
+                         new Object[] { new Integer(1) } ) );
+            assertTrue(rs.wasNull());
+            assertEquals(null, getUrlString.invoke(rs, 
+                         new Object[] { "column" } ) );
+            assertTrue(rs.wasNull());
+            // Set what gets returned to something other than the default
+            URL u = new URL("http://www.apache.org");
+            rs2.setNullURL(u);
+            assertEquals(u, getUrlInt.invoke(rs, 
+                         new Object[] { new Integer(1) } ) );
+            assertEquals(u, getUrlString.invoke(rs, 
+                         new Object[] { "column" } ) );
+        }
     }
 
     /**
@@ -784,17 +807,6 @@
         assertEquals(ts, rs.getTimestamp("column", Calendar.getInstance()));
     }
     
-    /**
-     * Tests the setNullString implementation.
-     */
-    public void testSetNullURL() throws SQLException, MalformedURLException {
-        assertEquals(null, rs2.getNullURL());
-        // Set what gets returned to something other than the default
-        URL u = new URL("http://jakarta.apache.org");
-        rs2.setNullURL(u);
-        assertEquals(u, rs.getURL(1));
-        assertEquals(u, rs.getURL("column"));
-    }
 }
 
 class SqlNullUncheckedMockResultSet implements InvocationHandler {



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message