cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r954823 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server: ServerCaseLifecycleManager.java ServerCaseSelfTest.java
Date Tue, 15 Jun 2010 11:13:51 GMT
Author: aadamchik
Date: Tue Jun 15 11:13:50 2010
New Revision: 954823

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

* ensure cache reset between the tests

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseLifecycleManager.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSelfTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseLifecycleManager.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseLifecycleManager.java?rev=954823&r1=954822&r2=954823&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseLifecycleManager.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseLifecycleManager.java
Tue Jun 15 11:13:50 2010
@@ -20,6 +20,7 @@ package org.apache.cayenne.unit.di.serve
 
 import junit.framework.TestCase;
 
+import org.apache.cayenne.access.DataDomain;
 import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.di.Provider;
 import org.apache.cayenne.unit.di.DefaultUnitTestLifecycleManager;
@@ -30,6 +31,9 @@ public class ServerCaseLifecycleManager 
     @Inject
     protected Provider<ServerCaseProperties> propertiesProvider;
 
+    @Inject
+    protected ServerRuntimeFactory runtimeFactory;
+
     public ServerCaseLifecycleManager(UnitTestScope scope) {
         super(scope);
     }
@@ -37,12 +41,22 @@ public class ServerCaseLifecycleManager 
     @Override
     public <T extends TestCase> void setUp(T testCase) {
 
+        // init current runtime
         UseServerRuntime runtimeName = testCase.getClass().getAnnotation(
                 UseServerRuntime.class);
 
         String location = runtimeName != null ? runtimeName.value() : null;
         propertiesProvider.get().setConfigurationLocation(location);
 
+        // clear shared caches
+        if (location != null) {
+            DataDomain channel = (DataDomain) runtimeFactory.get(location).getChannel();
+            channel.getEventManager().removeAllListeners(
+                    channel.getSharedSnapshotCache().getSnapshotEventSubject());
+            channel.getSharedSnapshotCache().clear();
+            channel.getQueryCache().clear();
+        }
+
         super.setUp(testCase);
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSelfTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSelfTest.java?rev=954823&r1=954822&r2=954823&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSelfTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseSelfTest.java
Tue Jun 15 11:13:50 2010
@@ -20,20 +20,20 @@ package org.apache.cayenne.unit.di.serve
 
 import org.apache.cayenne.di.Inject;
 
-@UseServerRuntime("xUy")
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
 public class ServerCaseSelfTest extends ServerCase {
 
     @Inject
     protected ServerRuntimeFactory runtimeFactory;
-    
+
     @Inject
     protected ServerCaseProperties properties;
 
     public void testSetup_TearDown_Runtime() throws Exception {
 
         assertNotNull(properties);
-        assertEquals("xUy", properties.getConfigurationLocation());
-        
+        assertEquals(ServerCase.TESTMAP_PROJECT, properties.getConfigurationLocation());
+
         ServerRuntimeFactory localFactory = this.runtimeFactory;
         assertNotNull(localFactory);
 



Mime
View raw message