commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wspe...@apache.org
Subject svn commit: r1205509 - in /commons/proper/dbutils/trunk/src/test/java/org/apache/commons/dbutils/handlers: ColumnListHandlerTest.java KeyedHandlerTest.java ScalarHandlerTest.java
Date Wed, 23 Nov 2011 17:47:23 GMT
Author: wspeirs
Date: Wed Nov 23 17:47:22 2011
New Revision: 1205509

URL: http://svn.apache.org/viewvc?rev=1205509&view=rev
Log:
- Updated unit tests to used generics

Modified:
    commons/proper/dbutils/trunk/src/test/java/org/apache/commons/dbutils/handlers/ColumnListHandlerTest.java
    commons/proper/dbutils/trunk/src/test/java/org/apache/commons/dbutils/handlers/KeyedHandlerTest.java
    commons/proper/dbutils/trunk/src/test/java/org/apache/commons/dbutils/handlers/ScalarHandlerTest.java

Modified: commons/proper/dbutils/trunk/src/test/java/org/apache/commons/dbutils/handlers/ColumnListHandlerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/dbutils/trunk/src/test/java/org/apache/commons/dbutils/handlers/ColumnListHandlerTest.java?rev=1205509&r1=1205508&r2=1205509&view=diff
==============================================================================
--- commons/proper/dbutils/trunk/src/test/java/org/apache/commons/dbutils/handlers/ColumnListHandlerTest.java
(original)
+++ commons/proper/dbutils/trunk/src/test/java/org/apache/commons/dbutils/handlers/ColumnListHandlerTest.java
Wed Nov 23 17:47:22 2011
@@ -28,9 +28,8 @@ import org.apache.commons.dbutils.Result
 public class ColumnListHandlerTest extends BaseTestCase {
 
     public void testHandle() throws SQLException {
-        ResultSetHandler<List<Object>> h = new ColumnListHandler();
-
-        List<Object> results = h.handle(this.rs);
+        ResultSetHandler<List<String>> h = new ColumnListHandler<String>();
+        List<String> results = h.handle(this.rs);
 
         assertNotNull(results);
         assertEquals(ROWS, results.size());
@@ -40,8 +39,8 @@ public class ColumnListHandlerTest exten
     }
 
     public void testColumnIndexHandle() throws SQLException {
-        ResultSetHandler<List<Object>> h = new ColumnListHandler(2);
-        List<Object> results = h.handle(this.rs);
+        ResultSetHandler<List<String>> h = new ColumnListHandler<String>(2);
+        List<String> results = h.handle(this.rs);
 
         assertNotNull(results);
         assertEquals(ROWS, results.size());
@@ -51,19 +50,19 @@ public class ColumnListHandlerTest exten
     }
 
     public void testColumnNameHandle() throws SQLException {
-        ResultSetHandler<List<Object>> h = new ColumnListHandler("Three");
-        List<Object> results = h.handle(this.rs);
+        ResultSetHandler<List<Integer>> h = new ColumnListHandler<Integer>("intTest");
+        List<Integer> results = h.handle(this.rs);
 
         assertNotNull(results);
         assertEquals(ROWS, results.size());
 
-        assertEquals("3", results.get(0));
-        assertEquals("6", results.get(1));
+        assertEquals(new Integer(1), results.get(0));
+        assertEquals(new Integer(3), results.get(1));
     }
 
     public void testEmptyResultSetHandle() throws SQLException {
-        ResultSetHandler<List<Object>> h = new ColumnListHandler();
-        List<Object> results = h.handle(this.emptyResultSet);
+        ResultSetHandler<List<String>> h = new ColumnListHandler<String>();
+        List<String> results = h.handle(this.emptyResultSet);
 
         assertNotNull(results);
         assertTrue(results.isEmpty());

Modified: commons/proper/dbutils/trunk/src/test/java/org/apache/commons/dbutils/handlers/KeyedHandlerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/dbutils/trunk/src/test/java/org/apache/commons/dbutils/handlers/KeyedHandlerTest.java?rev=1205509&r1=1205508&r2=1205509&view=diff
==============================================================================
--- commons/proper/dbutils/trunk/src/test/java/org/apache/commons/dbutils/handlers/KeyedHandlerTest.java
(original)
+++ commons/proper/dbutils/trunk/src/test/java/org/apache/commons/dbutils/handlers/KeyedHandlerTest.java
Wed Nov 23 17:47:22 2011
@@ -26,15 +26,15 @@ import org.apache.commons.dbutils.Result
 public class KeyedHandlerTest extends BaseTestCase {
 
     public void testHandle() throws SQLException {
-        ResultSetHandler<Map<Object,Map<String,Object>>> h = new KeyedHandler();
+        ResultSetHandler<Map<String,Map<String,Object>>> h = new KeyedHandler<String>();
 
-        Map<Object,Map<String,Object>> results = h.handle(this.rs);
+        Map<String,Map<String,Object>> results = h.handle(this.rs);
 
         assertNotNull(results);
         assertEquals(ROWS, results.size());
 
         Map<String,Object> row = null;
-        for(Entry<Object, Map<String, Object>> entry : results.entrySet())
+        for(Entry<String, Map<String, Object>> entry : results.entrySet())
         {
             Object key = entry.getKey();
             assertNotNull(key);
@@ -49,14 +49,14 @@ public class KeyedHandlerTest extends Ba
     }
 
     public void testColumnIndexHandle() throws SQLException {
-        ResultSetHandler<Map<Object,Map<String,Object>>> h = new KeyedHandler(2);
-        Map<Object,Map<String,Object>> results = h.handle(this.rs);
+        ResultSetHandler<Map<String,Map<String,Object>>> h = new KeyedHandler<String>(2);
+        Map<String,Map<String,Object>> results = h.handle(this.rs);
 
         assertNotNull(results);
         assertEquals(ROWS, results.size());
 
         Map<String,Object> row = null;
-        for(Entry<Object, Map<String, Object>> entry : results.entrySet())
+        for(Entry<String, Map<String, Object>> entry : results.entrySet())
         {
             Object key = entry.getKey();
             assertNotNull(key);
@@ -71,14 +71,14 @@ public class KeyedHandlerTest extends Ba
     }
 
     public void testColumnNameHandle() throws SQLException {
-        ResultSetHandler<Map<Object,Map<String,Object>>> h = new KeyedHandler("three");
-        Map<Object,Map<String,Object>> results = h.handle(this.rs);
+        ResultSetHandler<Map<Integer,Map<String,Object>>> h = new KeyedHandler<Integer>("intTest");
+        Map<Integer,Map<String,Object>> results = h.handle(this.rs);
 
         assertNotNull(results);
         assertEquals(ROWS, results.size());
 
         Map<String,Object> row = null;
-        for(Entry<Object, Map<String, Object>> entry : results.entrySet())
+        for(Entry<Integer, Map<String, Object>> entry : results.entrySet())
         {
             Object key = entry.getKey();
             assertNotNull(key);
@@ -86,15 +86,15 @@ public class KeyedHandlerTest extends Ba
             assertNotNull(row);
             assertEquals(COLS, row.keySet().size());
         }
-        row = results.get("6");
+        row = results.get(3);
         assertEquals("4", row.get("one"));
         assertEquals("5", row.get("TWO"));
         assertEquals("6", row.get("Three"));
     }
 
     public void testEmptyResultSetHandle() throws SQLException {
-        ResultSetHandler<Map<Object,Map<String,Object>>> h = new KeyedHandler();
-        Map<Object,Map<String,Object>> results = h.handle(this.emptyResultSet);
+        ResultSetHandler<Map<String,Map<String,Object>>> h = new KeyedHandler<String>();
+        Map<String,Map<String,Object>> results = h.handle(this.emptyResultSet);
         assertNotNull(results);
         assertTrue(results.isEmpty());
     }

Modified: commons/proper/dbutils/trunk/src/test/java/org/apache/commons/dbutils/handlers/ScalarHandlerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/dbutils/trunk/src/test/java/org/apache/commons/dbutils/handlers/ScalarHandlerTest.java?rev=1205509&r1=1205508&r2=1205509&view=diff
==============================================================================
--- commons/proper/dbutils/trunk/src/test/java/org/apache/commons/dbutils/handlers/ScalarHandlerTest.java
(original)
+++ commons/proper/dbutils/trunk/src/test/java/org/apache/commons/dbutils/handlers/ScalarHandlerTest.java
Wed Nov 23 17:47:22 2011
@@ -24,28 +24,28 @@ import org.apache.commons.dbutils.Result
 public class ScalarHandlerTest extends BaseTestCase {
 
     public void testHandle() throws SQLException {
-        ResultSetHandler<Object> h = new ScalarHandler();
+        ResultSetHandler<String> h = new ScalarHandler<String>();
         Object results = h.handle(this.rs);
         assertNotNull(results);
         assertEquals("1", results);
     }
 
     public void testColumnIndexHandle() throws SQLException {
-        ResultSetHandler<Object> h = new ScalarHandler(2);
+        ResultSetHandler<String> h = new ScalarHandler<String>(2);
         Object results = h.handle(this.rs);
         assertNotNull(results);
         assertEquals("2", results);
     }
 
     public void testColumnNameHandle() throws SQLException {
-        ResultSetHandler<Object> h = new ScalarHandler("THree");
+        ResultSetHandler<Integer> h = new ScalarHandler<Integer>("intTest");
         Object results = h.handle(this.rs);
         assertNotNull(results);
-        assertEquals("3", results);
+        assertEquals(1, results);
     }
 
     public void testEmptyResultSetHandle() throws SQLException {
-        ResultSetHandler<Object> h = new ScalarHandler();
+        ResultSetHandler<String> h = new ScalarHandler<String>();
         Object results = h.handle(this.emptyResultSet);
         assertNull(results);
     }



Mime
View raw message