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 import org.apache.commons.dbutils.TestBean; 71 72 77 public class BeanListHandlerTest extends BaseTestCase { 78 79 82 public BeanListHandlerTest(String name) { 83 super(name); 84 } 85 86 public void testHandle() throws SQLException { 87 ResultSetHandler h = new BeanListHandler(TestBean.class); 88 List results = (List ) h.handle(this.rs); 89 90 assertNotNull(results); 91 assertEquals(ROWS, results.size()); 92 93 Iterator iter = results.iterator(); 94 TestBean row = null; 95 while (iter.hasNext()) { 96 row = (TestBean) iter.next(); 97 assertNotNull(row); 98 } 99 100 assertEquals("4", row.getOne()); 101 assertEquals("5", row.getTwo()); 102 assertEquals("6", row.getThree()); 103 assertEquals("not set", row.getDoNotSet()); 104 } 105 106 public void testEmptyResultSetHandle() throws SQLException { 107 ResultSetHandler h = new BeanListHandler(TestBean.class); 108 List results = (List ) h.handle(this.emptyResultSet); 109 110 assertNotNull(results); 111 assertTrue(results.isEmpty()); 112 } 113 114 } 115 | Popular Tags |