You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by br...@apache.org on 2004/01/29 21:51:00 UTC

cvs commit: db-ojb/src/test/org/apache/ojb/broker QueryTest.java

brj         2004/01/29 12:51:00

  Modified:    src/test/org/apache/ojb/broker QueryTest.java
  Log:
  testcase for report-queries using jdbctypes
  
  Revision  Changes    Path
  1.48      +45 -3     db-ojb/src/test/org/apache/ojb/broker/QueryTest.java
  
  Index: QueryTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/QueryTest.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- QueryTest.java	30 Dec 2003 19:15:31 -0000	1.47
  +++ QueryTest.java	29 Jan 2004 20:50:59 -0000	1.48
  @@ -1,5 +1,7 @@
   package org.apache.ojb.broker;
   
  +import java.math.BigDecimal;
  +import java.sql.Types;
   import java.util.ArrayList;
   import java.util.Arrays;
   import java.util.Collection;
  @@ -341,7 +343,7 @@
       }
   
       /**
  -	 * Simple ReportQuery returning rows with 2 columns of Person
  +	 * Simple ReportQuery returning rows with 3 columns of Person
   	 */
       public void testReportQuery()
       {
  @@ -358,12 +360,52 @@
           assertNotNull(iter);
           while (iter.hasNext())
           {
  -            results.add(iter.next());
  +            Object[] row = (Object[])iter.next();
  +            assertEquals(row.length, 3);
  +            
  +            results.add(row);
           }
  -        assertTrue(results.size() > 0);
  +        
  +        assertEquals(results.size(), 5);
   
       }
   
  +    /**
  +     * Simple ReportQuery returning rows with 3 columns of Person
  +     * Type of column data defined by sqltypes
  +     * @see java.sql.Types
  +     */
  +    public void testReportQueryWithJdbcTypes()
  +    {
  +        Criteria crit = new Criteria();
  +        Collection results = new Vector();
  +        int types[] = new int[]{Types.DECIMAL, Types.VARCHAR, Types.BIGINT};
  +        
  +        crit.addLike("firstname", "%o%");
  +        ReportQueryByCriteria q = QueryFactory.newReportQuery(Person.class, crit);
  +        q.setColumns(new String[] { "id", "firstname", "count(*)" });
  +        q.addGroupBy(new String[] { "id", "firstname" });
  +        q.setJdbcTypes(types);
  +
  +        Iterator iter = broker.getReportQueryIteratorByQuery(q);
  +
  +        assertNotNull(iter);
  +        while (iter.hasNext())
  +        {
  +            Object[] row = (Object[])iter.next();
  +            assertEquals(row.length, 3);
  +            
  +//            assertEquals(row[0].getClass(), BigDecimal.class);
  +//            assertEquals(row[1].getClass(), String.class);
  +//            assertEquals(row[2].getClass(), Long.class);
  +
  +            results.add(row);
  +        }
  +        
  +        assertEquals(results.size(), 5);
  +
  +    }
  +    
       /**
   	 * Simple ReportQuery returning rows with 2 columns of Person
        * needs SQL paging
  
  
  

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