cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r956881 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test: java/org/apache/cayenne/ java/org/apache/cayenne/remote/ java/org/apache/cayenne/unit/ java/org/apache/cayenne/unit/di/client/ resources/dml/
Date Tue, 22 Jun 2010 13:19:41 GMT
Author: aadamchik
Date: Tue Jun 22 13:19:40 2010
New Revision: 956881

URL: http://svn.apache.org/viewvc?rev=956881&view=rev
Log:
DI-enabled unit tests

* switching client tests... old tests also happened to leak EM threads

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/client/ClientCaseClientConnectionProvider.java
      - copied, changed from r956476, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/TestLocalConnectionTest.java
Removed:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/TestLocalConnectionTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/dml/CayenneContextMapRelationshipTest.xml
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextMapRelationshipTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextRefreshQueryTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextSQLTemplateTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextServerDiffsTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextValidationTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/PersistentObjectInContextTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/ClientChannelServerDiffsTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/ClientChannelTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/RemoteCayenneCase.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/RemoteIncrementalFaultListTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/client/ClientCaseModule.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextMapRelationshipTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextMapRelationshipTest.java?rev=956881&r1=956880&r2=956881&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextMapRelationshipTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextMapRelationshipTest.java Tue Jun 22 13:19:40 2010
@@ -20,48 +20,55 @@ package org.apache.cayenne;
 
 import java.util.Map;
 
-import org.apache.cayenne.access.ClientServerChannel;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.query.ObjectIdQuery;
 import org.apache.cayenne.query.RefreshQuery;
-import org.apache.cayenne.remote.ClientChannel;
-import org.apache.cayenne.remote.service.LocalConnection;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
 import org.apache.cayenne.testdo.mt.ClientMtMapToMany;
 import org.apache.cayenne.testdo.mt.ClientMtMapToManyTarget;
 import org.apache.cayenne.testdo.mt.MtMapToMany;
-import org.apache.cayenne.unit.AccessStack;
-import org.apache.cayenne.unit.CayenneCase;
-import org.apache.cayenne.unit.CayenneResources;
+import org.apache.cayenne.unit.di.client.ClientCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
-public class CayenneContextMapRelationshipTest extends CayenneCase {
+@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT)
+public class CayenneContextMapRelationshipTest extends ClientCase {
+
+    @Inject
+    private CayenneContext context;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    private TableHelper tMtMapToMany;
+    private TableHelper tMtMapToManyTarget;
 
     @Override
-    protected AccessStack buildAccessStack() {
-        return CayenneResources.getResources().getAccessStack(MULTI_TIER_ACCESS_STACK);
-    }
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("MT_MAP_TO_MANY_TARGET");
+        dbHelper.deleteAll("MT_MAP_TO_MANY");
+
+        tMtMapToMany = new TableHelper(dbHelper, "MT_MAP_TO_MANY");
+        tMtMapToMany.setColumns("ID");
 
-    private CayenneContext createClientContext() {
-        ClientServerChannel serverChannel = new ClientServerChannel(getDomain());
-        LocalConnection connection = new LocalConnection(serverChannel);
-        ClientChannel clientChannel = new ClientChannel(connection);
-        return new CayenneContext(clientChannel);
+        tMtMapToManyTarget = new TableHelper(dbHelper, "MT_MAP_TO_MANY_TARGET");
+        tMtMapToManyTarget.setColumns("ID", "MAP_TO_MANY_ID");
     }
 
-    @Override
-    protected void setUp() throws Exception {
-        deleteTestData();
+    private void createTwoMapToManysWithTargetsDataSet() throws Exception {
+        tMtMapToMany.insert(1).insert(2);
+        tMtMapToManyTarget.insert(1, 1).insert(2, 1).insert(3, 1).insert(4, 2);
     }
 
     public void testReadToMany() throws Exception {
-        createTestData("prepare");
-
-        ObjectContext context = createClientContext();
+        createTwoMapToManysWithTargetsDataSet();
 
         ObjectId id = new ObjectId("MtMapToMany", MtMapToMany.ID_PK_COLUMN, 1);
         ClientMtMapToMany o1 = (ClientMtMapToMany) Cayenne.objectForQuery(
                 context,
                 new ObjectIdQuery(id));
 
-        Map targets = o1.getTargets();
+        Map<Object, ClientMtMapToManyTarget> targets = o1.getTargets();
 
         assertTrue(((ValueHolder) targets).isFault());
 
@@ -73,22 +80,19 @@ public class CayenneContextMapRelationsh
     }
 
     public void testAddToMany() throws Exception {
-        createTestData("prepare");
-
-        ObjectContext context = createClientContext();
+        createTwoMapToManysWithTargetsDataSet();
 
         ObjectId id = new ObjectId("MtMapToMany", MtMapToMany.ID_PK_COLUMN, 1);
         ClientMtMapToMany o1 = (ClientMtMapToMany) Cayenne.objectForQuery(
                 context,
                 new ObjectIdQuery(id));
 
-        Map targets = o1.getTargets();
+        Map<Object, ClientMtMapToManyTarget> targets = o1.getTargets();
         assertNotNull(targets);
         assertEquals(3, targets.size());
 
-        ClientMtMapToManyTarget newTarget = o1
-                .getObjectContext()
-                .newObject(ClientMtMapToManyTarget.class);
+        ClientMtMapToManyTarget newTarget = o1.getObjectContext().newObject(
+                ClientMtMapToManyTarget.class);
 
         o1.addToTargets(newTarget);
         assertEquals(4, targets.size());
@@ -98,10 +102,10 @@ public class CayenneContextMapRelationsh
 
         o1.getObjectContext().performGenericQuery(new RefreshQuery());
         assertEquals(4, o1.getTargets().size());
-        
+
         int newId = Cayenne.intPKForObject(newTarget);
         assertSame(newTarget, o1.getTargets().get(new Integer(newId)));
-        
+
         assertEquals(PersistenceState.COMMITTED, o1.getPersistenceState());
         assertEquals(PersistenceState.COMMITTED, newTarget.getPersistenceState());
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextRefreshQueryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextRefreshQueryTest.java?rev=956881&r1=956880&r2=956881&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextRefreshQueryTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextRefreshQueryTest.java Tue Jun 22 13:19:40 2010
@@ -19,6 +19,7 @@
 package org.apache.cayenne;
 
 import org.apache.cayenne.access.ClientServerChannel;
+import org.apache.cayenne.event.MockEventManager;
 import org.apache.cayenne.query.RefreshQuery;
 import org.apache.cayenne.remote.ClientChannel;
 import org.apache.cayenne.remote.service.LocalConnection;
@@ -33,14 +34,18 @@ public class CayenneContextRefreshQueryT
     protected AccessStack buildAccessStack() {
         return CayenneResources.getResources().getAccessStack(MULTI_TIER_ACCESS_STACK);
     }
-    
+
     private CayenneContext createClientContext() {
         ClientServerChannel serverChannel = new ClientServerChannel(getDomain());
         LocalConnection connection = new LocalConnection(serverChannel);
-        ClientChannel clientChannel = new ClientChannel(connection);
+        ClientChannel clientChannel = new ClientChannel(
+                connection,
+                false,
+                new MockEventManager(),
+                false);
         return new CayenneContext(clientChannel);
     }
-    
+
     public void testRefreshToMany() throws Exception {
 
         deleteTestData();

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextSQLTemplateTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextSQLTemplateTest.java?rev=956881&r1=956880&r2=956881&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextSQLTemplateTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextSQLTemplateTest.java Tue Jun 22 13:19:40 2010
@@ -18,44 +18,30 @@
  ****************************************************************/
 package org.apache.cayenne;
 
-import org.apache.cayenne.access.ClientServerChannel;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.query.SQLTemplate;
-import org.apache.cayenne.remote.ClientChannel;
-import org.apache.cayenne.remote.service.LocalConnection;
+import org.apache.cayenne.test.jdbc.DBHelper;
 import org.apache.cayenne.testdo.mt.ClientMtTable1;
-import org.apache.cayenne.unit.AccessStack;
-import org.apache.cayenne.unit.CayenneCase;
-import org.apache.cayenne.unit.CayenneResources;
+import org.apache.cayenne.unit.di.client.ClientCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
-public class CayenneContextSQLTemplateTest extends CayenneCase {
+@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT)
+public class CayenneContextSQLTemplateTest extends ClientCase {
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        getDomain().getSharedSnapshotCache().clear();
-        getDomain().getQueryCache().clear();
-        deleteTestData();
-    }
+    @Inject
+    private DBHelper dbHelper;
 
-    @Override
-    protected AccessStack buildAccessStack() {
-        return CayenneResources.getResources().getAccessStack(MULTI_TIER_ACCESS_STACK);
-    }
+    @Inject
+    private CayenneContext context;
 
-    private CayenneContext createClientContext() {
-
-        ClientServerChannel serverChannel = new ClientServerChannel(getDomain());
-        LocalConnection connection = new LocalConnection(
-                serverChannel,
-                LocalConnection.HESSIAN_SERIALIZATION);
-        ClientChannel clientChannel = new ClientChannel(connection);
-        return new CayenneContext(clientChannel);
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("MT_TABLE2");
+        dbHelper.deleteAll("MT_TABLE1");
     }
 
     public void testObjectRoot() throws Exception {
 
-        CayenneContext context = createClientContext();
-
         assertNull(Cayenne.objectForPK(context, ClientMtTable1.class, 1));
         context.performGenericQuery(new SQLTemplate(
                 ClientMtTable1.class,

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextServerDiffsTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextServerDiffsTest.java?rev=956881&r1=956880&r2=956881&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextServerDiffsTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextServerDiffsTest.java Tue Jun 22 13:19:40 2010
@@ -19,42 +19,39 @@
 package org.apache.cayenne;
 
 import org.apache.cayenne.access.ClientServerChannel;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.map.LifecycleEvent;
 import org.apache.cayenne.reflect.LifecycleCallbackRegistry;
-import org.apache.cayenne.remote.ClientChannel;
 import org.apache.cayenne.remote.ClientChannelServerDiffsListener1;
-import org.apache.cayenne.remote.service.LocalConnection;
 import org.apache.cayenne.testdo.mt.ClientMtTable1;
 import org.apache.cayenne.testdo.mt.ClientMtTable2;
 import org.apache.cayenne.testdo.mt.MtTable1;
-import org.apache.cayenne.unit.AccessStack;
-import org.apache.cayenne.unit.CayenneCase;
-import org.apache.cayenne.unit.CayenneResources;
-
-public class CayenneContextServerDiffsTest extends CayenneCase {
-
-    @Override
-    protected AccessStack buildAccessStack() {
-        return CayenneResources.getResources().getAccessStack(MULTI_TIER_ACCESS_STACK);
-    }
+import org.apache.cayenne.unit.di.client.ClientCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT)
+public class CayenneContextServerDiffsTest extends ClientCase {
+
+    @Inject
+    private ClientServerChannel clientServerChannel;
+
+    @Inject
+    private CayenneContext context;
 
     public void testReturnDiffInPrePersist() {
 
-        LifecycleCallbackRegistry registry = getDomain()
+        LifecycleCallbackRegistry callbackRegistry = clientServerChannel
                 .getEntityResolver()
                 .getCallbackRegistry();
 
         try {
 
-            registry.addListener(
+            callbackRegistry.addListener(
                     LifecycleEvent.POST_ADD,
                     MtTable1.class,
                     new ClientChannelServerDiffsListener1(),
                     "prePersist");
 
-            ClientServerChannel csChannel = new ClientServerChannel(getDomain());
-            ClientChannel channel = new ClientChannel(new LocalConnection(csChannel));
-            CayenneContext context = new CayenneContext(channel);
             ClientMtTable1 o = context.newObject(ClientMtTable1.class);
             o.setServerAttribute1("YY");
             context.commitChanges();
@@ -64,27 +61,23 @@ public class CayenneContextServerDiffsTe
             assertEquals("XXX", o.getGlobalAttribute1());
         }
         finally {
-            registry.clear();
+            callbackRegistry.clear();
         }
     }
 
     public void testReturnDiffInPreUpdate() {
-
-        LifecycleCallbackRegistry registry = getDomain()
+        LifecycleCallbackRegistry callbackRegistry = clientServerChannel
                 .getEntityResolver()
                 .getCallbackRegistry();
 
         try {
 
-            registry.addListener(
+            callbackRegistry.addListener(
                     LifecycleEvent.PRE_UPDATE,
                     MtTable1.class,
                     new ClientChannelServerDiffsListener1(),
                     "preUpdate");
 
-            ClientServerChannel csChannel = new ClientServerChannel(getDomain());
-            ClientChannel channel = new ClientChannel(new LocalConnection(csChannel));
-            CayenneContext context = new CayenneContext(channel);
             ClientMtTable1 o = context.newObject(ClientMtTable1.class);
             o.setServerAttribute1("YY");
             context.commitChanges();
@@ -99,26 +92,23 @@ public class CayenneContextServerDiffsTe
             assertEquals("111", o.getGlobalAttribute1());
         }
         finally {
-            registry.clear();
+            callbackRegistry.clear();
         }
     }
 
     public void testReturnDiffClientArcChanges() {
 
-        LifecycleCallbackRegistry registry = getDomain()
+        LifecycleCallbackRegistry callbackRegistry = clientServerChannel
                 .getEntityResolver()
                 .getCallbackRegistry();
 
         try {
-            registry.addListener(
+            callbackRegistry.addListener(
                     LifecycleEvent.POST_ADD,
                     MtTable1.class,
                     new ClientChannelServerDiffsListener1(),
                     "prePersist");
 
-            ClientServerChannel csChannel = new ClientServerChannel(getDomain());
-            ClientChannel channel = new ClientChannel(new LocalConnection(csChannel));
-            CayenneContext context = new CayenneContext(channel);
             ClientMtTable1 o = context.newObject(ClientMtTable1.class);
             ClientMtTable2 o1 = context.newObject(ClientMtTable2.class);
             o.addToTable2Array(o1);
@@ -129,26 +119,23 @@ public class CayenneContextServerDiffsTe
             assertEquals("XXX", o.getGlobalAttribute1());
         }
         finally {
-            registry.clear();
+            callbackRegistry.clear();
         }
     }
 
     public void testReturnDiffServerArcChanges() {
 
-        LifecycleCallbackRegistry registry = getDomain()
+        LifecycleCallbackRegistry callbackRegistry = clientServerChannel
                 .getEntityResolver()
                 .getCallbackRegistry();
 
         try {
-            registry.addListener(
+            callbackRegistry.addListener(
                     LifecycleEvent.POST_ADD,
                     MtTable1.class,
                     new ClientChannelServerDiffsListener1(),
                     "prePersistAddRelationship");
 
-            ClientServerChannel csChannel = new ClientServerChannel(getDomain());
-            ClientChannel channel = new ClientChannel(new LocalConnection(csChannel));
-            CayenneContext context = new CayenneContext(channel);
             ClientMtTable1 o = context.newObject(ClientMtTable1.class);
             ClientMtTable2 o1 = context.newObject(ClientMtTable2.class);
             o.addToTable2Array(o1);
@@ -157,10 +144,10 @@ public class CayenneContextServerDiffsTe
             assertFalse(o.getObjectId().isTemporary());
             assertEquals(PersistenceState.COMMITTED, o.getPersistenceState());
             assertEquals(2, o.getTable2Array().size());
-            
+
         }
         finally {
-            registry.clear();
+            callbackRegistry.clear();
         }
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextTest.java?rev=956881&r1=956880&r2=956881&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextTest.java Tue Jun 22 13:19:40 2010
@@ -25,8 +25,10 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.event.DefaultEventManager;
 import org.apache.cayenne.event.EventManager;
+import org.apache.cayenne.event.MockEventManager;
 import org.apache.cayenne.graph.CompoundDiff;
 import org.apache.cayenne.graph.GraphDiff;
 import org.apache.cayenne.graph.MockGraphDiff;
@@ -39,19 +41,15 @@ import org.apache.cayenne.remote.ClientC
 import org.apache.cayenne.remote.MockClientConnection;
 import org.apache.cayenne.testdo.mt.ClientMtTable1;
 import org.apache.cayenne.testdo.mt.MtTable1;
-import org.apache.cayenne.unit.AccessStack;
-import org.apache.cayenne.unit.CayenneCase;
-import org.apache.cayenne.unit.CayenneResources;
+import org.apache.cayenne.unit.di.client.ClientCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 import org.apache.cayenne.util.GenericResponse;
 
-/**
- */
-public class CayenneContextTest extends CayenneCase {
-
-    @Override
-    protected AccessStack buildAccessStack() {
-        return CayenneResources.getResources().getAccessStack(MULTI_TIER_ACCESS_STACK);
-    }
+@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT)
+public class CayenneContextTest extends ClientCase {
+
+    @Inject
+    protected ObjectContext serverContext;
 
     public void testConstructor() {
 
@@ -70,9 +68,12 @@ public class CayenneContextTest extends 
 
         MockDataChannel channel = new MockDataChannel();
         CayenneContext src = new CayenneContext(channel);
-        src.setEntityResolver(getDomain().getEntityResolver().getClientEntityResolver());
+        src
+                .setEntityResolver(serverContext
+                        .getEntityResolver()
+                        .getClientEntityResolver());
 
-        List sources = new ArrayList();
+        List<Persistent> sources = new ArrayList<Persistent>();
 
         ClientMtTable1 s1 = new ClientMtTable1();
         s1.setPersistenceState(PersistenceState.COMMITTED);
@@ -98,12 +99,12 @@ public class CayenneContextTest extends 
         sources.add(s3);
 
         CayenneContext target = new CayenneContext(channel);
-        target.setEntityResolver(getDomain()
+        target.setEntityResolver(serverContext
                 .getEntityResolver()
                 .getClientEntityResolver());
 
         for (int i = 0; i < sources.size(); i++) {
-            Persistent srcObject = (Persistent) sources.get(i);
+            Persistent srcObject = sources.get(i);
             Persistent targetObject = target.localObject(
                     srcObject.getObjectId(),
                     srcObject);
@@ -136,7 +137,7 @@ public class CayenneContextTest extends 
     public void testCommitCommandExecuted() {
 
         MockDataChannel channel = new MockDataChannel(new MockGraphDiff());
-        channel.setEntityResolver(getDomain()
+        channel.setEntityResolver(serverContext
                 .getEntityResolver()
                 .getClientEntityResolver());
         CayenneContext context = new CayenneContext(channel);
@@ -189,7 +190,7 @@ public class CayenneContextTest extends 
 
         DataMap dataMap = new DataMap("test");
         dataMap.addObjEntity(entity);
-        Collection entities = Collections.singleton(dataMap);
+        Collection<DataMap> entities = Collections.singleton(dataMap);
         context.setEntityResolver(new EntityResolver(entities));
         Persistent object = context.newObject(MockPersistentObject.class);
 
@@ -212,7 +213,7 @@ public class CayenneContextTest extends 
 
         DataMap dataMap = new DataMap("test");
         dataMap.addObjEntity(entity);
-        Collection entities = Collections.singleton(dataMap);
+        Collection<DataMap> entities = Collections.singleton(dataMap);
         context.setEntityResolver(new EntityResolver(entities));
 
         Persistent object = context.newObject(MockPersistentObject.class);
@@ -236,7 +237,7 @@ public class CayenneContextTest extends 
 
         DataMap dataMap = new DataMap("test");
         dataMap.addObjEntity(entity);
-        Collection entities = Collections.singleton(dataMap);
+        Collection<DataMap> entities = Collections.singleton(dataMap);
         context.setEntityResolver(new EntityResolver(entities));
 
         // TRANSIENT ... should quietly ignore it
@@ -292,7 +293,11 @@ public class CayenneContextTest extends 
 
         MockClientConnection connection = new MockClientConnection(new GenericResponse(
                 Arrays.asList(inflated)));
-        ClientChannel channel = new ClientChannel(connection);
+        ClientChannel channel = new ClientChannel(
+                connection,
+                false,
+                new MockEventManager(),
+                false);
 
         // check that a HOLLOW object is infalted on "beforePropertyRead"
         ClientMtTable1 hollow = new ClientMtTable1();
@@ -303,13 +308,13 @@ public class CayenneContextTest extends 
         CayenneContext context = new CayenneContext(channel) {
 
             @Override
-            public List performQuery(Query query) {
+            public List<?> performQuery(Query query) {
                 selectExecuted[0] = true;
                 return super.performQuery(query);
             }
         };
 
-        context.setEntityResolver(getDomain()
+        context.setEntityResolver(serverContext
                 .getEntityResolver()
                 .getClientEntityResolver());
 
@@ -338,10 +343,14 @@ public class CayenneContextTest extends 
 
         MockClientConnection connection = new MockClientConnection(new GenericResponse(
                 Arrays.asList(inflated)));
-        ClientChannel channel = new ClientChannel(connection);
+        ClientChannel channel = new ClientChannel(
+                connection,
+                false,
+                new MockEventManager(),
+                false);
 
         CayenneContext context = new CayenneContext(channel);
-        context.setEntityResolver(getDomain()
+        context.setEntityResolver(serverContext
                 .getEntityResolver()
                 .getClientEntityResolver());
         ClientMtTable1 hollow = (ClientMtTable1) context.localObject(gid, null);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextValidationTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextValidationTest.java?rev=956881&r1=956880&r2=956881&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextValidationTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextValidationTest.java Tue Jun 22 13:19:40 2010
@@ -19,75 +19,71 @@
 
 package org.apache.cayenne;
 
-import org.apache.cayenne.access.ClientServerChannel;
-import org.apache.cayenne.remote.ClientChannel;
-import org.apache.cayenne.remote.service.LocalConnection;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.test.jdbc.DBHelper;
 import org.apache.cayenne.testdo.mt.ClientMtTable1;
 import org.apache.cayenne.testdo.mt.ClientMtTable2;
-import org.apache.cayenne.unit.AccessStack;
-import org.apache.cayenne.unit.CayenneCase;
-import org.apache.cayenne.unit.CayenneResources;
+import org.apache.cayenne.unit.di.client.ClientCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 import org.apache.cayenne.validation.ValidationException;
 
-public class CayenneContextValidationTest extends CayenneCase {
+@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT)
+public class CayenneContextValidationTest extends ClientCase {
+
+    @Inject
+    private DBHelper dbHelper;
+
+    @Inject
+    private CayenneContext context;
 
     @Override
-    protected AccessStack buildAccessStack() {
-        return CayenneResources
-                .getResources()
-                .getAccessStack(MULTI_TIER_ACCESS_STACK);
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("MT_TABLE2");
+        dbHelper.deleteAll("MT_TABLE1");
     }
 
     public void testValidate() throws Exception {
 
-        deleteTestData();
-        DataChannel serverChannel = new ClientServerChannel(getDomain());
-        ClientChannel clientChannel = new ClientChannel(
-                new LocalConnection(serverChannel),
-                true);
-
-        CayenneContext c = new CayenneContext(clientChannel);
-        
-        ClientMtTable1 o1 = c.newObject(ClientMtTable1.class);
+        ClientMtTable1 o1 = context.newObject(ClientMtTable1.class);
         o1.setGlobalAttribute1("G1");
         o1.resetValidation(false);
-        
+
         // this one is not validating
-        ClientMtTable2 o2 = c.newObject(ClientMtTable2.class);
+        ClientMtTable2 o2 = context.newObject(ClientMtTable2.class);
         o2.setTable1(o1);
-        
-        c.commitChanges();
+
+        context.commitChanges();
         assertTrue(o1.isValidatedForInsert());
         assertFalse(o1.isValidatedForDelete());
         assertFalse(o1.isValidatedForUpdate());
-        
+
         o1.resetValidation(false);
         o1.setGlobalAttribute1("G2");
-        
-        c.commitChanges();
+
+        context.commitChanges();
         assertFalse(o1.isValidatedForInsert());
         assertFalse(o1.isValidatedForDelete());
         assertTrue(o1.isValidatedForUpdate());
-        
+
         o1.resetValidation(false);
-        c.deleteObject(o1);
-        c.deleteObject(o2);
-        
-        c.commitChanges();
+        context.deleteObject(o1);
+        context.deleteObject(o2);
+
+        context.commitChanges();
         assertFalse(o1.isValidatedForInsert());
         assertTrue(o1.isValidatedForDelete());
         assertFalse(o1.isValidatedForUpdate());
-        
-        ClientMtTable1 o11 = c.newObject(ClientMtTable1.class);
+
+        ClientMtTable1 o11 = context.newObject(ClientMtTable1.class);
         o11.setGlobalAttribute1("G1");
         o11.resetValidation(true);
-        
+
         try {
-            c.commitChanges();
+            context.commitChanges();
             fail("Validation failure must have prevented commit");
         }
         catch (ValidationException e) {
-           // expected
+            // expected
         }
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/PersistentObjectInContextTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/PersistentObjectInContextTest.java?rev=956881&r1=956880&r2=956881&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/PersistentObjectInContextTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/PersistentObjectInContextTest.java Tue Jun 22 13:19:40 2010
@@ -23,6 +23,7 @@ import java.util.Iterator;
 import java.util.List;
 
 import org.apache.cayenne.access.ClientServerChannel;
+import org.apache.cayenne.event.MockEventManager;
 import org.apache.cayenne.query.ObjectIdQuery;
 import org.apache.cayenne.remote.ClientChannel;
 import org.apache.cayenne.remote.ClientConnection;
@@ -40,16 +41,18 @@ public class PersistentObjectInContextTe
 
     @Override
     protected AccessStack buildAccessStack() {
-        return CayenneResources
-                .getResources()
-                .getAccessStack(MULTI_TIER_ACCESS_STACK);
+        return CayenneResources.getResources().getAccessStack(MULTI_TIER_ACCESS_STACK);
     }
 
     protected ObjectContext createObjectContext() {
         // wrap ClientServerChannel in LocalConnection to enable logging...
         ClientConnection connector = new LocalConnection(new ClientServerChannel(
                 getDomain()), LocalConnection.HESSIAN_SERIALIZATION);
-        return new CayenneContext(new ClientChannel(connector));
+        return new CayenneContext(new ClientChannel(
+                connector,
+                false,
+                new MockEventManager(),
+                false));
     }
 
     public void testResolveToManyReverseResolved() throws Exception {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/ClientChannelServerDiffsTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/ClientChannelServerDiffsTest.java?rev=956881&r1=956880&r2=956881&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/ClientChannelServerDiffsTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/ClientChannelServerDiffsTest.java Tue Jun 22 13:19:40 2010
@@ -25,24 +25,26 @@ import org.apache.cayenne.CayenneContext
 import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.access.ClientServerChannel;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.event.MockEventManager;
 import org.apache.cayenne.graph.GraphChangeHandler;
 import org.apache.cayenne.graph.GraphDiff;
 import org.apache.cayenne.map.LifecycleEvent;
 import org.apache.cayenne.reflect.LifecycleCallbackRegistry;
-import org.apache.cayenne.remote.service.LocalConnection;
 import org.apache.cayenne.testdo.mt.ClientMtTable1;
 import org.apache.cayenne.testdo.mt.ClientMtTable2;
 import org.apache.cayenne.testdo.mt.MtTable1;
-import org.apache.cayenne.unit.AccessStack;
-import org.apache.cayenne.unit.CayenneCase;
-import org.apache.cayenne.unit.CayenneResources;
-
-public class ClientChannelServerDiffsTest extends CayenneCase {
-
-    @Override
-    protected AccessStack buildAccessStack() {
-        return CayenneResources.getResources().getAccessStack(MULTI_TIER_ACCESS_STACK);
-    }
+import org.apache.cayenne.unit.di.client.ClientCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+@UseServerRuntime(ClientCase.MULTI_TIER_PROJECT)
+public class ClientChannelServerDiffsTest extends ClientCase {
+
+    @Inject
+    private ClientServerChannel clientServerChannel;
+
+    @Inject
+    private ClientConnection connection;
 
     public void testReturnIdDiff() {
 
@@ -57,8 +59,11 @@ public class ClientChannelServerDiffsTes
             }
         };
 
-        ClientServerChannel csChannel = new ClientServerChannel(getDomain());
-        ClientChannel channel = new ClientChannel(new LocalConnection(csChannel)) {
+        ClientChannel channel = new ClientChannel(
+                connection,
+                false,
+                new MockEventManager(),
+                false) {
 
             @Override
             public GraphDiff onSync(
@@ -109,20 +114,23 @@ public class ClientChannelServerDiffsTes
 
         };
 
-        LifecycleCallbackRegistry registry = getDomain()
+        LifecycleCallbackRegistry callbackRegistry = clientServerChannel
                 .getEntityResolver()
                 .getCallbackRegistry();
 
         try {
 
-            registry.addListener(
+            callbackRegistry.addListener(
                     LifecycleEvent.POST_ADD,
                     MtTable1.class,
                     new ClientChannelServerDiffsListener1(),
                     "prePersist");
 
-            ClientServerChannel csChannel = new ClientServerChannel(getDomain());
-            ClientChannel channel = new ClientChannel(new LocalConnection(csChannel)) {
+            ClientChannel channel = new ClientChannel(
+                    connection,
+                    false,
+                    new MockEventManager(),
+                    false) {
 
                 @Override
                 public GraphDiff onSync(
@@ -155,7 +163,7 @@ public class ClientChannelServerDiffsTes
             assertEquals("XXX", diffs.get(0).newValue);
         }
         finally {
-            registry.clear();
+            callbackRegistry.clear();
         }
     }
 
@@ -163,8 +171,11 @@ public class ClientChannelServerDiffsTes
 
         final NoopGraphChangeHandler diffReader = new NoopGraphChangeHandler();
 
-        ClientServerChannel csChannel = new ClientServerChannel(getDomain());
-        ClientChannel channel = new ClientChannel(new LocalConnection(csChannel)) {
+        ClientChannel channel = new ClientChannel(
+                connection,
+                false,
+                new MockEventManager(),
+                false) {
 
             @Override
             public GraphDiff onSync(
@@ -241,18 +252,9 @@ public class ClientChannelServerDiffsTes
         private Object oldValue;
         private Object newValue;
         private ObjectId sourceId;
-        private ObjectId targetId;
 
         GenericDiff(ObjectId sourceId, String property, Object oldValue, Object newValue) {
-
-            this(sourceId, null, property, oldValue, newValue);
-        }
-
-        GenericDiff(ObjectId sourceId, ObjectId targetId, String property,
-                Object oldValue, Object newValue) {
-
             this.sourceId = sourceId;
-            this.targetId = targetId;
             this.property = property;
             this.oldValue = oldValue;
             this.newValue = newValue;

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/ClientChannelTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/ClientChannelTest.java?rev=956881&r1=956880&r2=956881&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/ClientChannelTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/ClientChannelTest.java Tue Jun 22 13:19:40 2010
@@ -34,6 +34,7 @@ import org.apache.cayenne.QueryResponse;
 import org.apache.cayenne.event.CayenneEvent;
 import org.apache.cayenne.event.DefaultEventManager;
 import org.apache.cayenne.event.EventBridge;
+import org.apache.cayenne.event.MockEventManager;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.map.ObjEntity;
@@ -51,7 +52,11 @@ public class ClientChannelTest extends C
         MockClientConnection connection = new MockClientConnection(new GenericResponse(
                 Arrays.asList(o1)));
 
-        ClientChannel channel = new ClientChannel(connection);
+        ClientChannel channel = new ClientChannel(
+                connection,
+                false,
+                new MockEventManager(),
+                false);
 
         CayenneContext context = new CayenneContext(channel);
         ObjEntity entity = new ObjEntity("test_entity");
@@ -59,12 +64,12 @@ public class ClientChannelTest extends C
 
         DataMap dataMap = new DataMap("test");
         dataMap.addObjEntity(entity);
-        Collection entities = Collections.singleton(dataMap);
+        Collection<DataMap> entities = Collections.singleton(dataMap);
         context.setEntityResolver(new EntityResolver(entities));
 
         QueryResponse response = channel.onQuery(context, new SelectQuery("test_entity"));
         assertNotNull(response);
-        List list = response.firstList();
+        List<?> list = response.firstList();
         assertNotNull(list);
         assertEquals(1, list.size());
         Persistent o1_1 = (Persistent) list.get(0);
@@ -82,7 +87,7 @@ public class ClientChannelTest extends C
 
         DataMap dataMap = new DataMap("test");
         dataMap.addObjEntity(entity);
-        Collection entities = Collections.singleton(dataMap);
+        Collection<DataMap> entities = Collections.singleton(dataMap);
         EntityResolver resolver = new EntityResolver(entities);
 
         CayenneContext context = new CayenneContext();
@@ -101,13 +106,17 @@ public class ClientChannelTest extends C
         MockClientConnection connection = new MockClientConnection(new GenericResponse(
                 Arrays.asList(o2)));
 
-        ClientChannel channel = new ClientChannel(connection);
+        ClientChannel channel = new ClientChannel(
+                connection,
+                false,
+                new MockEventManager(),
+                false);
 
         context.setChannel(channel);
         QueryResponse response = channel.onQuery(context, new SelectQuery("test_entity"));
         assertNotNull(response);
 
-        List list = response.firstList();
+        List<?> list = response.firstList();
         assertNotNull(list);
         assertEquals(1, list.size());
         assertTrue("Expected cached object, got: " + list, list.contains(o1));
@@ -119,7 +128,7 @@ public class ClientChannelTest extends C
         entity.setClassName(MockPersistentObject.class.getName());
         DataMap dataMap = new DataMap("test");
         dataMap.addObjEntity(entity);
-        Collection entities = Collections.singleton(dataMap);
+        Collection<DataMap> entities = Collections.singleton(dataMap);
         EntityResolver resolver = new EntityResolver(entities);
         CayenneContext context = new CayenneContext();
         context.setEntityResolver(resolver);
@@ -137,13 +146,16 @@ public class ClientChannelTest extends C
         MockClientConnection connection = new MockClientConnection(new GenericResponse(
                 Arrays.asList(o2)));
 
-        ClientChannel channel = new ClientChannel(connection);
+        ClientChannel channel = new ClientChannel(connection,
+                false,
+                new MockEventManager(),
+                false);
 
         context.setChannel(channel);
         QueryResponse response = channel.onQuery(context, new SelectQuery("test_entity"));
         assertNotNull(response);
         assertEquals(1, response.size());
-        List list = response.firstList();
+        List<?> list = response.firstList();
         assertNotNull(list);
         assertEquals(1, list.size());
         assertTrue("Expected cached object, got: " + list, list.contains(o1));
@@ -177,7 +189,10 @@ public class ClientChannelTest extends C
 
         // default constructor must fail
         try {
-            new ClientChannel(connection);
+            new ClientChannel(connection,
+                    false,
+                    new MockEventManager(),
+                    false);
             fail("Channel didn't throw on broken EventBridge");
         }
         catch (CayenneRuntimeException e) {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/RemoteCayenneCase.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/RemoteCayenneCase.java?rev=956881&r1=956880&r2=956881&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/RemoteCayenneCase.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/RemoteCayenneCase.java Tue Jun 22 13:19:40 2010
@@ -21,6 +21,7 @@ package org.apache.cayenne.remote;
 import org.apache.cayenne.CayenneContext;
 import org.apache.cayenne.access.ClientServerChannel;
 import org.apache.cayenne.access.DataContext;
+import org.apache.cayenne.event.DefaultEventManager;
 import org.apache.cayenne.remote.service.LocalConnection;
 import org.apache.cayenne.unit.AccessStack;
 import org.apache.cayenne.unit.CayenneCase;
@@ -30,16 +31,17 @@ import org.apache.cayenne.unit.UnitLocal
 /**
  * JUnit case to test ROP functionality
  */
-public abstract class RemoteCayenneCase extends CayenneCase { 
+public abstract class RemoteCayenneCase extends CayenneCase {
+
     protected CayenneContext context;
-    
+
     protected DataContext parentDataContext;
-    
+
     /**
      * Used serialization policy. Per CAY-979 we're testing on all policies
      */
     protected int serializationPolicy;
-    
+
     @Override
     public void runBare() throws Throwable {
         serializationPolicy = LocalConnection.HESSIAN_SERIALIZATION;
@@ -49,26 +51,31 @@ public abstract class RemoteCayenneCase 
         serializationPolicy = LocalConnection.NO_SERIALIZATION;
         runBareSimple();
     }
-    
+
     protected void runBareSimple() throws Throwable {
         super.runBare();
     }
-    
+
     @Override
     public void setUp() throws Exception {
         parentDataContext = createDataContext();
         context = createROPContext();
     }
-    
+
     protected CayenneContext createROPContext() {
-        ClientServerChannel clientServerChannel = new ClientServerChannel(parentDataContext);
+        ClientServerChannel clientServerChannel = new ClientServerChannel(
+                parentDataContext);
         UnitLocalConnection connection = new UnitLocalConnection(
                 clientServerChannel,
                 serializationPolicy);
-        ClientChannel channel = new ClientChannel(connection);
+        ClientChannel channel = new ClientChannel(connection, false,
+        // we want events, but we don't want thread eaks, so creating single threaded EM.
+                // TODO: replace with container managed ClientCase.
+                new DefaultEventManager(0),
+                false);
         return new CayenneContext(channel, true, true);
     }
-    
+
     @Override
     protected AccessStack buildAccessStack() {
         return CayenneResources.getResources().getAccessStack(MULTI_TIER_ACCESS_STACK);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/RemoteIncrementalFaultListTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/RemoteIncrementalFaultListTest.java?rev=956881&r1=956880&r2=956881&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/RemoteIncrementalFaultListTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/remote/RemoteIncrementalFaultListTest.java Tue Jun 22 13:19:40 2010
@@ -26,6 +26,7 @@ import java.util.ListIterator;
 import org.apache.cayenne.CayenneContext;
 import org.apache.cayenne.Persistent;
 import org.apache.cayenne.access.ClientServerChannel;
+import org.apache.cayenne.event.MockEventManager;
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.exp.ExpressionFactory;
 import org.apache.cayenne.query.SelectQuery;
@@ -67,7 +68,10 @@ public class RemoteIncrementalFaultListT
         LocalConnection connection = new LocalConnection(
                 serverChannel,
                 LocalConnection.HESSIAN_SERIALIZATION);
-        ClientChannel clientChannel = new ClientChannel(connection);
+        ClientChannel clientChannel = new ClientChannel(connection,
+                false,
+                new MockEventManager(),
+                false);
 
         this.list = new RemoteIncrementalFaultList(
                 new CayenneContext(clientChannel),

Copied: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/client/ClientCaseClientConnectionProvider.java (from r956476, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/TestLocalConnectionTest.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/client/ClientCaseClientConnectionProvider.java?p2=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/client/ClientCaseClientConnectionProvider.java&p1=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/TestLocalConnectionTest.java&r1=956476&r2=956881&rev=956881&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/TestLocalConnectionTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/client/ClientCaseClientConnectionProvider.java Tue Jun 22 13:19:40 2010
@@ -16,34 +16,20 @@
  *  specific language governing permissions and limitations
  *  under the License.
  ****************************************************************/
+package org.apache.cayenne.unit.di.client;
 
-package org.apache.cayenne.unit;
+import org.apache.cayenne.ConfigurationException;
+import org.apache.cayenne.configuration.rop.client.ClientRuntime;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.di.Provider;
+import org.apache.cayenne.remote.ClientConnection;
 
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
+public class ClientCaseClientConnectionProvider implements Provider<ClientConnection> {
 
-import org.apache.cayenne.MockDataChannel;
-import org.apache.cayenne.query.NamedQuery;
-import org.apache.cayenne.remote.QueryMessage;
+    @Inject
+    protected Provider<ClientRuntime> clientRuntimeProvider;
 
-public class TestLocalConnectionTest extends TestCase {
-
-    public void testBlockUnblock() {
-
-        UnitLocalConnection c = new UnitLocalConnection(new MockDataChannel());
-        assertFalse(c.isBlockingMessages());
-
-        c.setBlockingMessages(true);
-        assertTrue(c.isBlockingMessages());
-
-        try {
-            c.sendMessage(new QueryMessage(new NamedQuery("dummy")));
-        }
-        catch (AssertionFailedError e) {
-            // expected...
-            return;
-        }
-        fail("Didn't block message...");
+    public ClientConnection get() throws ConfigurationException {
+        return clientRuntimeProvider.get().getConnection();
     }
-
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/client/ClientCaseModule.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/client/ClientCaseModule.java?rev=956881&r1=956880&r2=956881&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/client/ClientCaseModule.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/client/ClientCaseModule.java Tue Jun 22 13:19:40 2010
@@ -26,6 +26,7 @@ import org.apache.cayenne.di.Binder;
 import org.apache.cayenne.di.Key;
 import org.apache.cayenne.di.Module;
 import org.apache.cayenne.di.spi.DefaultScope;
+import org.apache.cayenne.remote.ClientConnection;
 import org.apache.cayenne.unit.di.DataChannelInterceptor;
 import org.apache.cayenne.unit.di.UnitTestLifecycleManager;
 
@@ -61,5 +62,7 @@ public class ClientCaseModule implements
 
         binder.bind(ClientServerChannel.class).toProvider(
                 ClientServerChannelProvider.class).in(testScope);
+        binder.bind(ClientConnection.class).toProvider(
+                ClientCaseClientConnectionProvider.class).in(testScope);
     }
 }



Mime
View raw message