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 InheritanceMultipleTableTest.java
Date Thu, 08 Sep 2005 16:31:10 GMT
arminw      2005/09/08 09:31:10

  Modified:    src/java/org/apache/ojb/broker/metadata
                        SuperReferenceDescriptor.java
               src/test/org/apache/ojb/broker
                        InheritanceMultipleTableTest.java
  Log:
  comment out tests for "declarative inheritance", throw exception in SuperReferenceDescriptor
when this kind of inheritance is used.
  
  Revision  Changes    Path
  1.4       +4 -4      db-ojb/src/java/org/apache/ojb/broker/metadata/SuperReferenceDescriptor.java
  
  Index: SuperReferenceDescriptor.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/SuperReferenceDescriptor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SuperReferenceDescriptor.java	3 Sep 2005 15:28:14 -0000	1.3
  +++ SuperReferenceDescriptor.java	8 Sep 2005 16:31:10 -0000	1.4
  @@ -218,9 +218,9 @@
               }
               else
               {
  -                //throw new MetadataException("Declared super class '" + superRef.getClassDescriptor()
  -                //        + "'is not assignable from " + target.getClass());
  -                copyFields(superRef.getClassDescriptor(), target, superCld, value, false,
false);
  +                throw new MetadataException("Declared super class '" + superRef.getClassDescriptor()
  +                        + "'is not assignable from " + target.getClass());
  +                // copyFields(superRef.getClassDescriptor(), target, superCld, value, false,
false);
               }
           }
   
  
  
  
  1.17      +96 -81    db-ojb/src/test/org/apache/ojb/broker/InheritanceMultipleTableTest.java
  
  Index: InheritanceMultipleTableTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/InheritanceMultipleTableTest.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- InheritanceMultipleTableTest.java	27 Aug 2005 12:41:20 -0000	1.16
  +++ InheritanceMultipleTableTest.java	8 Sep 2005 16:31:10 -0000	1.17
  @@ -141,42 +141,6 @@
           assertEquals(1, shareholderCount);
       }
   
  -    public void testWithoutJavaInheritance_1()
  -    {
  -        String name = "testWithoutJavaInheritance_1" + System.currentTimeMillis();
  -        Dog dog = new Dog(name, 35, 4);
  -        broker.beginTransaction();
  -        broker.store(dog);
  -        broker.commitTransaction();
  -
  -        broker.clearCache();
  -        Criteria crit = new Criteria();
  -        crit.addEqualTo("name", name);
  -        Query q = QueryFactory.newQuery(Dog.class, crit);
  -        Collection result = broker.getCollectionByQuery(q);
  -        assertNotNull(result);
  -        assertEquals(1, result.size());
  -        Dog newDog = (Dog) result.iterator().next();
  -        assertTrue(dog.equals(newDog));
  -
  -        broker.beginTransaction();
  -        newDog.setWeight(1000);
  -        newDog.setLegs(10);
  -        broker.store(newDog);
  -        broker.commitTransaction();
  -
  -        broker.clearCache();
  -        result = broker.getCollectionByQuery(q);
  -        assertNotNull(result);
  -        assertEquals(1, result.size());
  -        Dog newDog2 = (Dog) result.iterator().next();
  -        assertTrue(newDog.equals(newDog2));
  -
  -        broker.beginTransaction();
  -        broker.delete(dog);
  -        broker.commitTransaction();
  -    }
  -
       public void testJavaInheritance()
       {
           ojbSkipKnownIssueProblem("Declared inheritance (without java inheritance)" +
  @@ -209,50 +173,6 @@
           assertTrue(animal.equals(newAnimal));
       }
   
  -    public void testWithoutJavaInheritance_2()
  -    {
  -        String name = "testWithoutJavaInheritance_2" + System.currentTimeMillis();
  -        Dog dog = new Dog(name, 35, 4);
  -        Animal parent = new Animal(name + "_parent", 55);
  -        Food f1 = new Food(name + "fruit1");
  -        Food f2 = new Food(name + "fruit2");
  -        dog.addFood(f1);
  -        dog.addFood(f2);
  -        dog.setParent(parent);
  -
  -        broker.beginTransaction();
  -        broker.store(dog);
  -        broker.commitTransaction();
  -
  -        broker.clearCache();
  -        Criteria crit = new Criteria();
  -        crit.addEqualTo("name", name);
  -        Query q = QueryFactory.newQuery(Dog.class, crit);
  -        Collection result = broker.getCollectionByQuery(q);
  -        assertNotNull(result);
  -        assertEquals(1, result.size());
  -        Dog newDog = (Dog) result.iterator().next();
  -        assertEquals(dog, newDog);
  -
  -        broker.beginTransaction();
  -        newDog.setWeight(1000);
  -        newDog.setLegs(10);
  -        newDog.addFood(new Food(name + "_new"));
  -        broker.store(newDog);
  -        broker.commitTransaction();
  -
  -        broker.clearCache();
  -        result = broker.getCollectionByQuery(q);
  -        assertNotNull(result);
  -        assertEquals(1, result.size());
  -        Dog newDog2 = (Dog) result.iterator().next();
  -        assertTrue(newDog.equals(newDog2));
  -
  -        broker.beginTransaction();
  -        broker.delete(dog);
  -        broker.commitTransaction();
  -    }
  -
       public void testInheritancedObjectsInCollectionReferences()
       {
           if(ojbSkipKnownIssueProblem("References of classes (1:1, 1:n) mapped to multiple
joined tables only" +
  @@ -1184,6 +1104,101 @@
           assertFalse(obj_2.getSomeValue() == obj_3.getSomeValue());
       }
   
  +    /**
  +     * TODO: Should we support some kind of "declarative inheritance"? This test
  +     * try to use this kind of inheritance as class Dog expects some fields from a
  +     * "declarated super class" (no java inheritance, only declared in metadata).
  +     * In class {@link org.apache.ojb.broker.metadata.SuperReferenceDescriptor} the
  +     * support is comment out (but only works for simple objects without references).
  +     */
  +    public void YYYtestWithoutJavaInheritance_1()
  +    {
  +        String name = "testWithoutJavaInheritance_1" + System.currentTimeMillis();
  +        Dog dog = new Dog(name, 35, 4);
  +        broker.beginTransaction();
  +        broker.store(dog);
  +        broker.commitTransaction();
  +
  +        broker.clearCache();
  +        Criteria crit = new Criteria();
  +        crit.addEqualTo("name", name);
  +        Query q = QueryFactory.newQuery(Dog.class, crit);
  +        Collection result = broker.getCollectionByQuery(q);
  +        assertNotNull(result);
  +        assertEquals(1, result.size());
  +        Dog newDog = (Dog) result.iterator().next();
  +        assertTrue(dog.equals(newDog));
  +
  +        broker.beginTransaction();
  +        newDog.setWeight(1000);
  +        newDog.setLegs(10);
  +        broker.store(newDog);
  +        broker.commitTransaction();
  +
  +        broker.clearCache();
  +        result = broker.getCollectionByQuery(q);
  +        assertNotNull(result);
  +        assertEquals(1, result.size());
  +        Dog newDog2 = (Dog) result.iterator().next();
  +        assertTrue(newDog.equals(newDog2));
  +
  +        broker.beginTransaction();
  +        broker.delete(dog);
  +        broker.commitTransaction();
  +    }
  +
  +    /**
  +     * TODO: Should we support some kind of "declarative inheritance"? This test
  +     * try to use this kind of inheritance as class Dog expects some fields from a
  +     * "declarated super class" (no java inheritance, only declared in metadata).
  +     * In class {@link org.apache.ojb.broker.metadata.SuperReferenceDescriptor} the
  +     * support is comment out (but only works for simple objects without references).
  +     */
  +    public void YYYtestWithoutJavaInheritance_2()
  +    {
  +        String name = "testWithoutJavaInheritance_2" + System.currentTimeMillis();
  +        Dog dog = new Dog(name, 35, 4);
  +        Animal parent = new Animal(name + "_parent", 55);
  +        Food f1 = new Food(name + "fruit1");
  +        Food f2 = new Food(name + "fruit2");
  +        dog.addFood(f1);
  +        dog.addFood(f2);
  +        dog.setParent(parent);
  +
  +        broker.beginTransaction();
  +        broker.store(dog);
  +        broker.commitTransaction();
  +
  +        broker.clearCache();
  +        Criteria crit = new Criteria();
  +        crit.addEqualTo("name", name);
  +        Query q = QueryFactory.newQuery(Dog.class, crit);
  +        Collection result = broker.getCollectionByQuery(q);
  +        assertNotNull(result);
  +        assertEquals(1, result.size());
  +        Dog newDog = (Dog) result.iterator().next();
  +        assertEquals(dog, newDog);
  +
  +        broker.beginTransaction();
  +        newDog.setWeight(1000);
  +        newDog.setLegs(10);
  +        newDog.addFood(new Food(name + "_new"));
  +        broker.store(newDog);
  +        broker.commitTransaction();
  +
  +        broker.clearCache();
  +        result = broker.getCollectionByQuery(q);
  +        assertNotNull(result);
  +        assertEquals(1, result.size());
  +        Dog newDog2 = (Dog) result.iterator().next();
  +        assertTrue(newDog.equals(newDog2));
  +
  +        broker.beginTransaction();
  +        broker.delete(dog);
  +        broker.commitTransaction();
  +    }
  +
  +
   
       //************************************************************
       // inner classes used for test
  
  
  

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