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, 14 Jan 2005 20:50:15 GMT
brj         2005/01/14 12:50:15

  Modified:    src/test/org/apache/ojb/broker QueryTest.java
  Log:
  added testcase for attributes in expressions (price + 1.0)
  
  Revision  Changes    Path
  1.78      +20 -15    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.77
  retrieving revision 1.78
  diff -u -r1.77 -r1.78
  --- QueryTest.java	10 Jan 2005 20:46:46 -0000	1.77
  +++ QueryTest.java	14 Jan 2005 20:50:15 -0000	1.78
  @@ -11,8 +11,8 @@
   import java.util.Vector;
   
   import org.apache.commons.lang.time.StopWatch;
  -import org.apache.commons.beanutils.PropertyUtils;
   import org.apache.ojb.broker.ReferenceTest.Region;
  +import org.apache.ojb.broker.accesslayer.sql.SqlGenerator;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.platforms.PlatformHsqldbImpl;
   import org.apache.ojb.broker.query.Criteria;
  @@ -883,7 +883,6 @@
        */
       public void testDistinctMultiPk()
       {
  -
           Criteria crit = new Criteria();
           crit.addEqualTo("project_id", new Integer(1));
           QueryByCriteria q = QueryFactory.newQuery(Role.class, crit, true);
  @@ -1062,7 +1061,6 @@
        */
       public void _testReportQueryWithStartAndEnd()
       {
  -
           Criteria crit = new Criteria();
           Collection results = new Vector();
           crit.addLike("firstname", "%o%");
  @@ -1088,7 +1086,6 @@
        */
       public void testReportQueryExtent()
       {
  -
           Criteria crit = new Criteria();
           Collection results = new Vector();
           crit.addLike("articleName", "%o%");
  @@ -1226,7 +1223,6 @@
           // compare with count
           int count = broker.getCount(q);
           assertEquals(results.size(), count);
  -
       }
   
       /**
  @@ -1234,7 +1230,6 @@
        */
       public void testReportQueryOrderBy()
       {
  -
           Criteria crit = new Criteria();
           Collection results = new Vector();
           crit.addEqualTo("productGroup.groupName", "Liquors");
  @@ -1253,7 +1248,6 @@
           // compare with count
           int count = broker.getCount(q);
           assertEquals(results.size(), count);
  -
       }
   
       /**
  @@ -1261,7 +1255,6 @@
        */
       public void testReportQueryOrderByNonSelectColumn()
       {
  -
           Criteria crit = new Criteria();
           Collection results = new Vector();
           crit.addEqualTo("productGroup.groupName", "Liquors");
  @@ -1280,7 +1273,6 @@
           // compare with count
           int count = broker.getCount(q);
           assertEquals(results.size(), count);
  -
       }
   
       /**
  @@ -1453,7 +1445,6 @@
           //
           assertEquals("Check size", articleSize, articleSize2);
           assertEquals("Check content", articleString, articleString2);
  -
       }
   
       /**
  @@ -1658,7 +1649,6 @@
           //
           assertEquals("Check size", pgs.size(), pgs2.size());
           assertEquals("Check content", pgsString, pgsString2);
  -
       }
   
       /**
  @@ -1692,7 +1682,6 @@
        */
       public void testQueryOrderByNonSelectColumn()
       {
  -
           Criteria crit = new Criteria();
           Collection results = new Vector();
           crit.addEqualTo("productGroup.groupName", "Liquors");
  @@ -1706,7 +1695,6 @@
               results.add(iter.next());
           }
           assertTrue(results.size() > 0);
  -
       }
   
       /**
  @@ -1801,6 +1789,25 @@
       }
   
       /**
  +     * ReportQuery with Expression in column need to add table alias to the field (price)
  +     **/
  +    public void testReportQueryExpressionInStatement()
  +    {
  +        // TODO: Resolve attributes of expressions
  +        if(ojbSkipKnownIssueProblem("Resolve attributes of expressions")) return;
  +
  +        Criteria crit = new Criteria();
  +        ReportQueryByCriteria q = QueryFactory.newReportQuery(Article.class, crit);
  +        q.setAttributes(new String[]{"articleId", "price + 0"});
  +        ClassDescriptor cd = broker.getClassDescriptor(q.getBaseClass());
  +        SqlGenerator sqlg = broker.serviceSqlGenerator();
  +        String sql = sqlg.getPreparedSelectStatement(q, cd);
  +        
  +        assertTrue("Bad query generated. the 'price' field has not table prefix. SQL Output:
" + sql, sql
  +                .equalsIgnoreCase("SELECT A0.Artikel_Nr,A0.PRICE + 0 FROM Artikel A0"));
  +    }
  +
  +    /**
        * Test pathExpression and Extents
        */
       public void testPathExpressionForExtents1()
  @@ -1842,7 +1849,6 @@
   
           // ProductGroups 4 and 5
           assertEquals("check size", list.size(), 2);
  -
       }
   
       /**
  @@ -2089,7 +2095,6 @@
        */
       private void runQueryRangeTest(int delta)
       {
  -
           // How many records are there in the table?
           Query countQuery = QueryFactory.newQuery(ProductGroup.class, null, false);
   
  
  
  

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