From jdo-commits-return-1496-apmail-db-jdo-commits-archive=www.apache.org@db.apache.org Fri Jun 23 18:32:00 2006 Return-Path: Delivered-To: apmail-db-jdo-commits-archive@www.apache.org Received: (qmail 2588 invoked from network); 23 Jun 2006 18:32:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 23 Jun 2006 18:32:00 -0000 Received: (qmail 29184 invoked by uid 500); 23 Jun 2006 18:31:59 -0000 Mailing-List: contact jdo-commits-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-commits@db.apache.org Received: (qmail 29173 invoked by uid 99); 23 Jun 2006 18:31:59 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Jun 2006 11:31:59 -0700 X-ASF-Spam-Status: No, hits=-8.2 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME,WEIRD_QUOTING X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Jun 2006 11:31:58 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id B73B31A983A; Fri, 23 Jun 2006 11:31:38 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r416791 - /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/models/embedded/SecondClassObjectsTrackTheirChanges.java Date: Fri, 23 Jun 2006 18:31:38 -0000 To: jdo-commits@db.apache.org From: mcaisse@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060623183138.B73B31A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: mcaisse Date: Fri Jun 23 11:31:38 2006 New Revision: 416791 URL: http://svn.apache.org/viewvc?rev=416791&view=rev Log: JDO-389 Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/models/embedded/SecondClassObjectsTrackTheirChanges.java Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/models/embedded/SecondClassObjectsTrackTheirChanges.java URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/models/embedded/SecondClassObjectsTrackTheirChanges.java?rev=416791&r1=416790&r2=416791&view=diff ============================================================================== --- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/models/embedded/SecondClassObjectsTrackTheirChanges.java (original) +++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/models/embedded/SecondClassObjectsTrackTheirChanges.java Fri Jun 23 11:31:38 2006 @@ -63,28 +63,33 @@ addTearDownClass(Company.class); } - /** This tests that persistence-capable instances track changes or notify their owning instance that they are dirty */ + /** This tests that persistence-capable instances track changes + * or notify their owning instance that they are dirty */ public void testPCInstance() { pm = getPM(); - pm.currentTransaction().begin(); - Company comp = getPersistentNewInstance(0); - pm.currentTransaction().commit(); // obj should transition to hollow - testHollowInstance(comp); - pm.currentTransaction().begin(); - makePersistentCleanInstance(comp); - - Address addr = (Address)comp.getAddress(); - addr.setStreet("200 Orange Street"); // comp or addr should transition to persistent-dirty - int currComp = currentState(comp); - int currAddr = currentState(addr); - if ((currComp != PERSISTENT_DIRTY) && (currAddr != PERSISTENT_DIRTY)){ - fail(ASSERTION_FAILED, - "Unable to create persistent-dirty instance " + - "from persistent-clean instance via changing Address instance, state of Company instance is " + states[currComp] + " and state of Address instance is " + states[currAddr]); - } + pm.currentTransaction().begin(); + Company comp = getPersistentNewInstance(0); + pm.currentTransaction().commit(); // obj should transition to hollow + testHollowInstance(comp); + pm.currentTransaction().begin(); + makePersistentCleanInstance(comp); + + Address addr = (Address)comp.getAddress(); + // comp or addr should transition to persistent-dirty + addr.setStreet("200 Orange Street"); + int currComp = currentState(comp); + int currAddr = currentState(addr); + if ((currComp != PERSISTENT_DIRTY) && (currAddr != PERSISTENT_DIRTY)){ + fail(ASSERTION_FAILED, + "Unable to create persistent-dirty instance " + + "from persistent-clean instance via changing Address instance, " + + "state of Company instance is " + states[currComp] + + " and state of Address instance is " + states[currAddr]); + } } - /** This tests that mutable system class instances track changes or notify their owning instance that they are dirty */ + /** This tests that mutable system class instances track changes + * or notify their owning instance that they are dirty */ public void testMutableSystemClass() { pm = getPM(); pm.currentTransaction().begin(); @@ -94,48 +99,53 @@ pm.currentTransaction().begin(); makePersistentCleanInstance(comp); - Set depts = comp.getDepartments(); - comp.addDepartment(new Department(0,"HR",comp)); // comp or depts should transition to persistent-dirty - int currComp = currentState(comp); - int currDepts = currentState(depts); - if ((currComp != PERSISTENT_DIRTY) && (currDepts != PERSISTENT_DIRTY)){ - fail(ASSERTION_FAILED, - "Unable to create persistent-dirty instance " + - "from persistent-clean instance via changing Departments instance, state of Company instance is " + states[currComp] + " and state of Departments instance is " + states[currDepts]); - } + Set depts = comp.getDepartments(); + // comp or depts should transition to persistent-dirty + comp.addDepartment(new Department(0, "HR", comp)); + int currComp = currentState(comp); + int currDepts = currentState(depts); + if ((currComp != PERSISTENT_DIRTY) && (currDepts != PERSISTENT_DIRTY)){ + fail(ASSERTION_FAILED, + "Unable to create persistent-dirty instance " + + "from persistent-clean instance via changing Departments " + + "instance, state of Company instance is " + + states[currComp] + " and state of Departments instance is " + + states[currDepts]); + } + } + + public Company getPersistentNewInstance(long companyid) { + Company obj = new Company(companyid, "MyCompany", new Date(), + new Address(0,"","","","","")); + pm.makePersistent(obj); // obj should transition to persistent-new + int curr = currentState(obj); + if( curr != PERSISTENT_NEW ){ + fail(ASSERTION_FAILED, + "Unable to create persistent-new instance " + + "from transient instance via makePersistent(), state is " + + states[curr]); + } + return obj; } - public Company getPersistentNewInstance(long companyid) - { - Company obj = new Company(companyid, "MyCompany", new Date(), new Address(0,"","","","","")); - pm.makePersistent(obj); // obj should transition to persistent-new - int curr = currentState(obj); - if( curr != PERSISTENT_NEW ){ - fail(ASSERTION_FAILED, - "Unable to create persistent-new instance " + - "from transient instance via makePersistent(), state is " + states[curr]); - } - return obj; - } - - public void testHollowInstance(Company obj) - { - int curr = currentState(obj); - if( curr != HOLLOW ){ - fail(ASSERTION_FAILED, - "Unable to create hollow instance " + - "from persistent-new instance via commit(), state is " + states[curr]); - } + public void testHollowInstance(Company obj) { + int curr = currentState(obj); + if( curr != HOLLOW ){ + fail(ASSERTION_FAILED, + "Unable to create hollow instance " + + "from persistent-new instance via commit(), state is " + + states[curr]); + } } - public void makePersistentCleanInstance(Company obj) - { - pm.makeTransactional(obj); // obj should transition to persistent-clean - int curr = currentState(obj); - if( curr != PERSISTENT_CLEAN ){ - fail(ASSERTION_FAILED, - "Unable to create persistent-clean instance " + - "from hollow instance via makeTransactional(obj), state is " + states[curr]); - } - } + public void makePersistentCleanInstance(Company obj) { + pm.makeTransactional(obj); // obj should transition to persistent-clean + int curr = currentState(obj); + if( curr != PERSISTENT_CLEAN ){ + fail(ASSERTION_FAILED, + "Unable to create persistent-clean instance " + + "from hollow instance via makeTransactional(obj), state is " + + states[curr]); + } + } }