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/schema ojbtest-schema.xml
Date Fri, 13 Jun 2003 16:59:14 GMT
arminw      2003/06/13 09:59:14

  Modified:    src/test/org/apache/ojb repository_junit.xml
               src/test/org/apache/ojb/broker AbstractExtentClassTest.java
               src/schema ojbtest-schema.xml
  Log:
  add more tests
  
  Revision  Changes    Path
  1.72      +62 -6     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.71
  retrieving revision 1.72
  diff -u -r1.71 -r1.72
  --- repository_junit.xml	13 Jun 2003 10:11:53 -0000	1.71
  +++ repository_junit.xml	13 Jun 2003 16:59:13 -0000	1.72
  @@ -4190,9 +4190,36 @@
       <!--      abstract collections test                    -->
       <!-- ************************************************* -->
       <class-descriptor
  -    class="org.apache.ojb.broker.AbstractExtentClassTest$AbstractX">
  +    class="org.apache.ojb.broker.AbstractExtentClassTest$AbstractIF_X">
  +        <extent-class class-ref="org.apache.ojb.broker.AbstractExtentClassTest$AbstractIF_Y"
/>
  +    </class-descriptor>
  +
  +    <class-descriptor
  +    class="org.apache.ojb.broker.AbstractExtentClassTest$AbstractIF_Y">
  +        <extent-class class-ref="org.apache.ojb.broker.AbstractExtentClassTest$ConcreteZ"
/>
  +    </class-descriptor>
  +
  +    <class-descriptor
  +    class="org.apache.ojb.broker.AbstractExtentClassTest$ConcreteZ"
  +    table="ABSTRACT_COLLECTION_Z">
  +
  +        <field-descriptor
  +        name="id"
  +        column="OBJ_ID"
  +        jdbc-type="INTEGER"
  +        primarykey="true"
  +        autoincrement="true"/>
   
  -        <extent-class class-ref="org.apache.ojb.broker.AbstractExtentClassTest$AbstractY"
/>
  +        <field-descriptor
  +            name="name"
  +            column="NAME"
  +            jdbc-type="VARCHAR"
  +        />
  +
  +        <field-descriptor
  +        name="someValue"
  +        column="SOMEVALUE"
  +        jdbc-type="INTEGER"/>
   
           <field-descriptor
           name="containerId"
  @@ -4201,18 +4228,41 @@
       </class-descriptor>
   
       <class-descriptor
  -    class="org.apache.ojb.broker.AbstractExtentClassTest$AbstractY">
  +    class="org.apache.ojb.broker.AbstractExtentClassTest$AbstractClassX">
   
  -        <extent-class class-ref="org.apache.ojb.broker.AbstractExtentClassTest$ConcreteZ"
/>
  +        <extent-class class-ref="org.apache.ojb.broker.AbstractExtentClassTest$AbstractClassY"
/>
   
           <field-descriptor
           name="containerId"
           column="CONTAINER_ID"
           jdbc-type="INTEGER"/>
  +
  +        <field-descriptor
  +            name="name"
  +            column="NAME"
  +            jdbc-type="VARCHAR"
  +        />
       </class-descriptor>
   
       <class-descriptor
  -    class="org.apache.ojb.broker.AbstractExtentClassTest$ConcreteZ"
  +    class="org.apache.ojb.broker.AbstractExtentClassTest$AbstractClassY">
  +
  +        <extent-class class-ref="org.apache.ojb.broker.AbstractExtentClassTest$ConcreteZZ"
/>
  +
  +        <field-descriptor
  +        name="containerId"
  +        column="CONTAINER_ID"
  +        jdbc-type="INTEGER"/>
  +
  +        <field-descriptor
  +            name="name"
  +            column="NAME"
  +            jdbc-type="VARCHAR"
  +        />
  +    </class-descriptor>
  +
  +    <class-descriptor
  +    class="org.apache.ojb.broker.AbstractExtentClassTest$ConcreteZZ"
       table="ABSTRACT_COLLECTION_Z">
   
           <field-descriptor
  @@ -4231,6 +4281,12 @@
           name="containerId"
           column="CONTAINER_ID"
           jdbc-type="INTEGER"/>
  +
  +        <field-descriptor
  +            name="name"
  +            column="NAME"
  +            jdbc-type="VARCHAR"
  +        />
       </class-descriptor>
   
       <class-descriptor
  @@ -4245,7 +4301,7 @@
   
           <collection-descriptor
           name="myXReferences"
  -        element-class-ref="org.apache.ojb.broker.AbstractExtentClassTest$AbstractX"
  +        element-class-ref="org.apache.ojb.broker.AbstractExtentClassTest$AbstractIF_X"
           auto-retrieve="true"
           auto-update="true"
           auto-delete="false">
  
  
  
  1.3       +165 -21   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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractExtentClassTest.java	13 Jun 2003 10:58:04 -0000	1.2
  +++ AbstractExtentClassTest.java	13 Jun 2003 16:59:13 -0000	1.3
  @@ -48,15 +48,16 @@
           }
       }
   
  -    public void testStoreRetrieveQuery() throws Exception
  +    public void testStoreRetrieveQueryUsingInterface() throws Exception
       {
  +        String name = "interface_test";
           broker.clearCache();
           broker.beginTransaction();
           // create new XContainer with ConcreteZ reference
           XContainer container = new XContainer();
  -        container.addX(new ConcreteZ());
  -        container.addX(new ConcreteZ());
  -        container.addX(new ConcreteZ());
  +        container.addX(new ConcreteZ(name));
  +        container.addX(new ConcreteZ(name));
  +        container.addX(new ConcreteZ(name));
   
           broker.store(container);
           broker.commitTransaction();
  @@ -70,7 +71,40 @@
   
           broker.clearCache();
           // now test query
  -		Query q = QueryFactory.newQuery(AbstractX.class, (Criteria) null);
  +        Criteria crit = new Criteria();
  +        crit.addLike("name", name);
  +		Query q = QueryFactory.newQuery(AbstractIF_X.class, crit);
  +		Collection results = broker.getCollectionByQuery(q);
  +        assertNotNull(results);
  +        assertTrue(results.size() > 2);
  +    }
  +
  +    public void testStoreRetrieveQueryUsingAbstract() throws Exception
  +    {
  +        String name = "abstract_class_test";
  +        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));
  +
  +        broker.store(container);
  +        broker.commitTransaction();
  +        broker.clearCache();
  +
  +        Identity cont = new Identity(container, broker);
  +        broker.beginTransaction();
  +        Object retContainer = broker.getObjectByIdentity(cont);
  +        // System.out.println("retrieved: " + retContainer);
  +        broker.commitTransaction();
  +
  +        broker.clearCache();
  +        // now test query
  +		Criteria crit = new Criteria();
  +        crit.addLike("name", name);
  +		Query q = QueryFactory.newQuery(AbstractIF_X.class, crit);
   		Collection results = broker.getCollectionByQuery(q);
           assertNotNull(results);
           assertTrue(results.size() > 2);
  @@ -81,39 +115,49 @@
       // inner classes / persistent objects
       //******************************************************************
   
  -    public static abstract class AbstractX
  +    public static abstract interface AbstractIF_X
       {
  -        private int containerId;
  -
  -        public int getContainerId()
  -        {
  -            return containerId;
  -        }
  -
  -        public void setContainerId(int containerId)
  -        {
  -            this.containerId = containerId;
  -        }
  +        public int getContainerId();
  +        public void setContainerId(int containerId);
  +        public void setName(String name);
  +        public String getName();
       }
   
  -    public static abstract class AbstractY extends AbstractX
  +    public static abstract interface AbstractIF_Y extends AbstractIF_X
       {
       }
   
  -    public static class ConcreteZ extends AbstractY
  +    public static class ConcreteZ implements AbstractIF_Y
       {
  +        private int containerId;
           private int someValue;
           private int id;
  +        private String name;
   
           public ConcreteZ()
           {
           }
   
  +        public ConcreteZ(String name)
  +        {
  +            this.name = name;
  +        }
  +
           ConcreteZ(int no)
           {
               someValue = no;
           }
   
  +        public int getContainerId()
  +        {
  +            return containerId;
  +        }
  +
  +        public void setContainerId(int containerId)
  +        {
  +            this.containerId = containerId;
  +        }
  +
           public int getId()
           {
               return id;
  @@ -124,6 +168,16 @@
               this.id = id;
           }
   
  +        public String getName()
  +        {
  +            return name;
  +        }
  +
  +        public void setName(String name)
  +        {
  +            this.name = name;
  +        }
  +
           public int getSomeValue()
           {
               return someValue;
  @@ -156,7 +210,7 @@
               this.id = id;
           }
   
  -        private void addX(AbstractX someX)
  +        private void addX(AbstractIF_X someX)
           {
               if(myXReferences == null) myXReferences = new ArrayList();
               myXReferences.add(someX);
  @@ -177,6 +231,96 @@
               return (new ToStringBuilder(this)).
                       append("id", id).
                       append("myXReferences", myXReferences).toString();
  +        }
  +    }
  +
  +    public static abstract class AbstractClassX implements AbstractIF_X
  +    {
  +        private int containerId;
  +        private String name;
  +
  +        public AbstractClassX()
  +        {
  +        }
  +
  +        public AbstractClassX(String name)
  +        {
  +            this.name = name;
  +        }
  +
  +        public int getContainerId()
  +        {
  +            return containerId;
  +        }
  +
  +        public void setContainerId(int containerId)
  +        {
  +            this.containerId = containerId;
  +        }
  +
  +        public String getName()
  +        {
  +            return name;
  +        }
  +
  +        public void setName(String name)
  +        {
  +            this.name = name;
  +        }
  +    }
  +
  +    public static abstract class AbstractClassY extends AbstractClassX
  +    {
  +        public AbstractClassY()
  +        {
  +        }
  +
  +        public AbstractClassY(String name)
  +        {
  +            super(name);
  +        }
  +    }
  +
  +    public static class ConcreteZZ extends AbstractClassY
  +    {
  +
  +        private int someValue;
  +        private int id;
  +
  +        public ConcreteZZ()
  +        {
  +        }
  +
  +        public ConcreteZZ(String name)
  +        {
  +            super(name);
  +        }
  +
  +        public int getId()
  +        {
  +            return id;
  +        }
  +
  +        public void setId(int id)
  +        {
  +            this.id = id;
  +        }
  +
  +        public int getSomeValue()
  +        {
  +            return someValue;
  +        }
  +
  +        public void setSomeValue(int someValue)
  +        {
  +            this.someValue = someValue;
  +        }
  +
  +        public String toString()
  +        {
  +            return (new ToStringBuilder(this)).
  +                    append("id", id).
  +                    append("someValue", someValue).toString();
           }
       }
   }
  
  
  
  1.38      +1 -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.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- ojbtest-schema.xml	13 Jun 2003 10:11:54 -0000	1.37
  +++ ojbtest-schema.xml	13 Jun 2003 16:59:14 -0000	1.38
  @@ -716,6 +716,7 @@
      <table name="ABSTRACT_COLLECTION_Z">
        <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="SOMEVALUE" type="INTEGER" />
      </table>
      <!-- Used in tests AbstractExtentClassTest -->
  
  
  

Mime
View raw message