cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1074573 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataDomainCallbacksTest.java
Date Fri, 25 Feb 2011 15:15:44 GMT
Author: aadamchik
Date: Fri Feb 25 15:15:42 2011
New Revision: 1074573

URL: http://svn.apache.org/viewvc?rev=1074573&view=rev
Log:
adding callback unit test

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataDomainCallbacksTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataDomainCallbacksTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataDomainCallbacksTest.java?rev=1074573&r1=1074572&r2=1074573&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataDomainCallbacksTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataDomainCallbacksTest.java
Fri Feb 25 15:15:42 2011
@@ -204,6 +204,39 @@ public class DataDomainCallbacksTest ext
         assertSame(a1, listener.getPublicCalledbackEntity());
     }
 
+    public void testPostLoad_LocalObject() throws Exception {
+        LifecycleCallbackRegistry registry = getDomain()
+                .getEntityResolver()
+                .getCallbackRegistry();
+
+        ObjectContext context = createDataContext();
+
+        Artist a1 = context.newObject(Artist.class);
+        a1.setArtistName("XX");
+        context.commitChanges();
+
+        registry.addListener(LifecycleEvent.POST_LOAD, Artist.class, "postLoadCallback");
+        MockCallingBackListener listener = new MockCallingBackListener();
+        registry.addListener(
+                LifecycleEvent.POST_LOAD,
+                Artist.class,
+                listener,
+                "publicCallback");
+
+        // reset context and read related object
+        context = createDataContext();
+
+        Artist a2 = (Artist) context.localObject(a1.getObjectId(), null);
+
+        assertEquals(PersistenceState.HOLLOW, a2.getPersistenceState());
+        assertEquals(0, a2.getPostLoaded());
+        assertNull(listener.getPublicCalledbackEntity());
+
+        a2.getArtistName();
+        assertEquals(1, a2.getPostLoaded());
+        assertSame(a2, listener.getPublicCalledbackEntity());
+    }
+
     public void testPreUpdate() {
 
         LifecycleCallbackRegistry registry = getDomain()



Mime
View raw message