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 ObjectRepository.java AnonymousFieldsTest.java
Date Wed, 17 Sep 2003 19:02:33 GMT
brj         2003/09/17 12:02:33

  Modified:    src/test/org/apache/ojb/broker ObjectRepository.java
                        AnonymousFieldsTest.java
  Log:
  multilevel vertical inheritance
  
  Revision  Changes    Path
  1.2       +27 -1     db-ojb/src/test/org/apache/ojb/broker/ObjectRepository.java
  
  Index: ObjectRepository.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/ObjectRepository.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ObjectRepository.java	14 Aug 2003 18:42:40 -0000	1.1
  +++ ObjectRepository.java	17 Sep 2003 19:02:33 -0000	1.2
  @@ -295,5 +295,31 @@
           }
       }
   
  +
  +    public static class G extends F implements Serializable
  +    {
  +        int id;
  +        int someSubValue;
  +
  +        public int getId()
  +        {
  +            return id;
  +        }
  +
  +        public void setId(int id)
  +        {
  +            this.id = id;
  +        }
  +
  +        public int getSomeSubValue()
  +        {
  +            return someSubValue;
  +        }
  +
  +        public void setSomeSubValue(int someSubValue)
  +        {
  +            this.someSubValue = someSubValue;
  +        }
  +    }
   }
   
  
  
  
  1.6       +105 -12   db-ojb/src/test/org/apache/ojb/broker/AnonymousFieldsTest.java
  
  Index: AnonymousFieldsTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/AnonymousFieldsTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AnonymousFieldsTest.java	29 Aug 2003 20:52:35 -0000	1.5
  +++ AnonymousFieldsTest.java	17 Sep 2003 19:02:33 -0000	1.6
  @@ -57,6 +57,7 @@
   
       /**
        * write an entry using vertical inheritance and try to read it again.
  +     * E-F
        */
       public void testVerticalInheritanceStoreAndLoad() throws Exception
       {
  @@ -78,6 +79,31 @@
   
       /**
        * write an entry using vertical inheritance and try to read it again.
  +     * E-F-G
  +     */
  +    public void testVerticalInheritanceStoreAndLoad2() throws Exception
  +    {
  +        // produce some test data G
  +        ObjectRepository.G entry = new ObjectRepository.G();
  +        entry.setSomeSuperValue(31415926);
  +        entry.setSomeValue(123456);
  +        entry.setSomeSubValue(4242);
  +        Identity oid = new Identity(entry, broker);
  +        broker.store(entry);
  +
  +        // clear cache and retrieve a copy from the DB
  +        broker.clearCache();
  +        ObjectRepository.G copy = (ObjectRepository.G) broker.getObjectByIdentity(oid);
  +
  +        // check equality
  +        assertEquals(entry.getSomeValue(), copy.getSomeValue());
  +        assertEquals(entry.getSomeSuperValue(), copy.getSomeSuperValue());
  +        assertEquals(entry.getSomeSubValue(), copy.getSomeSubValue());
  +    }
  +
  +    /**
  +     * write an entry using vertical inheritance and try to read it again.
  +     * E-F
        */
       public void testVerticalInheritanceUpdate() throws Exception
       {
  @@ -102,35 +128,102 @@
       }
   
       /**
  -     *
  +     * write an entry using vertical inheritance and try to read it again.
  +     * E-F-G
  +     */
  +    public void testVerticalInheritanceUpdate2() throws Exception
  +    {
  +        // produce some test data
  +        ObjectRepository.G entry = new ObjectRepository.G();
  +        entry.setSomeSuperValue(2718281);
  +        entry.setSomeValue(9999);
  +        entry.setSomeSubValue(8888);
  +        Identity oid = new Identity(entry, broker);
  +        broker.store(entry);
  +
  +        entry.setSomeSuperValue(2718282);
  +        entry.setSomeValue(10000);
  +        entry.setSomeSubValue(7777);
  +        broker.store(entry);
  +
  +        // clear cache and retrieve a copy from the DB
  +        broker.clearCache();
  +        ObjectRepository.G copy = (ObjectRepository.G) broker.getObjectByIdentity(oid);
  +
  +        // check equality
  +        assertEquals(entry.getSomeValue(), copy.getSomeValue());
  +        assertEquals(entry.getSomeSuperValue(), copy.getSomeSuperValue());
  +        assertEquals(entry.getSomeSubValue(), copy.getSomeSubValue());
  +    }
  +
  +    /**
  +     * Query Attribute of Super class
  +     * E-F
        */
       public void testQuerySuperField()
       {
  -        int key1 = (int) (Math.random() * Integer.MAX_VALUE);
  -        int key2 = (int) (Math.random() * Integer.MAX_VALUE);
  +        int data1 = (int) (Math.random() * Integer.MAX_VALUE);
  +        int data2 = (int) (Math.random() * Integer.MAX_VALUE);
           ObjectRepository.F f1 = new ObjectRepository.F();
  -        f1.setSomeValue(key1);
  -        f1.setSomeSuperValue(key2);
  +        f1.setSomeValue(data1);
  +        f1.setSomeSuperValue(data2);
           broker.store(f1);
   
           ObjectRepository.F f2 = new ObjectRepository.F();
  -        f2.setSomeValue(key1);
  -        f2.setSomeSuperValue(key2);
  +        f2.setSomeValue(data1);
  +        f2.setSomeSuperValue(data2);
           broker.store(f2);
   
           ObjectRepository.F f3 = new ObjectRepository.F();
  -        f3.setSomeValue(key1);
  -        f3.setSomeSuperValue(key2);
  +        f3.setSomeValue(data1);
  +        f3.setSomeSuperValue(data2);
           broker.store(f3);
   
           Criteria c = new Criteria();
  -        c.addEqualTo("someSuperValue", new Integer(key2));
  +        c.addEqualTo("someSuperValue", new Integer(data2));
           Query q = QueryFactory.newQuery(ObjectRepository.F.class, c);
           Collection result = broker.getCollectionByQuery(q);
           assertEquals(3, result.size());
           ObjectRepository.F retF = (ObjectRepository.F) result.iterator().next();
  -        assertEquals(key1, retF.getSomeValue());
  -        assertEquals(key2, retF.getSomeSuperValue());
  +        assertEquals(data1, retF.getSomeValue());
  +        assertEquals(data2, retF.getSomeSuperValue());
       }
   
  +    /**
  +     * Query Attribute of Super class
  +     * E-F-G
  +     */
  +    public void testQuerySuperField2()
  +    {
  +        int data1 = (int) (Math.random() * Integer.MAX_VALUE);
  +        int data2 = (int) (Math.random() * Integer.MAX_VALUE);
  +        int data3 = (int) (Math.random() * Integer.MAX_VALUE);
  +        ObjectRepository.G g1 = new ObjectRepository.G();
  +        g1.setSomeValue(data1);
  +        g1.setSomeSuperValue(data2);
  +        g1.setSomeSubValue(data3);
  +        broker.store(g1);
  +
  +        ObjectRepository.G g2 = new ObjectRepository.G();
  +        g2.setSomeValue(data1);
  +        g2.setSomeSuperValue(data2);
  +        g2.setSomeSubValue(data3);
  +        broker.store(g2);
  +
  +        ObjectRepository.G g3 = new ObjectRepository.G();
  +        g3.setSomeValue(data1);
  +        g3.setSomeSuperValue(data2);
  +        g3.setSomeSubValue(data3);
  +        broker.store(g3);
  +
  +        Criteria c = new Criteria();
  +        c.addEqualTo("someSuperValue", new Integer(data2));
  +        Query q = QueryFactory.newQuery(ObjectRepository.G.class, c);
  +        Collection result = broker.getCollectionByQuery(q);
  +        assertEquals(3, result.size());
  +        ObjectRepository.G ret = (ObjectRepository.G) result.iterator().next();
  +        assertEquals(data1, ret.getSomeValue());
  +        assertEquals(data2, ret.getSomeSuperValue());
  +        assertEquals(data3, ret.getSomeSubValue());
  +    }
   }
  
  
  

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