You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2011/05/02 19:31:44 UTC

svn commit: r1098674 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test: java/org/apache/cayenne/access/ObjectStoreDiffRetainingTest.java resources/dml/access.ObjectStoreDiffRetainingTest.xml

Author: aadamchik
Date: Mon May  2 17:31:44 2011
New Revision: 1098674

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

patches by Dzmitry Kazimirchyk:
ObjectStoreDiffRetainingTest

Removed:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/dml/access.ObjectStoreDiffRetainingTest.xml
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ObjectStoreDiffRetainingTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ObjectStoreDiffRetainingTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ObjectStoreDiffRetainingTest.java?rev=1098674&r1=1098673&r2=1098674&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ObjectStoreDiffRetainingTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ObjectStoreDiffRetainingTest.java Mon May  2 17:31:44 2011
@@ -20,24 +20,54 @@
 package org.apache.cayenne.access;
 
 import org.apache.cayenne.Cayenne;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
 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 ObjectStoreDiffRetainingTest extends CayenneCase {
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class ObjectStoreDiffRetainingTest extends ServerCase {
+
+    @Inject
+    protected DataContext context;
+
+    @Inject
+    protected DBHelper dbHelper;
+
+    protected TableHelper tArtist;
+    protected TableHelper tPainting;
 
     @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        deleteTestData();
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("PAINTING_INFO");
+        dbHelper.deleteAll("PAINTING");
+        dbHelper.deleteAll("ARTIST_EXHIBIT");
+        dbHelper.deleteAll("ARTIST_GROUP");
+        dbHelper.deleteAll("ARTIST");
+
+        tArtist = new TableHelper(dbHelper, "ARTIST");
+        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME", "DATE_OF_BIRTH");
+
+        tPainting = new TableHelper(dbHelper, "PAINTING");
+        tPainting.setColumns(
+                "ARTIST_ID",
+                "ESTIMATED_PRICE",
+                "GALLERY_ID",
+                "PAINTING_ID",
+                "PAINTING_TITLE");
+    }
+
+    protected void createMixedDataSet() throws Exception {
+        tArtist.insert(2000, "artist with one painting", null);
+        tPainting.insert(2000, null, null, 3000, "p1");
     }
 
     public void testSnapshotRetainedOnPropertyModification() throws Exception {
-        createTestData("test");
+        createMixedDataSet();
 
-        DataContext context = createDataContext();
         Artist a = Cayenne.objectForPK(context, Artist.class, 2000);
         ObjectStore objectStore = context.getObjectStore();
 
@@ -48,9 +78,8 @@ public class ObjectStoreDiffRetainingTes
     }
 
     public void testSnapshotRetainedOnRelAndPropertyModification() throws Exception {
-        createTestData("test");
+        createMixedDataSet();
 
-        DataContext context = createDataContext();
         Artist a = Cayenne.objectForPK(context, Artist.class, 2000);
         ObjectStore objectStore = context.getObjectStore();