1 61 62 package org.apache.commons.dbutils.handlers; 63 64 import java.sql.SQLException ; 65 import java.util.Iterator ; 66 import java.util.List ; 67 68 import org.apache.commons.dbutils.BaseTestCase; 69 import org.apache.commons.dbutils.ResultSetHandler; 70 71 76 public class ArrayListHandlerTest extends BaseTestCase { 77 78 81 public ArrayListHandlerTest(String name) { 82 super(name); 83 } 84 85 public void testHandle() throws SQLException { 86 ResultSetHandler h = new ArrayListHandler(); 87 List results = (List ) h.handle(this.rs); 88 89 assertNotNull(results); 90 assertEquals(ROWS, results.size()); 91 92 Iterator iter = results.iterator(); 93 Object [] row = null; 94 while (iter.hasNext()) { 95 row = (Object []) iter.next(); 96 assertEquals(COLS, row.length); 97 } 98 99 assertEquals("4", row[0]); 100 assertEquals("5", row[1]); 101 assertEquals("6", row[2]); 102 } 103 104 public void testEmptyResultSetHandle() throws SQLException { 105 ResultSetHandler h = new ArrayListHandler(); 106 List results = (List ) h.handle(this.emptyResultSet); 107 108 assertNotNull(results); 109 assertTrue(results.isEmpty()); 110 } 111 112 } 113 | Popular Tags |