cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r566143 - /cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa/CPAContextCase.java
Date Wed, 15 Aug 2007 13:35:03 GMT
Author: aadamchik
Date: Wed Aug 15 06:35:01 2007
New Revision: 566143

URL: http://svn.apache.org/viewvc?view=rev&rev=566143
Log:
CAY-843 Remove arbitrary reverse relationship mapping limitations
(adding client uint tests - still some work to be done to make client one-way relationships
work like the server)

Modified:
    cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa/CPAContextCase.java

Modified: cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa/CPAContextCase.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa/CPAContextCase.java?view=diff&rev=566143&r1=566142&r2=566143
==============================================================================
--- cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa/CPAContextCase.java
(original)
+++ cayenne/main/trunk/itests/itest-common/src/main/java/org/apache/cayenne/itest/cpa/CPAContextCase.java
Wed Aug 15 06:35:01 2007
@@ -18,19 +18,53 @@
  ****************************************************************/
 package org.apache.cayenne.itest.cpa;
 
+import org.apache.cayenne.CayenneContext;
 import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.access.ClientServerChannel;
 import org.apache.cayenne.access.DataContext;
+import org.apache.cayenne.remote.ClientChannel;
+import org.apache.cayenne.remote.service.LocalConnection;
 
 public class CPAContextCase extends CPATestCase {
 
-    protected DataContext context;
-
-    @Override
-    protected void setUp() throws Exception {
-        this.context = ItestSetup.getInstance().createDataContext();
-    }
+    private DataContext context;
+    private ObjectContext clientContext;
 
     public ObjectContext getContext() {
+        if (context == null) {
+            this.context = ItestSetup.getInstance().createDataContext();
+        }
         return context;
+    }
+
+    public ObjectContext getContext(boolean reset) {
+        if (reset) {
+            this.context = null;
+        }
+
+        return getContext();
+    }
+
+    protected ObjectContext getClientContext() {
+        if (clientContext == null) {
+
+            // create with this test case DataContext to allow callers to poke on the
+            // server side as well as the client
+            ClientServerChannel clientServerChannel = new ClientServerChannel(
+                    (DataContext) getContext());
+            LocalConnection connection = new LocalConnection(clientServerChannel);
+            ClientChannel channel = new ClientChannel(connection);
+            clientContext = new CayenneContext(channel);
+        }
+
+        return clientContext;
+    }
+
+    protected ObjectContext getClientContext(boolean reset) {
+        if (reset) {
+            clientContext = null;
+        }
+
+        return getClientContext();
     }
 }



Mime
View raw message