Index: DataContextTestBase.java
===================================================================
RCS file: /cvsroot/cayenne/cayenne/src/tests/java/org/objectstyle/cayenne/access/DataContextTestBase.java,v
retrieving revision 1.16
diff -u -r1.16 DataContextTestBase.java
--- DataContextTestBase.java	19 Mar 2005 19:29:06 -0000	1.16
+++ DataContextTestBase.java	12 Oct 2005 00:03:38 -0000
@@ -110,6 +110,19 @@
         return (ats.size() > 0) ? (Artist) ats.get(0) : null;
     }
 
+    protected Artist fetchArtist(String name) {
+        return fetchArtist(name, false);
+    }
+    
+    protected Artist fetchArtist(String artistName, DataContext useContext) {
+        SelectQuery q =
+            new SelectQuery(
+                "Artist",
+                ExpressionFactory.matchExp("artistName", artistName));
+        List ats = useContext.performQuery(q);
+        return (ats.size() > 0) ? (Artist) ats.get(0) : null;
+    }
+    
     protected ROArtist fetchROArtist(String name) {
         SelectQuery q =
             new SelectQuery(
Index: DataContextTst.java
===================================================================
RCS file: /cvsroot/cayenne/cayenne/src/tests/java/org/objectstyle/cayenne/access/DataContextTst.java,v
retrieving revision 1.84
diff -u -r1.84 DataContextTst.java
--- DataContextTst.java	18 Sep 2005 23:48:58 -0000	1.84
+++ DataContextTst.java	12 Oct 2005 00:03:39 -0000
@@ -59,6 +59,7 @@
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -76,6 +77,7 @@
 import org.objectstyle.cayenne.Fault;
 import org.objectstyle.cayenne.ObjectId;
 import org.objectstyle.cayenne.PersistenceState;
+import org.objectstyle.cayenne.TestCaseDataFactory;
 import org.objectstyle.cayenne.access.util.QueryUtils;
 import org.objectstyle.cayenne.conn.PoolManager;
 import org.objectstyle.cayenne.exp.Expression;
@@ -187,6 +189,62 @@
         altA.getArtistName();
     }
 
+    public void testInvalidateObjects() throws Exception{
+        
+        TestCaseDataFactory.createArtist(
+                "testInvalidateObjects");
+        
+        DataContext altContext = createAltContext();
+
+        // Retrieve the artist in both contexts...
+        Artist artist = fetchArtist("testInvalidateObjects");
+        Artist altArtist = fetchArtist("testInvalidateObjects", altContext);
+        
+        assertEquals(artist.getPersistenceState(), altArtist.getPersistenceState());
+        
+        context.invalidateObjects(Collections.singleton(artist));
+        
+//      Pause to avoid race condition
+        Thread.sleep(5000);
+        
+        assertEquals(PersistenceState.HOLLOW, artist.getPersistenceState());
+        
+        // If the object hasn't been transientized, that's good...
+        assertEquals(PersistenceState.HOLLOW, altArtist.getPersistenceState());
+        
+    }
+
+    public void testInvalidateObjectsMergeSnapshots() throws Exception{
+        
+        TestCaseDataFactory.createArtist(
+                "testInvalidateObjectsMergeSnapshots");
+        
+        DataContext altContext = createAltContext();
+
+        // Retrieve the artist in both contexts...
+        Artist artist = fetchArtist("testInvalidateObjectsMergeSnapshots");
+        Artist altArtist = fetchArtist("testInvalidateObjectsMergeSnapshots", altContext);
+        
+        assertEquals(artist.getPersistenceState(), altArtist.getPersistenceState());
+        
+        Date now = new Date();
+        artist.setDateOfBirth(now);
+        altArtist.setArtistName("nameToAccept");
+        
+        altContext.commitChanges();
+        
+        Thread.sleep(5000);
+        
+        context.invalidateObjects(Collections.singleton(artist));
+        
+        // Pause to avoid race condition
+        Thread.sleep(5000);
+        
+        assertEquals("nameToAccept", artist.getArtistName());
+        
+    }
+    
+    
     private DataContext createAltContext() {
         // can't use super.createdataContext(), since it would clean up the cache
         return context.getParentDataDomain().createDataContext();
