db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb/broker ExtentAwarePathExpressionsTest.java
Date Tue, 15 Nov 2005 02:17:06 GMT
arminw      2005/11/14 18:17:06

  Modified:    src/test/org/apache/ojb/broker Tag: OJB_1_0_RELEASE
                        ExtentAwarePathExpressionsTest.java
  Log:
  add test for OJB-62
  add test using multiple class path for same reference field
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.7.2.4   +85 -20    db-ojb/src/test/org/apache/ojb/broker/ExtentAwarePathExpressionsTest.java
  
  Index: ExtentAwarePathExpressionsTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/ExtentAwarePathExpressionsTest.java,v
  retrieving revision 1.7.2.3
  retrieving revision 1.7.2.4
  diff -u -r1.7.2.3 -r1.7.2.4
  --- ExtentAwarePathExpressionsTest.java	13 Nov 2005 15:45:54 -0000	1.7.2.3
  +++ ExtentAwarePathExpressionsTest.java	15 Nov 2005 02:17:05 -0000	1.7.2.4
  @@ -17,15 +17,8 @@
    */
   public class ExtentAwarePathExpressionsTest extends PBTestCase
   {
  -    /**
  -     * You can run the test like a java app 
  -     */
       public static void main(String[] args)
       {
  -        //OBS: when running this test from eclipse, one must copy the database file to
the directory where 
  -        //u checked out ojb from cvs
  -//        URL url = ClassHelper.getResource("DB.script");
  -//        System.out.println("Hsql database @ :" + url);
           String[] arr = {ExtentAwarePathExpressionsTest.class.getName()};
           junit.textui.TestRunner.main(arr);
       }
  @@ -35,18 +28,6 @@
           super(testName);
       }
   
  -//    public static Test suite()
  -//    {
  -//        TestSuite suite = new TestSuite();
  -//        //suite.addTest(new ExtentAwarePathExpressionsTest("testAddPathClass"));
  -//        suite.addTest(new ExtentAwarePathExpressionsTest("testAddPathClasses"));
  -//        //suite.addTest(new ExtentAwarePathExpressionsTest("testNotNullPathElement"));
  -//        //suite.addTest(new ExtentAwarePathExpressionsTest("testSetPathClass"));
  -//        //suite.addTest(new ExtentAwarePathExpressionsTest("testWithoutHintClass1"));
  -//        //suite.addTest(new ExtentAwarePathExpressionsTest("testWithoutHintClass2"));
  -//        return suite;
  -//    }
  -
       public void testWithoutHintClass1() throws Exception
       {
           Criteria criteria = new Criteria();
  @@ -261,4 +242,88 @@
           assertNotNull(((News)content.get(0)).getQualifiers());
           assertEquals(3, ((News)content.get(0)).getQualifiers().size());
       }
  +
  +    // Test for OJB-62
  +    public void testAddClassPathOnQuery_1()
  +    {
  +        Criteria criteria = new Criteria();
  +        criteria.addLike("qualifiers.importance", "impor%");
  +        QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria,
true);
  +        query.addPathClass("qualifiers", Topic.class);
  +        List content = (List) broker.getCollectionByQuery(query);
  +
  +        assertEquals(1, content.size());
  +        assertEquals(2, ((News)content.get(0)).getId());
  +        assertNotNull(((News)content.get(0)).getQualifiers());
  +        assertEquals(3, ((News)content.get(0)).getQualifiers().size());
  +    }
  +
  +    // Test for OJB-62
  +    public void testAddClassPathOnQuery_2()
  +    {
  +        Criteria criteria = new Criteria();
  +        criteria.addLike("qualifiers.importance", "NO_MATCH%");
  +        QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria,
true);
  +        query.addPathClass("qualifiers", Topic.class);
  +        List content = (List) broker.getCollectionByQuery(query);
  +
  +        assertEquals(0, content.size());
  +    }
  +
  +    // Test multiple path class on query object
  +    public void testMultipleClassPath_1a()
  +    {
  +        Criteria criteria = new Criteria();
  +        criteria.addLike("headline", "SAL%");
  +        criteria.addEqualTo("qualifiers.importance", "unimportant");
  +        criteria.addEqualTo("qualifiers.name", "Sellers");
  +        QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria,
true);
  +        //query.addPathClass("qualifiers", Qualifier.class);
  +        query.addPathClass("qualifiers", Topic.class);
  +        query.addPathClass("qualifiers", TopicExt.class);
  +        List content = (List) broker.getCollectionByQuery(query);
  +
  +        assertEquals(1, content.size());
  +        assertEquals(11, ((Paper)content.get(0)).getId());
  +        assertNotNull(((Paper)content.get(0)).getQualifiers());
  +        assertEquals(2, ((Paper)content.get(0)).getQualifiers().size());
  +    }
  +
  +    // Test multiple path class on criteria object
  +    public void testMultipleClassPath_1b()
  +    {
  +        Criteria criteria = new Criteria();
  +        criteria.addLike("headline", "SAL%");
  +        criteria.addEqualTo("qualifiers.importance", "unimportant");
  +        criteria.addEqualTo("qualifiers.name", "Sellers");
  +        criteria.addPathClass("qualifiers", Qualifier.class);
  +        criteria.addPathClass("qualifiers", TopicExt.class);
  +        criteria.addPathClass("qualifiers", Topic.class);
  +        QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria,
true);
  +        List content = (List) broker.getCollectionByQuery(query);
  +
  +        assertEquals(1, content.size());
  +        assertEquals(11, ((Paper)content.get(0)).getId());
  +        assertNotNull(((Paper)content.get(0)).getQualifiers());
  +        assertEquals(2, ((Paper)content.get(0)).getQualifiers().size());
  +    }
  +
  +    // Test multiple path class on query object
  +    public void testMultipleClassPath_1c()
  +    {
  +        Criteria criteria = new Criteria();
  +        criteria.addLike("headline", "SAL%");
  +        criteria.addEqualTo("qualifiers.importance", "unimportant");
  +        criteria.addEqualTo("qualifiers.name", "Sellers");
  +        //criteria.addPathClass("qualifiers", Qualifier.class);
  +        criteria.addPathClass("qualifiers", TopicExt.class);
  +        criteria.addPathClass("qualifiers", Topic.class);
  +        QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria,
true);
  +        List content = (List) broker.getCollectionByQuery(query);
  +
  +        assertEquals(1, content.size());
  +        assertEquals(11, ((Paper)content.get(0)).getId());
  +        assertNotNull(((Paper)content.get(0)).getQualifiers());
  +        assertEquals(2, ((Paper)content.get(0)).getQualifiers().size());
  +    }
   }
  
  
  

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