db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb repository_junit.xml
Date Tue, 21 Jun 2005 10:53:45 GMT
tomdz       2005/06/21 03:53:45

  Modified:    src/test/org/apache/ojb/broker Tag: OJB_1_0_RELEASE
                        Category.java ExtentAwarePathExpressionsTest.java
                        Topic.java
               src/schema Tag: OJB_1_0_RELEASE ojbtest-schema.xml
                        ojbtest-data.dtd ojbtest-data.xml
               src/test/org/apache/ojb Tag: OJB_1_0_RELEASE
                        repository_junit.xml
  Log:
  Added unit tests for setting the path class at the criteria instead of the query
  Added unit test for bug OJB-50
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.2.4.1   +11 -5     db-ojb/src/test/org/apache/ojb/broker/Category.java
  
  Index: Category.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/Category.java,v
  retrieving revision 1.2
  retrieving revision 1.2.4.1
  diff -u -r1.2 -r1.2.4.1
  --- Category.java	10 Jul 2003 22:05:18 -0000	1.2
  +++ Category.java	21 Jun 2005 10:53:45 -0000	1.2.4.1
  @@ -4,21 +4,27 @@
    * 
    * @author <a href="leandro@ibnetwork.com.br">Leandro Rodrigo Saad Cruz</a>
    */
  -public class Category 
  -    extends BaseQualifierImpl
  +public class Category extends BaseQualifierImpl
   {
  +    private String description;
   
       public Category()
       {
           super();
       }
       
  -    /**
  -     * @param i
  -     */
       public Category(int id)
       {
           super(id);
       }
   
  +    public String getDescription()
  +    {
  +        return description;
  +    }
  +
  +    public void setDescription(String value)
  +    {
  +        description = value;
  +    }
   }
  
  
  
  1.7.2.1   +72 -1     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
  retrieving revision 1.7.2.1
  diff -u -r1.7 -r1.7.2.1
  --- ExtentAwarePathExpressionsTest.java	1 Jun 2004 19:15:24 -0000	1.7
  +++ ExtentAwarePathExpressionsTest.java	21 Jun 2005 10:53:45 -0000	1.7.2.1
  @@ -124,6 +124,26 @@
   
       }
       
  +    public void testSetPathClassInCriteria()
  +    {
  +        Criteria criteria = new Criteria();
  +
  +        criteria.addNotNull("qualifiers.name");
  +        criteria.setPathClass("qualifiers", Category.class);
  +
  +        QueryByCriteria query   = new QueryByCriteria(BaseContentImpl.class, criteria,
true);
  +        List            content = (List)broker.getCollectionByQuery(query);
  +
  +        assertEquals(2,content.size());
  +        for (Iterator iter = content.iterator(); iter.hasNext();)
  +        {
  +            BaseContentImpl element = (BaseContentImpl) iter.next();
  +
  +            assertTrue(element.getId() <=3 && element.getId() >=2);
  +        }
  +
  +    }
  +
       public void testAddPathClass()
       {
           Criteria criteria = new Criteria();
  @@ -136,6 +156,20 @@
           assertEquals(10,((Paper)content.get(0)).getId());
       }
   
  +    public void testAddPathClassInCriteria()
  +    {
  +        Criteria criteria = new Criteria();
  +
  +        criteria.addNotNull("qualifiers.name");
  +        criteria.addPathClass("qualifiers", Qualifier.class);
  +        criteria.addPathClass("qualifiers", Area.class);
  +
  +        QueryByCriteria query   = new QueryByCriteria(BaseContentImpl.class, criteria,
true);
  +        List            content = (List)broker.getCollectionByQuery(query);
  +
  +        assertEquals(1, content.size());
  +        assertEquals(10, ((Paper)content.get(0)).getId());
  +    }
   
       /**
        * The order of criteria elements influences the use of parenthesis, 
  @@ -159,4 +193,41 @@
           assertEquals(3,((News)content.get(0)).getId());
       }
   
  +    public void testAddPathClassesInCriteria()
  +    {
  +        Criteria criteria = new Criteria();
  +        
  +        criteria.addLike("headline", "Bra%");
  +        criteria.addNotNull("qualifiers.name");
  +        criteria.addPathClass("qualifiers", Qualifier.class);
  +        criteria.addPathClass("qualifiers", Topic.class);
  +        criteria.addPathClass("qualifiers", Category.class);
  +
  +        QueryByCriteria query   = new QueryByCriteria(BaseContentImpl.class, criteria,
true);
  +        List            content = (List)broker.getCollectionByQuery(query);
  +
  +        assertEquals(1, content.size());
  +        assertEquals(3, ((News)content.get(0)).getId());
  +    }
  +
  +    // Test for OJB-50
  +    public void testComplexCriteriaWithPathClasses()
  +    {
  +        Criteria criteria         = new Criteria();
  +        Criteria categoryCriteria = new Criteria();
  +        Criteria topicCriteria    = new Criteria();
  +
  +        topicCriteria.addEqualTo("qualifiers.importance", "important");
  +        topicCriteria.addPathClass("qualifiers", Topic.class);
  +        criteria.addOrCriteria(topicCriteria);
  +        categoryCriteria.addNotNull("qualifiers.description");
  +        categoryCriteria.addPathClass("qualifiers", Category.class);
  +        criteria.addOrCriteria(categoryCriteria);
  +
  +        QueryByCriteria query   = new QueryByCriteria(BaseContentImpl.class, criteria,
true);
  +        List            content = (List)broker.getCollectionByQuery(query);
  +
  +        assertEquals(1, content.size());
  +        assertEquals(2, ((News)content.get(0)).getId());
  +    }
   }
  
  
  
  1.1.4.1   +10 -0     db-ojb/src/test/org/apache/ojb/broker/Topic.java
  
  Index: Topic.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/Topic.java,v
  retrieving revision 1.1
  retrieving revision 1.1.4.1
  diff -u -r1.1 -r1.1.4.1
  --- Topic.java	9 Apr 2003 13:33:31 -0000	1.1
  +++ Topic.java	21 Jun 2005 10:53:45 -0000	1.1.4.1
  @@ -7,5 +7,15 @@
   public class Topic 
       extends BaseQualifierImpl
   {
  +    private String importance;
   
  +    public String getImportance()
  +    {
  +        return importance;
  +    }
  +
  +    public void setImportance(String value)
  +    {
  +        importance = value;
  +    }
   }
  
  
  
  No                   revision
  No                   revision
  1.80.2.24 +3 -1      db-ojb/src/schema/ojbtest-schema.xml
  
  Index: ojbtest-schema.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/schema/ojbtest-schema.xml,v
  retrieving revision 1.80.2.23
  retrieving revision 1.80.2.24
  diff -u -r1.80.2.23 -r1.80.2.24
  --- ojbtest-schema.xml	10 May 2005 19:09:19 -0000	1.80.2.23
  +++ ojbtest-schema.xml	21 Jun 2005 10:53:45 -0000	1.80.2.24
  @@ -487,12 +487,14 @@
     <table name="TOPIC">
       <column name="ID" required="true" primaryKey="true" type="INTEGER"/>
       <column name="NAME" type="VARCHAR" size="50"/>
  +    <column name="IMPORTANCE" type="VARCHAR" size="50"/>
     </table>
   
     <!-- Qualifier -->
     <table name="CATEGORY">
       <column name="ID" required="true" primaryKey="true" type="INTEGER"/>
       <column name="NAME" type="VARCHAR" size="50"/>
  +    <column name="DESCRIPTION" type="VARCHAR" size="50"/>
     </table>
   
     <!-- Qualifier -->
  
  
  
  1.14.2.3  +2 -0      db-ojb/src/schema/ojbtest-data.dtd
  
  Index: ojbtest-data.dtd
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/schema/ojbtest-data.dtd,v
  retrieving revision 1.14.2.2
  retrieving revision 1.14.2.3
  diff -u -r1.14.2.2 -r1.14.2.3
  --- ojbtest-data.dtd	15 Dec 2004 12:39:23 -0000	1.14.2.2
  +++ ojbtest-data.dtd	21 Jun 2005 10:53:45 -0000	1.14.2.3
  @@ -314,12 +314,14 @@
   <!ATTLIST Category
     Id CDATA #REQUIRED
     Name CDATA #IMPLIED
  +  Description CDATA #IMPLIED
   >
   
   <!ELEMENT Topic EMPTY>
   <!ATTLIST Topic
     Id CDATA #REQUIRED
     Name CDATA #IMPLIED
  +  Importance CDATA #IMPLIED
   >
   
   <!ELEMENT Area EMPTY>
  
  
  
  1.15.2.5  +4 -4      db-ojb/src/schema/ojbtest-data.xml
  
  Index: ojbtest-data.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/schema/ojbtest-data.xml,v
  retrieving revision 1.15.2.4
  retrieving revision 1.15.2.5
  diff -u -r1.15.2.4 -r1.15.2.5
  --- ojbtest-data.xml	4 Mar 2005 23:33:47 -0000	1.15.2.4
  +++ ojbtest-data.xml	21 Jun 2005 10:53:45 -0000	1.15.2.5
  @@ -183,11 +183,11 @@
       <Paper Id="10" Headline="NONE" Issuedate="today" Author="NONE"/>
       <Paper Id="11" Headline="SALES" Issuedate="yesterday" Author="SALES MAN"/>
   
  -    <Category Id="1" Name="Cars" />
  -    <Category Id="2" Name="Sports" />
  +    <Category Id="1" Name="Cars" Description="The cars category"/>
  +    <Category Id="2" Name="Sports"/>
   
  -    <Topic Id="10" Name="Buyers" />
  -    <Topic Id="11" Name="Sellers" />
  +    <Topic Id="10" Name="Buyers" Importance="important"/>
  +    <Topic Id="11" Name="Sellers" Importance="unimportant"/>
   
       <Area Id="20" Name="Human"/>
       <Area Id="21" Name="NotHuman"/>
  
  
  
  No                   revision
  No                   revision
  1.112.2.15 +3 -1      db-ojb/src/test/org/apache/ojb/repository_junit.xml
  
  Index: repository_junit.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/repository_junit.xml,v
  retrieving revision 1.112.2.14
  retrieving revision 1.112.2.15
  diff -u -r1.112.2.14 -r1.112.2.15
  --- repository_junit.xml	7 May 2005 16:02:57 -0000	1.112.2.14
  +++ repository_junit.xml	21 Jun 2005 10:53:45 -0000	1.112.2.15
  @@ -2673,11 +2673,13 @@
   	<class-descriptor class="org.apache.ojb.broker.Topic" table="TOPIC">
   	   <field-descriptor name="id" column="ID" jdbc-type="INTEGER" primarykey="true" autoincrement="true"/>
   	   <field-descriptor name="name" column="NAME" jdbc-type="VARCHAR"/>
  +	   <field-descriptor name="importance" column="IMPORTANCE" jdbc-type="VARCHAR"/>
   	</class-descriptor>
   
   	<class-descriptor class="org.apache.ojb.broker.Category" table="CATEGORY">
   	   <field-descriptor name="id" column="ID" jdbc-type="INTEGER" primarykey="true"/>
   	   <field-descriptor name="name" column="NAME" jdbc-type="VARCHAR"/>
  +	   <field-descriptor name="description" column="DESCRIPTION" jdbc-type="VARCHAR"/>
   	</class-descriptor>
   
   	<class-descriptor class="org.apache.ojb.broker.Area" table="AREA">
  
  
  

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