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/odmg OQLTest.java
Date Mon, 13 Oct 2003 16:48:58 GMT
brj         2003/10/13 09:48:58

  Modified:    src/test/org/apache/ojb/odmg OQLTest.java
  Log:
  added testcase for group by (functions not yet supported)
  
  Revision  Changes    Path
  1.12      +82 -0     db-ojb/src/test/org/apache/ojb/odmg/OQLTest.java
  
  Index: OQLTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/odmg/OQLTest.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- OQLTest.java	24 Jun 2003 21:45:21 -0000	1.11
  +++ OQLTest.java	13 Oct 2003 16:48:58 -0000	1.12
  @@ -349,4 +349,86 @@
   		tx.commit();
   		assertEquals(3, food.size());
   	}
  +    
  +    /**
  +     * 
  +     */
  +    public void _testFunctions() throws Exception
  +    {
  +        Implementation odmg = OJB.getInstance();
  +        Database db = odmg.newDatabase();
  +        db.open(databaseName, Database.OPEN_READ_WRITE);
  +
  +        Transaction tx = odmg.newTransaction();
  +        tx.begin();
  +
  +        OQLQuery query = odmg.newOQLQuery();
  +        query.create("select anArticle from " + 
  +                Article.class.getName() +
  +                " where upper(articleName) like \"A%\" ");
  +        
  +        List results = (List) query.execute();
  +        tx.commit();
  +        assertTrue(results.size() > 0);
  +        db.close();
  +    }    
  +
  +    /**
  +     * ReportQuery returning rows with summed stock and price per article group
  +     */
  +    public void testReportQueryGroupBy() throws Exception
  +    {
  +        Implementation odmg = OJB.getInstance();
  +        Database db = odmg.newDatabase();
  +        db.open(databaseName, Database.OPEN_READ_WRITE);
  +
  +        Transaction tx = odmg.newTransaction();
  +        tx.begin();
  +
  +        OQLQuery query = odmg.newOQLQuery();
  +        query.create("select p.groupName, p.allArticlesInGroup.stock, p.allArticlesInGroup.price"
+
  +               " from " + ProductGroup.class.getName() +
  +               " group by groupName");
  +
  +//        query.create("select p.groupName, sum(p.allArticlesInGroup.stock), sum(p.allArticlesInGroup.price)"
+
  +//               " from " + ProductGroup.class.getName() +
  +//               " group by groupName");
  +
  +        List results = (List) query.execute();
  +        tx.commit();
  +        assertTrue(results.size() > 0);
  +        db.close();
  +    }    
  +    
  +    
  +    /**
  +     * test Subquery
  +     * get all articles with price > avg(price)
  +     * PROBLEM: avg(price) is NOT extent aware !!
  +     *
  +     * test may fail if db does not support sub queries
  +     */
  +    public void _testSubQuery1() throws Exception
  +    {
  +        Implementation odmg = OJB.getInstance();
  +        Database db = odmg.newDatabase();
  +        db.open(databaseName, Database.OPEN_READ_WRITE);
  +
  +        Transaction tx = odmg.newTransaction();
  +        tx.begin();
  +     
  +        OQLQuery query = odmg.newOQLQuery();
  +        query.create("select anArticle from " + 
  +                Article.class.getName() + 
  +                " where " + 
  +                " price >= (select avg(price) from " + 
  +                Article.class.getName() +
  +                " where articleName like \"A%\") ");
  +
  +        List results = (List) query.execute();
  +        tx.commit();
  +        assertTrue(results.size() > 0);
  +        db.close();
  +    }
  +    
   }
  
  
  

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