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