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 PersistenceBrokerTest.java
Date Fri, 12 Mar 2004 19:48:35 GMT
brj         2004/03/12 11:48:35

  Modified:    src/test/org/apache/ojb/broker PersistenceBrokerTest.java
  Log:
  additional tests for multiKey count and paging
  
  Revision  Changes    Path
  1.40      +61 -0     db-ojb/src/test/org/apache/ojb/broker/PersistenceBrokerTest.java
  
  Index: PersistenceBrokerTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/PersistenceBrokerTest.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- PersistenceBrokerTest.java	25 Feb 2004 00:32:11 -0000	1.39
  +++ PersistenceBrokerTest.java	12 Mar 2004 19:48:35 -0000	1.40
  @@ -1060,6 +1060,18 @@
           assertEquals("Count should be 12", 12, count);
       }
   
  +    public void testMultiKeyCount() throws Exception
  +    {
  +        Criteria criteria = new Criteria();
  +        QueryByCriteria query1 = QueryFactory.newQuery(Role.class, criteria);
  +        QueryByCriteria query2 = QueryFactory.newQuery(Role.class, criteria,true);
  +        
  +        int count1 = broker.getCount(query1);
  +        int count2 = broker.getCount(query2);
  +        
  +        assertEquals("count and count distinct must match", count1, count2);
  +    }
  +    
       /**
        * extent aware iterator
        */
  @@ -1606,6 +1618,55 @@
           ojbIter.releaseDbResources();
       }
   
  +    public void testPagingPosition()
  +    {
  +        OJBIterator ojbIter;
  +        Criteria crit;
  +        QueryByCriteria query;
  +        Collection fullColl, pagedColl;
  +        InterfaceArticle article;
  +        
  +        // All Articles index in range
  +        crit = new Criteria();
  +        query = QueryFactory.newQuery(Article.class, crit);
  +        query.addOrderByAscending("articleId");
  +        fullColl = broker.getCollectionByQuery(query);
  +        
  +        // limited query
  +        query.setStartAtIndex(10);
  +        query.setEndAtIndex(14);
  +        pagedColl = broker.getCollectionByQuery(query);
  +                      
  +        ojbIter = (OJBIterator)broker.getIteratorByQuery(query);
  +        
  +        assertEquals("collection- and iterator-size must match", pagedColl.size(), ojbIter.size());
  +        assertEquals("index 10 - 14 expecting 5 rows", 5,ojbIter.size());
  +        
  +        ojbIter.absolute(2);
  +        article = (InterfaceArticle)ojbIter.next();
  +        assertEquals("Article id=12", article.getArticleId(), 12);
  +        
  +        ojbIter.relative(-1);
  +        article = (InterfaceArticle)ojbIter.next();
  +        assertEquals("Article id=12", article.getArticleId(), 12);
  +
  +        ojbIter.relative(-1);
  +        article = (InterfaceArticle)ojbIter.next();
  +        assertEquals("Article id=12", article.getArticleId(), 12);
  +        
  +        // last
  +        ojbIter.absolute(12);
  +        article = (InterfaceArticle)ojbIter.next();
  +        assertEquals("Article id=15", article.getArticleId(), 15);
  +
  +        // first
  +        ojbIter.absolute(-12);
  +        article = (InterfaceArticle)ojbIter.next();
  +        assertEquals("Article id=10", article.getArticleId(), 10);
  +        
  +        ojbIter.releaseDbResources();
  +    }
  +    
       public void testPagingIndicesOutOfRange()
       {
           OJBIterator ojbIter;
  
  
  

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