1 61 62 package org.apache.commons.dbutils.wrappers; 63 64 import java.sql.ResultSet ; 65 import java.sql.SQLException ; 66 67 import org.apache.commons.dbutils.BaseTestCase; 68 import org.apache.commons.dbutils.MockResultSet; 69 import org.apache.commons.dbutils.ProxyFactory; 70 71 76 public class StringTrimmedResultSetTest extends BaseTestCase { 77 78 public StringTrimmedResultSetTest(String name) { 79 super(name); 80 } 81 82 public void setUp() throws Exception { 83 super.setUp(); 84 this.rs = StringTrimmedResultSet.wrap(this.rs); 85 } 86 87 public void testGetString() throws SQLException { 88 this.rs.next(); 89 assertEquals("notInBean", rs.getString(4)); 90 } 91 92 public void testGetObject() throws SQLException { 93 this.rs.next(); 94 assertEquals("notInBean", rs.getObject(4)); 95 } 96 97 101 public void testMultipleWrappers() throws Exception { 102 Object [][] rows = new Object [][] { { null } 104 }; 105 ResultSet rs = MockResultSet.create(metaData, rows); 106 107 SqlNullCheckedResultSet ncrs = new SqlNullCheckedResultSet(rs); 109 ncrs.setNullString(" trim this "); 110 rs = ProxyFactory.instance().createResultSet(ncrs); 111 112 rs = StringTrimmedResultSet.wrap(rs); 114 115 rs.next(); 116 assertEquals("trim this", rs.getString(1)); 117 } 118 119 } 120 | Popular Tags |