You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-commits@db.apache.org by mc...@apache.org on 2006/06/23 20:31:38 UTC

svn commit: r416791 - /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/models/embedded/SecondClassObjectsTrackTheirChanges.java

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]);
+        }
+    }
 }