db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb/broker QueryTest.java
Date Fri, 23 Jul 2004 11:49:46 GMT
brj         2004/07/23 04:49:46

  Modified:    src/test/org/apache/ojb/broker QueryTest.java
  Log:
  added testcase for Criteria#addSql
  
  Revision  Changes    Path
  1.66      +40 -0     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.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- QueryTest.java	23 Jul 2004 11:31:24 -0000	1.65
  +++ QueryTest.java	23 Jul 2004 11:49:46 -0000	1.66
  @@ -116,6 +116,46 @@
       }
   
       /**
  +	 * test sql Criteria
  +	 */
  +    public void testSqlCriteria()
  +    {
  +        Criteria crit; 
  +        Query q;
  +        Collection results;
  +        
  +        // sql only
  +        crit = new Criteria();
  +        crit.addSql("upper(firstname) = 'TOM' and id = 1");
  +        q = QueryFactory.newQuery(Person.class, crit);
  +
  +        results = broker.getCollectionByQuery(q);
  +        int size1 = results.size();
  +        
  +        // sql plus attribute 
  +        crit = new Criteria();
  +        crit.addSql("upper(firstname) = 'TOM'");
  +        crit.addEqualTo("id",new Integer(1));
  +        q = QueryFactory.newQuery(Person.class, crit);
  +
  +        results = broker.getCollectionByQuery(q);
  +        int size2 = results.size();
  +        
  +        // attribute plus sql 
  +        crit = new Criteria();
  +        crit.addEqualTo("upper(firstname)","TOM");
  +        crit.addSql("id = 1");
  +        q = QueryFactory.newQuery(Person.class, crit);
  +
  +        results = broker.getCollectionByQuery(q);
  +        int size3 = results.size();
  +        
  +        assertTrue(size2 == size1);
  +        assertTrue(size3 == size2);
  +    }
  +
  +   
  +    /**
   	 * test OrderBy and Count
   	 */
       public void testOrderByCount()
  
  
  

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


Mime
View raw message