cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1098749 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCallbacksTest.java
Date Mon, 02 May 2011 19:14:24 GMT
Author: aadamchik
Date: Mon May  2 19:14:24 2011
New Revision: 1098749

URL: http://svn.apache.org/viewvc?rev=1098749&view=rev
Log:
CAY-1562 CayenneCase unit tests conversion

patches by Dzmitry Kazimirchyk:
DataContextCallbacksTest

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

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCallbacksTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCallbacksTest.java?rev=1098749&r1=1098748&r2=1098749&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCallbacksTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCallbacksTest.java
Mon May  2 19:14:24 2011
@@ -18,33 +18,50 @@
  ****************************************************************/
 package org.apache.cayenne.access;
 
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.map.LifecycleEvent;
 import org.apache.cayenne.reflect.LifecycleCallbackRegistry;
+import org.apache.cayenne.test.jdbc.DBHelper;
 import org.apache.cayenne.testdo.testmap.Artist;
 import org.apache.cayenne.testdo.testmap.Painting;
-import org.apache.cayenne.unit.CayenneCase;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
-public class DataContextCallbacksTest extends CayenneCase {
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataContextCallbacksTest extends ServerCase {
+
+    @Inject
+    private DataContext context;
+
+    @Inject
+    private ServerRuntime runtime;
+
+    @Inject
+    private DBHelper dbHelper;
 
     @Override
-    protected void setUp() throws Exception {
-        deleteTestData();
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("PAINTING_INFO");
+        dbHelper.deleteAll("PAINTING");
+        dbHelper.deleteAll("ARTIST_EXHIBIT");
+        dbHelper.deleteAll("ARTIST_GROUP");
+        dbHelper.deleteAll("ARTIST");
     }
 
     @Override
-    protected void tearDown() throws Exception {
-        EntityResolver resolver = getDomain().getEntityResolver();
+    protected void tearDownBeforeInjection() throws Exception {
+        EntityResolver resolver = runtime.getDataDomain().getEntityResolver();
         resolver.getCallbackRegistry().clear();
     }
 
     public void testPostAddCallbacks() {
-        LifecycleCallbackRegistry registry = getDomain()
+        LifecycleCallbackRegistry registry = runtime
+                .getDataDomain()
                 .getEntityResolver()
                 .getCallbackRegistry();
 
-        DataContext context = createDataContext();
-
         // no callbacks
         Artist a1 = context.newObject(Artist.class);
         assertNotNull(a1);
@@ -76,12 +93,11 @@ public class DataContextCallbacksTest ex
     }
 
     public void testPrePersistCallbacks() {
-        LifecycleCallbackRegistry registry = getDomain()
+        LifecycleCallbackRegistry registry = runtime
+                .getDataDomain()
                 .getEntityResolver()
                 .getCallbackRegistry();
 
-        DataContext context = createDataContext();
-
         // no callbacks
         Artist a1 = context.newObject(Artist.class);
         a1.setArtistName("1");
@@ -115,12 +131,11 @@ public class DataContextCallbacksTest ex
     }
 
     public void testPreRemoveCallbacks() {
-        LifecycleCallbackRegistry registry = getDomain()
+        LifecycleCallbackRegistry registry = runtime
+                .getDataDomain()
                 .getEntityResolver()
                 .getCallbackRegistry();
 
-        DataContext context = createDataContext();
-
         // no callbacks
         Artist a1 = context.newObject(Artist.class);
         a1.setArtistName("XX");



Mime
View raw message