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 Sun, 05 Dec 2004 15:17:40 GMT
brj         2004/12/05 07:17:40

  Modified:    src/test/org/apache/ojb/broker QueryTest.java
  Log:
  added new testcases
  
  Revision  Changes    Path
  1.75      +69 -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.74
  retrieving revision 1.75
  diff -u -r1.74 -r1.75
  --- QueryTest.java	15 Sep 2004 17:18:45 -0000	1.74
  +++ QueryTest.java	5 Dec 2004 15:17:40 -0000	1.75
  @@ -34,7 +34,7 @@
   	 */
       public QueryTest(String name)
       {
  -        super(name);
  +        super(name);  
       }
   
       public static void main(String[] args)
  @@ -618,10 +618,27 @@
           Criteria crit = new Criteria();
           crit.addEqualTo("productGroup.groupName", "Liquors");
           Query q = QueryFactory.newQuery(Article.class, crit);
  -        //System.out.println(q.toString());
   
           Collection results = broker.getCollectionByQuery(q);
  -        //System.out.println(results.toString());
  +        assertNotNull(results);
  +        assertTrue(results.size() > 0);
  +
  +        // compare with count
  +        int count = broker.getCount(q);
  +        assertEquals(results.size(), count);
  +    }
  +
  +    /**
  +	 * Single Path Expression
  +	 */
  +    public void testPathExpressionsAndFunctions()
  +    {
  +
  +        Criteria crit = new Criteria();
  +        crit.addEqualTo("upper(productGroup.groupName)", "LIQUORS");
  +        Query q = QueryFactory.newQuery(Article.class, crit);
  +
  +        Collection results = broker.getCollectionByQuery(q);
           assertNotNull(results);
           assertTrue(results.size() > 0);
   
  @@ -1676,6 +1693,55 @@
           assertEquals("check size", list.size(), 1);
       }
   
  +    /**
  +	 * Test pathExpression with projection attribute
  +	 */
  +    public void testPathExpressionWithProjection()
  +    {
  +        // TODO: make path expressions extent aware
  +        if(ojbSkipKnownIssueProblem()) return;
  +
  +        ArrayList list1 = new java.util.ArrayList();
  +
  +        // Read ProductGroup with Articles
  +        Criteria crit1 = new Criteria();
  +        crit1.addLike("groupName", "B%");
  +        crit1.addLike("upper(allArticlesInGroup.articleName)", "F%");
  +
  +        QueryByCriteria q1 = QueryFactory.newQuery(ProductGroup.class, crit1, true);
  +
  +        Iterator iter1 = broker.getIteratorByQuery(q1);
  +        while (iter1.hasNext())
  +        {
  +            list1.add(iter1.next());
  +        }
  +
  +        // ProductGroup 5
  +        assertEquals("check size", list1.size(), 1);
  +
  +        
  +        ArrayList list2 = new java.util.ArrayList();
  +
  +        // Read ProductGroup with Articles
  +        Criteria crit2 = new Criteria();
  +        crit2.addLike("groupName", "B%");
  +        crit2.addLike("upper(allArticlesInGroup.articleName)", "F%");
  +
  +        QueryByCriteria q2 = QueryFactory.newQuery(ProductGroup.class, crit2, true);
  +        // set searchclass to Article
  +        q2.setObjectProjectionAttribute("allArticlesInGroup");
  +
  +        Iterator iter2 = broker.getIteratorByQuery(q2);
  +        while (iter2.hasNext())
  +        {
  +            list2.add(iter2.next());
  +        }
  +
  +        // ProductGroup 5
  +        assertEquals("check size", list2.size(), 1);
  +        
  +    }
  +    
       /**
   	 * Test ReportQuery and Alias
   	 */
  
  
  

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