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 Thu, 20 Nov 2003 20:58:35 GMT
brj         2003/11/20 12:58:35

  Modified:    src/test/org/apache/ojb/broker PersistenceBrokerTest.java
  Log:
  additional testcase for paging
  
  Revision  Changes    Path
  1.34      +78 -1     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.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- PersistenceBrokerTest.java	20 Nov 2003 19:47:47 -0000	1.33
  +++ PersistenceBrokerTest.java	20 Nov 2003 20:58:35 -0000	1.34
  @@ -738,7 +738,7 @@
           assertEquals("size of iterator should be one", 1, ojbIter.size());
           InterfaceArticle test4 = (InterfaceArticle) ojbIter.next();
           assertEquals("should be same value - id number", 5004, test4.getArticleId());
  -        
  +        ojbIter.releaseDbResources();
       }
   
       /**
  @@ -1360,6 +1360,83 @@
           set.addAll(result);
   
           assertEquals("Both sizes must be equal", set.size(), result.size());     
  +    }
  +    
  +    public void testPaging()
  +    {
  +        OJBIterator ojbIter;
  +        Criteria crit;
  +        QueryByCriteria query;
  +        int fullSize;
  +        
  +        // All Articles index in range
  +        crit = new Criteria();
  +        query = QueryFactory.newQuery(Article.class, crit);
  +        fullSize = broker.getCollectionByQuery(query).size();
  +        
  +        query.setStartAtIndex(10);
  +        query.setEndAtIndex(14);       
  +        ojbIter = (OJBIterator)broker.getIteratorByQuery(query);
  +        assertEquals("index 10 - 14 expecting 5 rows", 5,ojbIter.size());
  +        ojbIter.releaseDbResources();
  +    }
  +
  +    public void testPagingIndicesOutOfRange()
  +    {
  +        OJBIterator ojbIter;
  +        Criteria crit;
  +        QueryByCriteria query;
  +        int fullSize;
  +        
  +        // All Articles index out of  range
  +        crit = new Criteria();
  +        query = QueryFactory.newQuery(Article.class, crit);
  +        fullSize = broker.getCollectionByQuery(query).size();
  +        
  +        query.setStartAtIndex(fullSize + 5);
  +        query.setEndAtIndex(fullSize + 14);        
  +        ojbIter = (OJBIterator)broker.getIteratorByQuery(query);
  +        assertEquals("indices out of range expecting 0 rows", 0,ojbIter.size());
  +        ojbIter.releaseDbResources();      
  +    }
  +
  +    public void testPagingEndIndexOutOfRange()
  +    {
  +        OJBIterator ojbIter;
  +        Criteria crit;
  +        QueryByCriteria query;
  +        int fullSize;
  +        
  +        // All Articles index out of  range
  +        crit = new Criteria();
  +        query = QueryFactory.newQuery(Article.class, crit);
  +        fullSize = broker.getCollectionByQuery(query).size();
  +        
  +        query.setStartAtIndex(fullSize - 9);
  +        query.setEndAtIndex(fullSize + 9);        
  +        ojbIter = (OJBIterator)broker.getIteratorByQuery(query);
  +        assertEquals("end index out of range expecting 10 rows", 10,ojbIter.size());
  +        ojbIter.releaseDbResources();      
  +    }
  +    
  +    public void testPagingEmptyIterator()
  +    {
  +        OJBIterator ojbIter;
  +        Criteria crit;
  +        QueryByCriteria query;
  +        int fullSize;
  +        
  +        // looking for inexistent Article    
  +        crit = new Criteria();
  +        crit.addEqualTo("articleId",new Integer(-777));
  +        query = QueryFactory.newQuery(Article.class, crit);
  +        fullSize = broker.getCollectionByQuery(query).size();
  +        
  +        query.setStartAtIndex(10);
  +        query.setEndAtIndex(14);        
  +        ojbIter = (OJBIterator)broker.getIteratorByQuery(query);
  +        assertEquals("index 10 - 14 expecting 0 rows for empty iterator", 0,ojbIter.size());
  +        ojbIter.releaseDbResources();       
       }
       
   }
  
  
  

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