cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1098978 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCommitTest.java
Date Tue, 03 May 2011 09:18:14 GMT
Author: aadamchik
Date: Tue May  3 09:18:14 2011
New Revision: 1098978

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

patches by Dzmitry Kazimirchyk:
DataContextCommitTest

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

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCommitTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCommitTest.java?rev=1098978&r1=1098977&r2=1098978&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCommitTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCommitTest.java
Tue May  3 09:18:14 2011
@@ -19,19 +19,37 @@
 
 package org.apache.cayenne.access;
 
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.graph.GraphDiff;
 import org.apache.cayenne.graph.MockGraphChangeHandler;
+import org.apache.cayenne.test.jdbc.DBHelper;
 import org.apache.cayenne.testdo.testmap.Artist;
 import org.apache.cayenne.testdo.testmap.NullTestEntity;
 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 DataContextCommitTest extends CayenneCase {
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataContextCommitTest extends ServerCase {
+
+    @Inject
+    private DataContext context;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("PAINTING_INFO");
+        dbHelper.deleteAll("PAINTING");
+        dbHelper.deleteAll("ARTIST_EXHIBIT");
+        dbHelper.deleteAll("ARTIST_GROUP");
+        dbHelper.deleteAll("ARTIST");
+        dbHelper.deleteAll("NULL_TEST");
+    }
 
     public void testFlushToParent_Commit() {
 
-        DataContext context = createDataContext();
-        
         // commit new object
         Artist a = context.newObject(Artist.class);
         a.setArtistName("Test");
@@ -57,13 +75,13 @@ public class DataContextCommitTest exten
         diff.apply(diffChecker);
         assertEquals(1, diffChecker.getCallbackCount());
         assertSame(a.getObjectId(), newIds[0]);
-        
+
         // commit a mix of new and modified
         Painting p = context.newObject(Painting.class);
         p.setPaintingTitle("PT");
         p.setToArtist(a);
         a.setArtistName(a.getArtistName() + "_");
-        
+
         GraphDiff diff2 = context.flushToParent(true);
         assertNotNull(diff2);
         assertFalse(context.hasChanges());
@@ -83,18 +101,16 @@ public class DataContextCommitTest exten
         diff2.apply(diffChecker2);
         assertEquals(1, diffChecker2.getCallbackCount());
         assertSame(p.getObjectId(), newIds2[0]);
-        
-        //commit new object with uninitialized attributes
-        
-        context = createDataContext();
-        
+
+        // commit new object with uninitialized attributes
+
         context.newObject(NullTestEntity.class);
-        
+
         assertTrue(context.hasChanges());
-        
+
         GraphDiff diff3 = context.flushToParent(true);
         assertNotNull(diff3);
         assertFalse(context.hasChanges());
-        
+
     }
 }



Mime
View raw message