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 ResultSetIteratorTest.java BaseTestCase.java BasicRowProcessorTest.java
Date Sat, 25 Oct 2003 22:46:29 GMT
dgraham     2003/10/25 15:46:29

  Modified:    dbutils/src/test/org/apache/commons/dbutils/handlers
                        ArrayListHandlerTest.java ArrayHandlerTest.java
                        MapHandlerTest.java MapListHandlerTest.java
                        BeanListHandlerTest.java
               dbutils/src/test/org/apache/commons/dbutils
                        ResultSetIteratorTest.java BaseTestCase.java
                        BasicRowProcessorTest.java
  Log:
  Created ROWS and COLS constants in BaseTestCase
  to make it easier to change.
  
  Revision  Changes    Path
  1.2       +5 -5      jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/handlers/ArrayListHandlerTest.java
  
  Index: ArrayListHandlerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/handlers/ArrayListHandlerTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ArrayListHandlerTest.java	23 Oct 2003 01:15:34 -0000	1.1
  +++ ArrayListHandlerTest.java	25 Oct 2003 22:46:29 -0000	1.2
  @@ -87,13 +87,13 @@
   		List results = (List) h.handle(this.rs);
   
   		assertNotNull(results);
  -		assertEquals(2, results.size());
  +		assertEquals(ROWS, results.size());
   
   		Iterator iter = results.iterator();
   		Object[] row = null;
   		while (iter.hasNext()) {
   			row = (Object[]) iter.next();
  -			assertEquals(4, row.length);
  +			assertEquals(COLS, row.length);
   		}
   
   		assertEquals("4", row[0]);
  
  
  
  1.3       +4 -4      jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/handlers/ArrayHandlerTest.java
  
  Index: ArrayHandlerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/handlers/ArrayHandlerTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ArrayHandlerTest.java	23 Oct 2003 01:16:52 -0000	1.2
  +++ ArrayHandlerTest.java	25 Oct 2003 22:46:29 -0000	1.3
  @@ -85,7 +85,7 @@
   		Object[] results = (Object[]) h.handle(this.rs);
           
   		assertNotNull(results);
  -		assertEquals(4, results.length);
  +		assertEquals(COLS, results.length);
   		assertEquals("1", results[0]);
   		assertEquals("2", results[1]);
   		assertEquals("3", results[2]);
  
  
  
  1.2       +4 -4      jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/handlers/MapHandlerTest.java
  
  Index: MapHandlerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/handlers/MapHandlerTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MapHandlerTest.java	23 Oct 2003 01:57:54 -0000	1.1
  +++ MapHandlerTest.java	25 Oct 2003 22:46:29 -0000	1.2
  @@ -86,7 +86,7 @@
           Map results = (Map) h.handle(this.rs);
           
   		assertNotNull(results);
  -		assertEquals(4, results.keySet().size());
  +		assertEquals(COLS, results.keySet().size());
   		assertEquals("1", results.get("ONE"));
   		assertEquals("2", results.get("two"));
   		assertEquals("3", results.get("Three"));
  
  
  
  1.2       +4 -4      jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/handlers/MapListHandlerTest.java
  
  Index: MapListHandlerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/handlers/MapListHandlerTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MapListHandlerTest.java	23 Oct 2003 01:57:54 -0000	1.1
  +++ MapListHandlerTest.java	25 Oct 2003 22:46:29 -0000	1.2
  @@ -88,13 +88,13 @@
   		List results = (List) h.handle(this.rs);
   
   		assertNotNull(results);
  -		assertEquals(2, results.size());
  +		assertEquals(ROWS, results.size());
   
   		Iterator iter = results.iterator();
           Map row = null;
   		while (iter.hasNext()) {
   			row = (Map) iter.next();
  -			assertEquals(4, row.keySet().size());
  +			assertEquals(COLS, row.keySet().size());
   		}
   
   		assertEquals("4", row.get("one"));
  
  
  
  1.2       +3 -3      jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/handlers/BeanListHandlerTest.java
  
  Index: BeanListHandlerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/handlers/BeanListHandlerTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BeanListHandlerTest.java	23 Oct 2003 01:26:22 -0000	1.1
  +++ BeanListHandlerTest.java	25 Oct 2003 22:46:29 -0000	1.2
  @@ -88,7 +88,7 @@
   		List results = (List) h.handle(this.rs);
   
   		assertNotNull(results);
  -		assertEquals(2, results.size());
  +		assertEquals(ROWS, results.size());
   
   		Iterator iter = results.iterator();
   		TestBean row = null;
  
  
  
  1.3       +5 -5      jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/ResultSetIteratorTest.java
  
  Index: ResultSetIteratorTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/ResultSetIteratorTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ResultSetIteratorTest.java	23 Oct 2003 01:15:34 -0000	1.2
  +++ ResultSetIteratorTest.java	25 Oct 2003 22:46:29 -0000	1.3
  @@ -89,10 +89,10 @@
   			row = (Object[]) iter.next();
   
   			assertNotNull(row);
  -			assertEquals(4, row.length);
  +			assertEquals(COLS, row.length);
   		}
   
  -		assertEquals(2, rowCount);
  +		assertEquals(ROWS, rowCount);
   		assertEquals("4", row[0]);
   		assertEquals("5", row[1]);
   		assertEquals("6", row[2]);
  
  
  
  1.8       +67 -57    jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/BaseTestCase.java
  
  Index: BaseTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/BaseTestCase.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- BaseTestCase.java	25 Oct 2003 20:47:39 -0000	1.7
  +++ BaseTestCase.java	25 Oct 2003 22:46:29 -0000	1.8
  @@ -86,70 +86,80 @@
    */
   public class BaseTestCase extends TestCase {
   
  -	private static final String[] columnNames =
  -		new String[] { "one", "two", "three", "notInBean" };
  +    private static final String[] columnNames =
  +        new String[] { "one", "two", "three", "notInBean" };
   
  -	protected static final ResultSetMetaData metaData =
  -		MockResultSetMetaData.create(columnNames);
  -
  -	private static final Object[][] rows =
  -		new Object[][] { { "1", "2", "3", "  notInBean  " }, {
  -			"4", "5", "6", "  notInBean  " }
  -	};
  -
  -	/**
  -	 * The ResultSet all test methods will use.
  -	 */
  -	protected ResultSet rs = null;
  -
  -	/**
  -	 * A ResultSet with 0 rows.
  -	 */
  -	protected ResultSet emptyResultSet = null;
  -
  -	/**
  -	 * Constructor for BaseTestCase.
  -	 */
  -	public BaseTestCase(String name) {
  -		super(name);
  -	}
  -
  -	/**
  -	 * This is called before each test method so ResultSet will be fresh each
  -	 * time.
  -	 * @see junit.framework.TestCase#setUp()
  -	 */
  -	protected void setUp() throws Exception {
  -		super.setUp();
  -
  -		rs = MockResultSet.create(metaData, rows);
  -		emptyResultSet = MockResultSet.create(metaData, null);
  -	}
  -
  -	/**
  -	 * Return a TestSuite containing all of our test cases.
  -	 */
  -	public static Test suite() {
  -		TestSuite suite = new TestSuite("All DbUtils Tests");
  -
  -		suite.addTestSuite(BasicRowProcessorTest.class);
  -		suite.addTestSuite(ProxyFactoryTest.class);
  -		suite.addTestSuite(ResultSetIteratorTest.class);
  +    /**
  +     * The number of columns in the MockResultSet.
  +     */
  +    protected static final int COLS = 4;
  +
  +    protected static final ResultSetMetaData metaData =
  +        MockResultSetMetaData.create(columnNames);
  +
  +    private static final Object[][] rows =
  +        new Object[][] { { "1", "2", "3", "  notInBean  " }, {
  +            "4", "5", "6", "  notInBean  " }
  +    };
  +    
  +    /**
  +     * The number of rows in the MockResultSet.
  +     */
  +    protected static final int ROWS = 2;
  +
  +    /**
  +     * The ResultSet all test methods will use.
  +     */
  +    protected ResultSet rs = null;
  +
  +    /**
  +     * A ResultSet with 0 rows.
  +     */
  +    protected ResultSet emptyResultSet = null;
  +
  +    /**
  +     * Constructor for BaseTestCase.
  +     */
  +    public BaseTestCase(String name) {
  +        super(name);
  +    }
  +
  +    /**
  +     * This is called before each test method so ResultSet will be fresh each
  +     * time.
  +     * @see junit.framework.TestCase#setUp()
  +     */
  +    protected void setUp() throws Exception {
  +        super.setUp();
  +
  +        rs = MockResultSet.create(metaData, rows);
  +        emptyResultSet = MockResultSet.create(metaData, null);
  +    }
  +
  +    /**
  +     * Return a TestSuite containing all of our test cases.
  +     */
  +    public static Test suite() {
  +        TestSuite suite = new TestSuite("All DbUtils Tests");
  +
  +        suite.addTestSuite(BasicRowProcessorTest.class);
  +        suite.addTestSuite(ProxyFactoryTest.class);
  +        suite.addTestSuite(ResultSetIteratorTest.class);
           suite.addTestSuite(QueryLoaderTest.class);
   
  -		// test handler implementations
  -		suite.addTestSuite(ArrayHandlerTest.class);
  +        // test handler implementations
  +        suite.addTestSuite(ArrayHandlerTest.class);
           suite.addTestSuite(ArrayListHandlerTest.class);
           suite.addTestSuite(BeanHandlerTest.class);
           suite.addTestSuite(BeanListHandlerTest.class);
           suite.addTestSuite(MapHandlerTest.class);
           suite.addTestSuite(MapListHandlerTest.class);
           suite.addTestSuite(ScalarHandlerTest.class);
  -        
  +
           suite.addTestSuite(StringTrimmedResultSetTest.class);
           suite.addTestSuite(SqlNullCheckedResultSetTest.class);
  -        
  -		return suite;
  -	}
  +
  +        return suite;
  +    }
   
   }
  
  
  
  1.3       +9 -9      jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/BasicRowProcessorTest.java
  
  Index: BasicRowProcessorTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/BasicRowProcessorTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BasicRowProcessorTest.java	23 Oct 2003 01:15:34 -0000	1.2
  +++ BasicRowProcessorTest.java	25 Oct 2003 22:46:29 -0000	1.3
  @@ -88,11 +88,11 @@
   		Object[] a = null;
   		while (this.rs.next()) {
   			a = processor.toArray(this.rs);
  -			assertEquals(4, a.length);
  +			assertEquals(COLS, a.length);
   			rowCount++;
   		}
   
  -		assertEquals(2, rowCount);
  +		assertEquals(ROWS, rowCount);
   		assertEquals("4", a[0]);
   		assertEquals("5", a[1]);
   		assertEquals("6", a[2]);
  @@ -108,7 +108,7 @@
   			rowCount++;
   		}
   
  -		assertEquals(2, rowCount);
  +		assertEquals(ROWS, rowCount);
   		assertEquals("4", b.getOne());
   		assertEquals("5", b.getTwo());
   		assertEquals("6", b.getThree());
  @@ -119,7 +119,7 @@
   
   		List list = processor.toBeanList(this.rs, TestBean.class);
   		assertNotNull(list);
  -		assertEquals(2, list.size());
  +		assertEquals(ROWS, list.size());
   
   		TestBean b = (TestBean) list.get(1);
   
  @@ -136,11 +136,11 @@
   		while (this.rs.next()) {
   			m = processor.toMap(this.rs);
   			assertNotNull(m);
  -			assertEquals(4, m.keySet().size());
  +			assertEquals(COLS, m.keySet().size());
   			rowCount++;
   		}
   
  -		assertEquals(2, rowCount);
  +		assertEquals(ROWS, rowCount);
   		assertEquals("4", m.get("One")); // case shouldn't matter
   		assertEquals("5", m.get("two"));
   		assertEquals("6", m.get("THREE"));
  
  
  

---------------------------------------------------------------------
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