Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 95704 invoked from network); 13 Oct 2004 16:48:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 13 Oct 2004 16:48:34 -0000 Received: (qmail 23341 invoked by uid 500); 13 Oct 2004 16:48:33 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 23264 invoked by uid 500); 13 Oct 2004 16:48:32 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 23250 invoked by uid 500); 13 Oct 2004 16:48:31 -0000 Received: (qmail 23246 invoked by uid 99); 13 Oct 2004 16:48:31 -0000 X-ASF-Spam-Status: No, hits=-10.0 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Wed, 13 Oct 2004 09:48:29 -0700 Received: (qmail 95642 invoked by uid 1510); 13 Oct 2004 16:48:28 -0000 Date: 13 Oct 2004 16:48:28 -0000 Message-ID: <20041013164828.95641.qmail@minotaur.apache.org> From: arminw@apache.org To: db-ojb-cvs@apache.org Subject: cvs commit: db-ojb/src/test/org/apache/ojb repository_junit_inheritance.xml repository.xml repository_junit.xml X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N arminw 2004/10/13 09:48:28 Modified: src/schema Tag: OJB_1_0_RELEASE ojbtest-schema.xml src/test/org/apache/ojb/broker Tag: OJB_1_0_RELEASE AllTests.java InheritanceMultipleTableTest.java src/test/org/apache/ojb Tag: OJB_1_0_RELEASE repository.xml repository_junit.xml Added: src/test/org/apache/ojb Tag: OJB_1_0_RELEASE repository_junit_inheritance.xml Log: add new test testing inheritance, multiple joined tables reorder tests add new sub-xml file Revision Changes Path No revision No revision 1.80.2.3 +6 -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.2 retrieving revision 1.80.2.3 diff -u -r1.80.2.2 -r1.80.2.3 --- ojbtest-schema.xml 28 Sep 2004 14:13:49 -0000 1.80.2.2 +++ ojbtest-schema.xml 13 Oct 2004 16:48:27 -0000 1.80.2.3 @@ -1176,6 +1176,11 @@ + + + +
+ No revision No revision 1.49.2.1 +5 -5 db-ojb/src/test/org/apache/ojb/broker/AllTests.java Index: AllTests.java =================================================================== RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/AllTests.java,v retrieving revision 1.49 retrieving revision 1.49.2.1 diff -u -r1.49 -r1.49.2.1 --- AllTests.java 26 Jun 2004 00:22:25 -0000 1.49 +++ AllTests.java 13 Oct 2004 16:48:27 -0000 1.49.2.1 @@ -44,7 +44,6 @@ suite.addTestSuite(PolymorphicExtents.class); suite.addTestSuite(TreeTest.class); suite.addTestSuite(TypedCollectionsTest.class); - suite.addTestSuite(MtoNMapping.class); suite.addTestSuite(AutomaticForeignKeys.class); suite.addTestSuite(OptimisticLockingTest.class); suite.addTestSuite(GraphTest.class); @@ -85,20 +84,21 @@ suite.addTestSuite(NativeIdentifierTest.class); suite.addTestSuite(AnonymousFieldsTest.class); suite.addTestSuite(AbstractExtentClassTest.class); - suite.addTestSuite(MtoNTest.class); suite.addTestSuite(NestedFieldsTest.class); suite.addTestSuite(ReadonlyTest.class); suite.addTestSuite(ReferenceMapTest.class); suite.addTestSuite(MultithreadedReadTest.class); - suite.addTestSuite(InheritanceMultipleTableTest.class); - suite.addTestSuite(M2NTest.class); suite.addTestSuite(CollectionTest2.class); suite.addTestSuite(NumberAccuracyTest.class); suite.addTestSuite(AutoIncrementTest.class); suite.addTestSuite(PathTest.class); suite.addTestSuite(PrimaryKeyForeignKeyTest.class); - suite.addTestSuite(M2NGraphTest.class); suite.addTestSuite(PersistentFieldTest.class); + suite.addTestSuite(InheritanceMultipleTableTest.class); + suite.addTestSuite(M2NGraphTest.class); + suite.addTestSuite(MtoNMapping.class); + suite.addTestSuite(MtoNTest.class); + suite.addTestSuite(M2NTest.class); return suite; } 1.7.2.2 +121 -7 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.7.2.1 retrieving revision 1.7.2.2 diff -u -r1.7.2.1 -r1.7.2.2 --- InheritanceMultipleTableTest.java 27 Jul 2004 00:31:50 -0000 1.7.2.1 +++ InheritanceMultipleTableTest.java 13 Oct 2004 16:48:27 -0000 1.7.2.2 @@ -17,9 +17,9 @@ import org.apache.ojb.junit.PBTestCase; /** - * This test check inheritance using multiple tables. The test objects use - * a composite PK. One autoincrement PK field - Integer. One non-autoincrement PK field - * with manually set PK- Long. + * These tests check inheritance using multiple tables via 1:1 reference and "super" keyword in + * reference descriptor. The test objects use a composite PK. + * One autoincrement PK field - Integer. One non-autoincrement PK field with manually set PK- Long. * * @author Armin Waibel * @version $Id$ @@ -31,13 +31,79 @@ junit.textui.TestRunner.main(new String[]{InheritanceMultipleTableTest.class.getName()}); } + public void testInheritancedObjectsInCollectionReferences() + { + long timestamp = System.currentTimeMillis(); + Long id_2 = new Long(timestamp); + String name = "testInheritancedObjectsInCollectionReferences_" + timestamp; + Manager m_1 = new Manager(id_2, name + "_manager_1"); + Manager m_2 = new Manager(id_2, name + "_manager_2"); + Manager m_3 = new Manager(id_2, name + "_manager_3"); + m_3.setDepartment("none"); + Executive ex_1 = new Executive(id_2, name + "_executive", "department_1", null); + Executive ex_2 = new Executive(id_2, name + "_executive", "department_1", null); + Employee em = new Employee(id_2, name + "_employee"); + + ArrayList employees = new ArrayList(); + employees.add(m_1); + employees.add(m_2); + employees.add(m_3); + employees.add(ex_1); + employees.add(ex_2); + employees.add(em); + + Company company = new Company(id_2, name, employees); + broker.beginTransaction(); + broker.store(company); + broker.commitTransaction(); + + broker.clearCache(); + Criteria crit = new Criteria(); + crit.addEqualTo("id", id_2); + Query query = QueryFactory.newQuery(Company.class, crit); + Collection result = broker.getCollectionByQuery(query); + assertEquals(1, result.size()); + Company newCompany = (Company) result.iterator().next(); + List newEmployees = newCompany.getEmployees(); + assertNotNull(newEmployees); + assertEquals(employees.size(), newEmployees.size()); + int countEmployee = 0; + int countExecutive = 0; + int countManager = 0; + for(int i = 0; i < newEmployees.size(); i++) + { + Object o = newEmployees.get(i); + if(o instanceof Employee) + { + ++countEmployee; + } + if(o instanceof Executive) + { + ++countExecutive; + } + if(o instanceof Manager) + { + ++countManager; + } + } + assertEquals(6, countEmployee); + /* + bug: + expect that the real classes will be populated + currently this does not happen, only objects of + type Employee will be returned. + */ + assertEquals(5, countExecutive); + assertEquals(3, countManager); + } + public void testObjectExistence() { Manager target_1 = new Manager(new Long(1), "testObjectExistence"); Manager target_2 = new Manager(new Long(System.currentTimeMillis()), "testObjectExistence"); - Identity oid_1 = new Identity(target_1, broker); - Identity oid_2 = new Identity(target_2, broker); + Identity oid_1 = broker.serviceIdentity().buildIdentity(target_1); + Identity oid_2 = broker.serviceIdentity().buildIdentity(target_2); ClassDescriptor cld = broker.getClassDescriptor(Manager.class); @@ -51,7 +117,7 @@ { long timestamp = System.currentTimeMillis(); Long id_2 = new Long(timestamp); - String name = "testInsert" + timestamp; + String name = "testStoreUpdateQuerySerialized_" + timestamp; Manager m_1 = new Manager(id_2, name + "_manager_1"); Manager m_2 = new Manager(id_2, name + "_manager_2"); Manager m_3 = new Manager(id_2, name + "_manager_3"); @@ -668,5 +734,53 @@ public String getStreet(); public void setStreet(String street); + } + + public static class Company + { + private Long id; + private String name; + private List employees; + + public Company() + { + } + + public Company(Long id, String name, List employees) + { + this.id = id; + this.name = name; + this.employees = employees; + } + + public Long getId() + { + return id; + } + + public void setId(Long id) + { + this.id = id; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public List getEmployees() + { + return employees; + } + + public void setEmployees(List employees) + { + this.employees = employees; + } } } No revision No revision 1.26.2.1 +2 -0 db-ojb/src/test/org/apache/ojb/repository.xml Index: repository.xml =================================================================== RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/repository.xml,v retrieving revision 1.26 retrieving revision 1.26.2.1 diff -u -r1.26 -r1.26.2.1 --- repository.xml 25 Jun 2004 14:49:40 -0000 1.26 +++ repository.xml 13 Oct 2004 16:48:27 -0000 1.26.2.1 @@ -48,6 +48,7 @@ + @@ -79,6 +80,7 @@ &junit_cache; &junit_model; &junit_cloneable; + &junit_inheritance; &junit_pathClass; 1.112.2.4 +1 -678 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.3 retrieving revision 1.112.2.4 diff -u -r1.112.2.3 -r1.112.2.4 --- repository_junit.xml 13 Aug 2004 14:23:54 -0000 1.112.2.3 +++ repository_junit.xml 13 Oct 2004 16:48:27 -0000 1.112.2.4 @@ -1876,547 +1876,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No revision Index: repository_junit.xml =================================================================== RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/repository_junit.xml,v retrieving revision 1.112.2.3 retrieving revision 1.112.2.4 diff -u -r1.112.2.3 -r1.112.2.4 --- repository_junit.xml 13 Aug 2004 14:23:54 -0000 1.112.2.3 +++ repository_junit.xml 13 Oct 2004 16:48:27 -0000 1.112.2.4 @@ -1876,547 +1876,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No revision Index: repository_junit.xml =================================================================== RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/repository_junit.xml,v retrieving revision 1.112.2.3 retrieving revision 1.112.2.4 diff -u -r1.112.2.3 -r1.112.2.4 --- repository_junit.xml 13 Aug 2004 14:23:54 -0000 1.112.2.3 +++ repository_junit.xml 13 Oct 2004 16:48:27 -0000 1.112.2.4 @@ -1876,547 +1876,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1.1.2.1 +728 -0 db-ojb/src/test/org/apache/ojb/Attic/repository_junit_inheritance.xml --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org For additional commands, e-mail: ojb-dev-help@db.apache.org