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 repository_junit.xml
Date Sun, 22 Jun 2003 22:03:26 GMT
arminw      2003/06/22 15:03:26

  Modified:    src/schema ojbtest-schema.xml
               src/test/org/apache/ojb/broker AbstractExtentClassTest.java
               src/test/org/apache/ojb repository_junit.xml
  Log:
  update test case
  
  Revision  Changes    Path
  1.39      +8 -0      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.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- ojbtest-schema.xml	13 Jun 2003 16:59:14 -0000	1.38
  +++ ojbtest-schema.xml	22 Jun 2003 22:03:26 -0000	1.39
  @@ -720,6 +720,14 @@
        <column name="SOMEVALUE" type="INTEGER" />
      </table>
      <!-- Used in tests AbstractExtentClassTest -->
  +   <table name="ABSTRACT_COLLECTION_ZZ">
  +     <column name="OBJ_ID" required="true" primaryKey="true" type="INTEGER"/>
  +     <column name="CONTAINER_ID" required="true" type="INTEGER"/>
  +     <column name="NAME" type="VARCHAR" size="150"/>
  +     <column name="ZZ_NAME" type="VARCHAR" size="150"/>
  +     <column name="SOMEVALUE" type="INTEGER" />
  +   </table>
  +   <!-- Used in tests AbstractExtentClassTest -->
      <table name="ABSTRACT_COLLECTION_CONTAINER">
        <column name="OBJ_ID" required="true" primaryKey="true" type="INTEGER"/>
      </table>
  
  
  
  1.6       +109 -36   db-ojb/src/test/org/apache/ojb/broker/AbstractExtentClassTest.java
  
  Index: AbstractExtentClassTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/AbstractExtentClassTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AbstractExtentClassTest.java	16 Jun 2003 07:52:54 -0000	1.5
  +++ AbstractExtentClassTest.java	22 Jun 2003 22:03:26 -0000	1.6
  @@ -8,6 +8,7 @@
   
   import java.util.ArrayList;
   import java.util.Collection;
  +import java.util.Iterator;
   
   /**
    *
  @@ -48,19 +49,23 @@
       }
   
       /**
  -     * Using data model:
  +     * Used data model:
        * AbstractIF_X <-- AbstractIF_Y <-- ConcreteZ
  +     * AbstractIF_X <-- AbstractClassX <-- AbstractClassY <-- ConcreteZZ
        */
       public void testStoreRetrieveQueryUsingInterface() throws Exception
       {
           String name = "interface_test_"+System.currentTimeMillis();
           broker.clearCache();
           broker.beginTransaction();
  -        // create new XContainer with ConcreteZ reference
  +        // create new XContainer with ConcreteZ and ConreteZZ references
           XContainer container = new XContainer();
           container.addX(new ConcreteZ(name));
           container.addX(new ConcreteZ(name));
  -        container.addX(new ConcreteZ(name));
  +        // we a set additional field 'zzName' in ConcreteZZ
  +        container.addX(new ConcreteZZ(name, "ZZ"));
  +        container.addX(new ConcreteZZ(name, "ZZ"));
  +        container.addX(new ConcreteZZ(name, "ZZ"));
   
           broker.store(container);
           broker.commitTransaction();
  @@ -72,57 +77,113 @@
           broker.commitTransaction();
           Collection res = retContainer.getXReferences();
           assertNotNull(res);
  -        assertEquals(3, res.size());
  +        assertEquals(5, res.size());
  +        boolean found = false;
  +        for (Iterator iterator = res.iterator(); iterator.hasNext();)
  +        {
  +            Object o = (Object) iterator.next();
  +            if(o instanceof ConcreteZZ)
  +            {
  +                ConcreteZZ zz = (ConcreteZZ) o;
  +                assertNotNull(zz.getConcreteZZName());
  +                assertEquals("ZZ", zz.getConcreteZZName());
  +                found = true;
  +            }
  +        }
  +        assertTrue("No ConcreteZZ instances be returned",found);
   
           broker.clearCache();
  -        // now test query
  +
  +        // test query base interface
           Criteria crit = new Criteria();
           crit.addLike("name", name);
           Query q = QueryFactory.newQuery(AbstractIF_X.class, crit);
           Collection results = broker.getCollectionByQuery(q);
           assertNotNull(results);
  +        assertEquals(5, results.size());
  +        found = false;
  +        for (Iterator iterator = results.iterator(); iterator.hasNext();)
  +        {
  +            Object o = (Object) iterator.next();
  +            if(o instanceof ConcreteZZ)
  +            {
  +                ConcreteZZ zz = (ConcreteZZ) o;
  +                assertNotNull(zz.getConcreteZZName());
  +                assertEquals("ZZ", zz.getConcreteZZName());
  +                found = true;
  +            }
  +        }
  +        assertTrue("No ConcreteZZ instances be returned",found);
  +
  +        // test query abstract class
  +        broker.clearCache();
  +        crit = new Criteria();
  +        crit.addLike("name", name);
  +        q = QueryFactory.newQuery(AbstractClassX.class, crit);
  +        results = broker.getCollectionByQuery(q);
  +        assertNotNull(results);
           assertEquals(3, results.size());
  -    }
  +        for (Iterator iterator = results.iterator(); iterator.hasNext();)
  +        {
  +            Object o = (Object) iterator.next();
  +            ConcreteZZ zz = (ConcreteZZ) o;
  +            assertNotNull(zz.getConcreteZZName());
  +            assertEquals("ZZ", zz.getConcreteZZName());
  +        }
   
  -    /**
  -     * Using data model:
  -     * AbstractIF_X <-- AbstractClassX <-- AbstractClassY <-- ConcreteZZ
  -     */
  -    public void testStoreRetrieveQueryUsingAbstract() throws Exception
  -    {
  -        String name = "abstract_class_test_"+System.currentTimeMillis();
  +        // test query abstract class
           broker.clearCache();
  -        broker.beginTransaction();
  -        // create new XContainer with ConcreteZ reference
  -        XContainer container = new XContainer();
  -        container.addX(new ConcreteZZ(name));
  -        container.addX(new ConcreteZZ(name));
  -        container.addX(new ConcreteZZ(name));
  -        container.addX(new ConcreteZZ(name));
  +        crit = new Criteria();
  +        crit.addLike("name", name);
  +        q = QueryFactory.newQuery(AbstractClassY.class, crit);
  +        results = broker.getCollectionByQuery(q);
  +        assertNotNull(results);
  +        assertEquals(3, results.size());
  +        for (Iterator iterator = results.iterator(); iterator.hasNext();)
  +        {
  +            Object o = (Object) iterator.next();
  +            ConcreteZZ zz = (ConcreteZZ) o;
  +            assertNotNull(zz.getConcreteZZName());
  +            assertEquals("ZZ", zz.getConcreteZZName());
  +        }
   
  -        broker.store(container);
  -        broker.commitTransaction();
  +        // test query extended interface
           broker.clearCache();
  +        crit = new Criteria();
  +        crit.addLike("name", name);
  +        q = QueryFactory.newQuery(AbstractIF_Y.class, crit);
  +        results = broker.getCollectionByQuery(q);
  +        assertNotNull(results);
  +        assertEquals(2, results.size());
   
  -        Identity cont = new Identity(container, broker);
  -        broker.beginTransaction();
  -        XContainer retContainer = (XContainer) broker.getObjectByIdentity(cont);
  -        broker.commitTransaction();
  -        Collection res = retContainer.getXReferences();
  -        assertNotNull(res);
  -        assertEquals(4, res.size());
  +        // test query concrete class
  +        broker.clearCache();
  +        crit = new Criteria();
  +        crit.addLike("name", name);
  +        q = QueryFactory.newQuery(ConcreteZ.class, crit);
  +        results = broker.getCollectionByQuery(q);
  +        assertNotNull(results);
  +        assertEquals(2, results.size());
   
  +        // test query concrete class
           broker.clearCache();
  -        // now test query
  -        Criteria crit = new Criteria();
  +        crit = new Criteria();
           crit.addLike("name", name);
  -        Query q = QueryFactory.newQuery(AbstractIF_X.class, crit);
  -        Collection results = broker.getCollectionByQuery(q);
  +        q = QueryFactory.newQuery(ConcreteZZ.class, crit);
  +        results = broker.getCollectionByQuery(q);
           assertNotNull(results);
  -        assertEquals(4,results.size());
  +        assertEquals(3, results.size());
  +        for (Iterator iterator = results.iterator(); iterator.hasNext();)
  +        {
  +            Object o = (Object) iterator.next();
  +            ConcreteZZ zz = (ConcreteZZ) o;
  +            assertNotNull(zz.getConcreteZZName());
  +            assertEquals("ZZ", zz.getConcreteZZName());
  +        }
       }
   
   
  +
       //******************************************************************
       // inner classes / persistent objects
       //******************************************************************
  @@ -308,14 +369,16 @@
   
           private int someValue;
           private int id;
  +        private String concreteZZName;
   
           public ConcreteZZ()
           {
           }
   
  -        public ConcreteZZ(String name)
  +        public ConcreteZZ(String name, String zzName)
           {
               super(name);
  +            this.concreteZZName = zzName;
           }
   
           public int getId()
  @@ -326,6 +389,16 @@
           public void setId(int id)
           {
               this.id = id;
  +        }
  +
  +        public String getConcreteZZName()
  +        {
  +            return concreteZZName;
  +        }
  +
  +        public void setConcreteZZName(String concreteZZName)
  +        {
  +            this.concreteZZName = concreteZZName;
           }
   
           public int getSomeValue()
  
  
  
  1.76      +10 -5     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.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- repository_junit.xml	20 Jun 2003 13:34:57 -0000	1.75
  +++ repository_junit.xml	22 Jun 2003 22:03:26 -0000	1.76
  @@ -4195,12 +4195,11 @@
           <extent-class class-ref="org.apache.ojb.broker.AbstractExtentClassTest$AbstractIF_Y"
/>
           <extent-class class-ref="org.apache.ojb.broker.AbstractExtentClassTest$AbstractClassX"
/>
           -->
  -        
  -		<!-- Using concrete classes in extent definition only works fine:-->  
  +
  +		<!-- Using concrete classes in extent definition only works fine:-->
           <extent-class class-ref="org.apache.ojb.broker.AbstractExtentClassTest$ConcreteZ"
/>
           <extent-class class-ref="org.apache.ojb.broker.AbstractExtentClassTest$ConcreteZZ"
/>
  -        <!-- -->        
  -        
  +
       </class-descriptor>
   
       <class-descriptor
  @@ -4272,7 +4271,7 @@
   
       <class-descriptor
       class="org.apache.ojb.broker.AbstractExtentClassTest$ConcreteZZ"
  -    table="ABSTRACT_COLLECTION_Z">
  +    table="ABSTRACT_COLLECTION_ZZ">
   
           <field-descriptor
           name="id"
  @@ -4294,6 +4293,12 @@
           <field-descriptor
               name="name"
               column="NAME"
  +            jdbc-type="VARCHAR"
  +        />
  +
  +        <field-descriptor
  +            name="concreteZZName"
  +            column="ZZ_NAME"
               jdbc-type="VARCHAR"
           />
       </class-descriptor>
  
  
  

Mime
View raw message