cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r563282 - /cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/CayenneContextWithDataContextTest.java
Date Mon, 06 Aug 2007 21:07:17 GMT
Author: aadamchik
Date: Mon Aug  6 14:07:16 2007
New Revision: 563282

URL: http://svn.apache.org/viewvc?view=rev&rev=563282
Log:
CAY-797 Lifecycle callbacks *CallbackInterceptor concept introduces problems for testing equality
of contexts
adding extra test case

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/CayenneContextWithDataContextTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/CayenneContextWithDataContextTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/CayenneContextWithDataContextTest.java?view=diff&rev=563282&r1=563281&r2=563282
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/CayenneContextWithDataContextTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/CayenneContextWithDataContextTest.java
Mon Aug  6 14:07:16 2007
@@ -23,6 +23,7 @@
 import java.util.List;
 
 import org.apache.cayenne.access.ClientServerChannel;
+import org.apache.cayenne.access.DataDomain;
 import org.apache.cayenne.query.ObjectIdQuery;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.reflect.LifecycleCallbackRegistry;
@@ -93,6 +94,52 @@
             assertFalse(flag[0]);
             context.commitChanges();
             assertTrue(flag[0]);
+        }
+        finally {
+            callbackRegistry.clear();
+        }
+    }
+
+    class TestClientServerChannel extends ClientServerChannel {
+
+        TestClientServerChannel(DataDomain domain) {
+            super(domain);
+        }
+
+        public ObjectContext getServerContext() {
+            return serverContext;
+        }
+    }
+
+    public void testPrePersistOnObjectCallback() throws Exception {
+
+        TestClientServerChannel csChannel = new TestClientServerChannel(getDomain());
+
+        // an exception was triggered within POST_LOAD callback
+        LifecycleCallbackRegistry callbackRegistry = csChannel
+                .getEntityResolver()
+                .getCallbackRegistry();
+
+        try {
+            callbackRegistry.addListener(
+                    LifecycleListener.PRE_PERSIST,
+                    MtTable1.class,
+                    "prePersistMethod");
+
+            ClientConnection connection = new LocalConnection(csChannel);
+            ClientChannel channel = new ClientChannel(connection);
+
+            CayenneContext context = new CayenneContext(channel);
+
+            Persistent clientObject = context.newObject(ClientMtTable1.class);
+
+            context.commitChanges();
+
+            // find peer
+            MtTable1 peer = (MtTable1) csChannel.getServerContext().getGraphManager().getNode(
+                    clientObject.getObjectId());
+
+            assertTrue(peer.isPrePersisted());
         }
         finally {
             callbackRegistry.clear();



Mime
View raw message