cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1098613 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test: java/org/apache/cayenne/reflect/MixedPersistenceStrategyTest.java resources/dml/reflect.MixedPersistenceStrategyTest.xml
Date Mon, 02 May 2011 14:56:52 GMT
Author: aadamchik
Date: Mon May  2 14:56:52 2011
New Revision: 1098613

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

patches by Dzmitry Kazimirchyk:
MixedPersistenceStrategyTest

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

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/reflect/MixedPersistenceStrategyTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/reflect/MixedPersistenceStrategyTest.java?rev=1098613&r1=1098612&r2=1098613&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/reflect/MixedPersistenceStrategyTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/reflect/MixedPersistenceStrategyTest.java
Mon May  2 14:56:52 2011
@@ -20,25 +20,56 @@
 package org.apache.cayenne.reflect;
 
 import org.apache.cayenne.Cayenne;
+import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.ValueHolder;
-import org.apache.cayenne.access.DataContext;
+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.MixedPersistenceStrategy;
 import org.apache.cayenne.testdo.testmap.MixedPersistenceStrategy2;
-import org.apache.cayenne.unit.CayenneCase;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
 /**
  * Tests conflicts between field and map-based persistence.
  * 
  */
-public class MixedPersistenceStrategyTest extends CayenneCase {
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class MixedPersistenceStrategyTest extends ServerCase {
 
+    @Inject
+    protected ObjectContext context;
+    
+    @Inject
+    protected DBHelper dbHelper;
+    
+    protected TableHelper tMixedPersistenceStrategy;
+    protected TableHelper tMixedPersistenceStrategy2;
+    
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("MIXED_PERSISTENCE_STRATEGY");
+        dbHelper.deleteAll("MIXED_PERSISTENCE_STRATEGY2");
+        
+        tMixedPersistenceStrategy = new TableHelper(dbHelper, "MIXED_PERSISTENCE_STRATEGY");
+        tMixedPersistenceStrategy.setColumns("ID", "DESCRIPTION", "NAME");
+        
+        tMixedPersistenceStrategy2 = new TableHelper(dbHelper, "MIXED_PERSISTENCE_STRATEGY2");
+        tMixedPersistenceStrategy2.setColumns("ID", "MASTER_ID", "NAME");
+    }
+    
+    protected void createConflictingFieldDataSet() throws Exception {
+        tMixedPersistenceStrategy.insert(1, "d1", "n1");
+        tMixedPersistenceStrategy2.insert(1, 1, "dn1");
+        tMixedPersistenceStrategy2.insert(2, 1, "dn2");
+    }
+    
     public void testConflictingField1() throws Exception {
-        deleteTestData();
-        createTestData("testConflictingField");
 
-        DataContext c = createDataContext();
+        createConflictingFieldDataSet();
+
         MixedPersistenceStrategy object = Cayenne.objectForPK(
-                c,
+                context,
                 MixedPersistenceStrategy.class,
                 1);
 
@@ -50,17 +81,16 @@ public class MixedPersistenceStrategyTes
      * This test case reproduces CAY-582 bug.
      */
     public void testConflictingField2() throws Exception {
-        deleteTestData();
-        createTestData("testConflictingField");
 
-        DataContext c = createDataContext();
+        createConflictingFieldDataSet();
+
         MixedPersistenceStrategy2 detail1 = Cayenne.objectForPK(
-                c,
+                context,
                 MixedPersistenceStrategy2.class,
                 1);
 
         MixedPersistenceStrategy2 detail2 = Cayenne.objectForPK(
-                c,
+                context,
                 MixedPersistenceStrategy2.class,
                 2);
 



Mime
View raw message