1 61 62 package org.apache.commons.dbutils.handlers; 63 64 import java.sql.SQLException ; 65 66 import org.apache.commons.dbutils.BaseTestCase; 67 import org.apache.commons.dbutils.ResultSetHandler; 68 69 74 public class ScalarHandlerTest extends BaseTestCase { 75 76 79 public ScalarHandlerTest(String name) { 80 super(name); 81 } 82 83 public void testHandle() throws SQLException { 84 ResultSetHandler h = new ScalarHandler(); 85 Object results = (Object ) h.handle(this.rs); 86 87 assertNotNull(results); 88 assertEquals("1", results); 89 } 90 91 public void testColumnIndexHandle() throws SQLException { 92 ResultSetHandler h = new ScalarHandler(2); 93 Object results = (Object ) h.handle(this.rs); 94 95 assertNotNull(results); 96 assertEquals("2", results); 97 } 98 99 public void testColumnNameHandle() throws SQLException { 100 ResultSetHandler h = new ScalarHandler("THree"); 101 Object results = (Object ) h.handle(this.rs); 102 103 assertNotNull(results); 104 assertEquals("3", results); 105 } 106 107 public void testEmptyResultSetHandle() throws SQLException { 108 ResultSetHandler h = new ScalarHandler(); 109 Object results = (Object ) h.handle(this.emptyResultSet); 110 111 assertNull(results); 112 } 113 114 } 115 | Popular Tags |