commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dgra...@apache.org
Subject cvs commit: jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/wrappers StringTrimmedResultSetTest.java
Date Wed, 29 Oct 2003 01:31:50 GMT
dgraham     2003/10/28 17:31:50

  Modified:    dbutils/src/test/org/apache/commons/dbutils/wrappers
                        StringTrimmedResultSetTest.java
  Log:
  Added a test for a wrapper within a wrapper to make sure
  they delegate calls appropriately and their behavior is
  cumulative.
  
  Revision  Changes    Path
  1.2       +45 -20    jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/wrappers/StringTrimmedResultSetTest.java
  
  Index: StringTrimmedResultSetTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/wrappers/StringTrimmedResultSetTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StringTrimmedResultSetTest.java	28 Oct 2003 03:08:06 -0000	1.1
  +++ StringTrimmedResultSetTest.java	29 Oct 2003 01:31:50 -0000	1.2
  @@ -61,9 +61,12 @@
   
   package org.apache.commons.dbutils.wrappers;
   
  +import java.sql.ResultSet;
   import java.sql.SQLException;
   
   import org.apache.commons.dbutils.BaseTestCase;
  +import org.apache.commons.dbutils.MockResultSet;
  +import org.apache.commons.dbutils.ProxyFactory;
   
   /**
    * StringTrimmedResultSetTest
  @@ -72,23 +75,45 @@
    */
   public class StringTrimmedResultSetTest extends BaseTestCase {
   
  -	public StringTrimmedResultSetTest(String name) {
  -		super(name);
  -	}
  -
  -	public void setUp() throws Exception {
  -		super.setUp();
  -		this.rs = StringTrimmedResultSet.wrap(this.rs);
  -	}
  -
  -	public void testGetString() throws SQLException {
  -		this.rs.next();
  -		assertEquals("notInBean", rs.getString(4));
  -	}
  -
  -	public void testGetObject() throws SQLException {
  -		this.rs.next();
  -		assertEquals("notInBean", rs.getObject(4));
  -	}
  +    public StringTrimmedResultSetTest(String name) {
  +        super(name);
  +    }
  +
  +    public void setUp() throws Exception {
  +        super.setUp();
  +        this.rs = StringTrimmedResultSet.wrap(this.rs);
  +    }
  +
  +    public void testGetString() throws SQLException {
  +        this.rs.next();
  +        assertEquals("notInBean", rs.getString(4));
  +    }
  +
  +    public void testGetObject() throws SQLException {
  +        this.rs.next();
  +        assertEquals("notInBean", rs.getObject(4));
  +    }
  +
  +    /**
  +     * Make sure 2 wrappers work together.
  +     * @throws SQLException
  +     */
  +    public void testMultipleWrappers() throws Exception {
  +        // Create a ResultSet with data
  +        Object[][] rows = new Object[][] { { null }
  +        };
  +        ResultSet rs = MockResultSet.create(metaData, rows);
  +
  +        // Wrap the ResultSet with a null checked version
  +        SqlNullCheckedResultSet ncrs = new SqlNullCheckedResultSet(rs);
  +        ncrs.setNullString("   trim this   ");
  +        rs = ProxyFactory.instance().createResultSet(ncrs);
  +
  +        // Wrap the wrapper with a string trimmed version
  +        rs = StringTrimmedResultSet.wrap(rs);
  +
  +        rs.next();
  +        assertEquals("trim this", rs.getString(1));
  +    }
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message