dgraham 2003/11/09 10:18:04
Modified:dbutils/src/test/org/apache/commons/dbutils/wrappers
SqlNullCheckedResultSetTest.java
dbutils/src/java/org/apache/commons/dbutils/wrappers
SqlNullCheckedResultSet.java
Log:
- Cleaned up nullMethods population code
- Fixed bug in invoke() where we were potentially calling
rs.wasNull() before a getter method was called which
could lead to an SQLException
- Added support for null URLs.
Revision ChangesPath
1.2 +32 -15
jakarta-commons/dbutils/src/test/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java
Index: SqlNullCheckedResultSetTest.java
===
RCS file:
/home/cvs/jakarta-commons/dbutils/src/test/org/apache/commons/dbutils/wrappers/SqlNullCheckedResultSetTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SqlNullCheckedResultSetTest.java 2 Nov 2003 19:15:24 - 1.1
+++ SqlNullCheckedResultSetTest.java 9 Nov 2003 18:18:04 - 1.2
@@ -70,6 +70,8 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.math.BigDecimal;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Ref;
@@ -445,14 +447,12 @@
rs2.setNullShort(s);
assertEquals(s, rs.getShort(1));
assertEquals(s, rs.getShort(column));
-
}
/**
* Tests the getString implementation.
*/
public void testGetString() throws SQLException {
-
assertEquals(null, rs.getString(1));
assertTrue(rs.wasNull());
assertEquals(null, rs.getString(column));
@@ -462,7 +462,6 @@
rs2.setNullString(s);
assertEquals(s, rs.getString(1));
assertEquals(s, rs.getString(column));
-
}
/**
@@ -516,7 +515,21 @@
assertEquals(ts, rs.getTimestamp(1, Calendar.getInstance()));
assertNotNull(rs.getTimestamp(column, Calendar.getInstance()));
assertEquals(ts, rs.getTimestamp(column, Calendar.getInstance()));
-
+}
+
+/**
+ * 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));
}
/**
@@ -779,21 +792,18 @@
* Tests the setNullString implementation.
*/
public void testSetNullString() throws SQLException {
-
assertEquals(null, rs2.getNullString());
// Set what gets returned to something other than the default
String s = hello, world;
rs2.setNullString(s);
assertEquals(s, rs.getString(1));
assertEquals(s, rs.getString(column));
-
}
/**
* Tests the setNullRef implementation.
*/
public void testSetNullRef() throws SQLException {
-
assertNull(rs2.getNullRef());
// Set what gets returned to something other than the default
Ref ref = new SqlNullCheckedResultSetMockRef();
@@ -802,14 +812,12 @@
assertEquals(ref, rs.getRef(1));
assertNotNull(rs.getRef(column));
assertEquals(ref, rs.getRef(column));
-
}
/**
* Tests the setNullTime implementation.
*/
public void testSetNullTime() throws SQLException {
-
assertEquals(null, rs2.getNullTime());
// Set what gets returned to something other than the default
Time time = new Time(new java.util.Date().getTime());
@@ -822,14 +830,12 @@
assertEquals(time, rs.getTime(1, Calendar.getInstance()));
assertNotNull(rs.getTime(column, Calendar.getInstance()));
assertEquals(time, rs.getTime(column, Calendar.getInstance()));
-
}
/**
* Tests the setNullTimestamp implementation.
*/
public void testSetNullTimestamp() throws SQLException {
-
assertEquals(null, rs2.getNullTimestamp());
// Set what gets returned to something other than the default
Timestamp ts = new Timestamp(new java.util.Date().getTime());
@@ -842,7 +848,18 @@
assertEquals(ts, rs.getTimestamp(1, Calendar.getInstance()));
assertNotNull(rs.getTimestamp(column, Calendar.getInstance()));
assertEquals(ts, rs.getTimestamp(column, Calendar.getInstance()));
-
+}