1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.dbutils.handlers;
18
19 import java.sql.SQLException;
20
21 import org.apache.commons.dbutils.BaseTestCase;
22 import org.apache.commons.dbutils.ResultSetHandler;
23
24 public class ScalarHandlerTest extends BaseTestCase {
25
26 public void testHandle() throws SQLException {
27 ResultSetHandler h = new ScalarHandler();
28 Object results = h.handle(this.rs);
29 assertNotNull(results);
30 assertEquals("1", results);
31 }
32
33 public void testColumnIndexHandle() throws SQLException {
34 ResultSetHandler h = new ScalarHandler(2);
35 Object results = h.handle(this.rs);
36 assertNotNull(results);
37 assertEquals("2", results);
38 }
39
40 public void testColumnNameHandle() throws SQLException {
41 ResultSetHandler h = new ScalarHandler("THree");
42 Object results = h.handle(this.rs);
43 assertNotNull(results);
44 assertEquals("3", results);
45 }
46
47 public void testEmptyResultSetHandle() throws SQLException {
48 ResultSetHandler h = new ScalarHandler();
49 Object results = h.handle(this.emptyResultSet);
50 assertNull(results);
51 }
52
53 }