cayenne-commits mailing list archives

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

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

patches by Dzmitry Kazimirchyk:
DataContextCompoundRelTest

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

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCompoundRelTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCompoundRelTest.java?rev=1098979&r1=1098978&r2=1098979&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCompoundRelTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCompoundRelTest.java
Tue May  3 09:18:41 2011
@@ -19,49 +19,55 @@
 
 package org.apache.cayenne.access;
 
+import java.util.Arrays;
 import java.util.List;
 
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.exp.ExpressionFactory;
 import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
 import org.apache.cayenne.testdo.testmap.CompoundFkTestEntity;
 import org.apache.cayenne.testdo.testmap.CompoundPkTestEntity;
-import org.apache.cayenne.unit.CayenneCase;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
 /**
  * Testing relationships with compound keys.
- * 
  */
-public class DataContextCompoundRelTest extends CayenneCase {
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataContextCompoundRelTest extends ServerCase {
 
-    protected DataContext ctxt;
+    @Inject
+    private DataContext context;
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+    @Inject
+    private DataContext context1;
+
+    @Inject
+    private DBHelper dbHelper;
 
-        deleteTestData();
-        ctxt = createDataContext();
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("COMPOUND_FK_TEST");
+        dbHelper.deleteAll("COMPOUND_PK_TEST");
     }
 
     public void testInsert() {
-        CompoundPkTestEntity master = ctxt
-                .newObject(CompoundPkTestEntity.class);
-        CompoundFkTestEntity detail = ctxt
-                .newObject(CompoundFkTestEntity.class);
+
+        CompoundPkTestEntity master = context.newObject(CompoundPkTestEntity.class);
+        CompoundFkTestEntity detail = context.newObject(CompoundFkTestEntity.class);
         master.addToCompoundFkArray(detail);
         master.setName("m1");
         master.setKey1("key11");
         master.setKey2("key21");
         detail.setName("d1");
 
-        ctxt.commitChanges();
-
-        // reset context
-        ctxt = createDataContext();
+        context.commitChanges();
+        context.invalidateObjects(Arrays.asList(master, detail));
 
         SelectQuery q = new SelectQuery(CompoundPkTestEntity.class);
-        List<?> objs = ctxt.performQuery(q);
+        List<?> objs = context1.performQuery(q);
         assertEquals(1, objs.size());
 
         master = (CompoundPkTestEntity) objs.get(0);
@@ -75,13 +81,13 @@ public class DataContextCompoundRelTest 
     }
 
     public void testFetchQualifyingToOne() {
-        CompoundPkTestEntity master = (CompoundPkTestEntity) ctxt
+        CompoundPkTestEntity master = (CompoundPkTestEntity) context
                 .newObject("CompoundPkTestEntity");
-        CompoundPkTestEntity master1 = (CompoundPkTestEntity) ctxt
+        CompoundPkTestEntity master1 = (CompoundPkTestEntity) context
                 .newObject("CompoundPkTestEntity");
-        CompoundFkTestEntity detail = (CompoundFkTestEntity) ctxt
+        CompoundFkTestEntity detail = (CompoundFkTestEntity) context
                 .newObject("CompoundFkTestEntity");
-        CompoundFkTestEntity detail1 = (CompoundFkTestEntity) ctxt
+        CompoundFkTestEntity detail1 = (CompoundFkTestEntity) context
                 .newObject("CompoundFkTestEntity");
         master.addToCompoundFkArray(detail);
         master1.addToCompoundFkArray(detail1);
@@ -98,14 +104,12 @@ public class DataContextCompoundRelTest 
 
         detail1.setName("d2");
 
-        ctxt.commitChanges();
-
-        // reset context
-        ctxt = createDataContext();
+        context.commitChanges();
+        context.invalidateObjects(Arrays.asList(master, master1, detail, detail1));
 
         Expression qual = ExpressionFactory.matchExp("toCompoundPk", master);
         SelectQuery q = new SelectQuery(CompoundFkTestEntity.class, qual);
-        List<?> objs = ctxt.performQuery(q);
+        List<?> objs = context1.performQuery(q);
         assertEquals(1, objs.size());
 
         detail = (CompoundFkTestEntity) objs.get(0);
@@ -113,13 +117,13 @@ public class DataContextCompoundRelTest 
     }
 
     public void testFetchQualifyingToMany() throws Exception {
-        CompoundPkTestEntity master = (CompoundPkTestEntity) ctxt
+        CompoundPkTestEntity master = (CompoundPkTestEntity) context
                 .newObject("CompoundPkTestEntity");
-        CompoundPkTestEntity master1 = (CompoundPkTestEntity) ctxt
+        CompoundPkTestEntity master1 = (CompoundPkTestEntity) context
                 .newObject("CompoundPkTestEntity");
-        CompoundFkTestEntity detail = (CompoundFkTestEntity) ctxt
+        CompoundFkTestEntity detail = (CompoundFkTestEntity) context
                 .newObject("CompoundFkTestEntity");
-        CompoundFkTestEntity detail1 = (CompoundFkTestEntity) ctxt
+        CompoundFkTestEntity detail1 = (CompoundFkTestEntity) context
                 .newObject("CompoundFkTestEntity");
         master.addToCompoundFkArray(detail);
         master1.addToCompoundFkArray(detail1);
@@ -136,14 +140,12 @@ public class DataContextCompoundRelTest 
 
         detail1.setName("d2");
 
-        ctxt.commitChanges();
-
-        // reset context
-        ctxt = createDataContext();
+        context.commitChanges();
+        context.invalidateObjects(Arrays.asList(master, master1, detail, detail1));
 
         Expression qual = ExpressionFactory.matchExp("compoundFkArray", detail1);
         SelectQuery q = new SelectQuery(CompoundPkTestEntity.class, qual);
-        List<?> objs = ctxt.performQuery(q);
+        List<?> objs = context1.performQuery(q);
         assertEquals(1, objs.size());
 
         master = (CompoundPkTestEntity) objs.get(0);



Mime
View raw message