cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1099031 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/GenericMappingTest.java
Date Tue, 03 May 2011 12:02:59 GMT
Author: aadamchik
Date: Tue May  3 12:02:58 2011
New Revision: 1099031

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

patches by Dzmitry Kazimirchyk:
GenericMappingTest

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

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/GenericMappingTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/GenericMappingTest.java?rev=1099031&r1=1099030&r2=1099031&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/GenericMappingTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/GenericMappingTest.java
Tue May  3 12:02:58 2011
@@ -22,30 +22,31 @@ package org.apache.cayenne;
 import java.util.List;
 
 import org.apache.cayenne.access.DataContext;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.exp.ExpressionFactory;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.unit.AccessStack;
-import org.apache.cayenne.unit.CayenneCase;
-import org.apache.cayenne.unit.CayenneResources;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
-public class GenericMappingTest extends CayenneCase {
+@UseServerRuntime("cayenne-default.xml")
+public class GenericMappingTest extends ServerCase {
 
-    @Override
-    protected AccessStack buildAccessStack() {
-        return CayenneResources.getResources().getAccessStack("GenericStack");
-    }
+    @Inject
+    private DataContext context;
+
+    @Inject
+    protected DBHelper dbHelper;
 
     @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        deleteTestData();
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("GENERIC2");
+        dbHelper.deleteAll("GENERIC1");
     }
 
     public void testInsertSingle() {
-        DataContext context = createDataContext();
-
         DataObject g1 = (DataObject) context.newObject("Generic1");
         g1.writeProperty("name", "G1 Name");
 
@@ -53,8 +54,6 @@ public class GenericMappingTest extends 
     }
 
     public void testInsertRelated() {
-        DataContext context = createDataContext();
-
         DataObject g1 = (DataObject) context.newObject("Generic1");
         g1.writeProperty("name", "G1 Name");
 
@@ -66,8 +65,6 @@ public class GenericMappingTest extends 
     }
 
     public void testSelect() {
-        DataContext context = createDataContext();
-
         context.performNonSelectingQuery(new SQLTemplate(
                 "Generic1",
                 "INSERT INTO GENERIC1 (ID, NAME) VALUES (1, 'AAAA')"));
@@ -81,13 +78,11 @@ public class GenericMappingTest extends 
         Expression qual = ExpressionFactory.matchExp("name", "AAAA");
         SelectQuery q = new SelectQuery("Generic1", qual);
 
-        List result = context.performQuery(q);
+        List<?> result = context.performQuery(q);
         assertEquals(1, result.size());
     }
 
     public void testUpdateRelated() {
-        DataContext context = createDataContext();
-
         DataObject g1 = (DataObject) context.newObject("Generic1");
         g1.writeProperty("name", "G1 Name");
 
@@ -97,7 +92,7 @@ public class GenericMappingTest extends 
 
         context.commitChanges();
 
-        List r1 = (List) g1.readProperty("generic2s");
+        List<?> r1 = (List<?>) g1.readProperty("generic2s");
         assertTrue(r1.contains(g2));
 
         DataObject g11 = (DataObject) context.newObject("Generic1");
@@ -106,10 +101,10 @@ public class GenericMappingTest extends 
 
         context.commitChanges();
 
-        List r11 = (List) g11.readProperty("generic2s");
+        List<?> r11 = (List<?>) g11.readProperty("generic2s");
         assertTrue(r11.contains(g2));
 
-        List r1_1 = (List) g1.readProperty("generic2s");
+        List<?> r1_1 = (List<?>) g1.readProperty("generic2s");
         assertFalse(r1_1.contains(g2));
     }
 }



Mime
View raw message