cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1098751 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCharPKTest.java
Date Mon, 02 May 2011 19:16:34 GMT
Author: aadamchik
Date: Mon May  2 19:16:33 2011
New Revision: 1098751

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

patches by Dzmitry Kazimirchyk:
DataContextCharPKTest

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

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCharPKTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCharPKTest.java?rev=1098751&r1=1098750&r2=1098751&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCharPKTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextCharPKTest.java
Mon May  2 19:16:33 2011
@@ -20,29 +20,35 @@
 package org.apache.cayenne.access;
 
 import java.util.List;
-import java.util.Map;
 
+import org.apache.cayenne.DataRow;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.query.SQLTemplate;
+import org.apache.cayenne.test.jdbc.DBHelper;
 import org.apache.cayenne.testdo.testmap.CharPkTestEntity;
-import org.apache.cayenne.unit.CayenneCase;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
-public class DataContextCharPKTest extends CayenneCase {
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataContextCharPKTest extends ServerCase {
 
-    protected DataContext ctxt;
+    @Inject
+    private DataContext context;
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+    @Inject
+    private DBHelper dbHelper;
 
-        deleteTestData();
-        ctxt = createDataContext();
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("CHAR_FK_TEST");
+        dbHelper.deleteAll("CHAR_PK_TEST");
     }
 
     public void testInsert() throws Exception {
-        CharPkTestEntity object = (CharPkTestEntity) ctxt.newObject("CharPkTestEntity");
+        CharPkTestEntity object = context.newObject(CharPkTestEntity.class);
         object.setOtherCol("object-XYZ");
         object.setPkCol("PK1");
-        ctxt.commitChanges();
+        context.commitChanges();
 
         SQLTemplate q = new SQLTemplate(
                 CharPkTestEntity.class,
@@ -50,10 +56,10 @@ public class DataContextCharPKTest exten
 
         q.setFetchingDataRows(true);
 
-        List<?> rows = ctxt.performQuery(q);
+        List<?> rows = context.performQuery(q);
         assertNotNull(rows);
         assertEquals(1, rows.size());
-        Map row = (Map) rows.get(0);
+        DataRow row = (DataRow) rows.get(0);
 
         Object val = row.get("OTHER_COL");
         if (val == null) {
@@ -69,42 +75,42 @@ public class DataContextCharPKTest exten
     }
 
     public void testDelete() throws Exception {
-        CharPkTestEntity object = (CharPkTestEntity) ctxt.newObject("CharPkTestEntity");
+        CharPkTestEntity object = context.newObject(CharPkTestEntity.class);
         object.setOtherCol("object-XYZ");
         object.setPkCol("PK1");
-        ctxt.commitChanges();
+        context.commitChanges();
 
-        ctxt.deleteObject(object);
-        ctxt.commitChanges();
+        context.deleteObject(object);
+        context.commitChanges();
 
         SQLTemplate q = new SQLTemplate(
                 CharPkTestEntity.class,
                 "SELECT * FROM CHAR_PK_TEST");
         q.setFetchingDataRows(true);
 
-        List<?> rows = ctxt.performQuery(q);
+        List<?> rows = context.performQuery(q);
         assertNotNull(rows);
         assertEquals(0, rows.size());
     }
 
     public void testUpdate() throws Exception {
-        CharPkTestEntity object = (CharPkTestEntity) ctxt.newObject("CharPkTestEntity");
+        CharPkTestEntity object = context.newObject(CharPkTestEntity.class);
         object.setOtherCol("object-XYZ");
         object.setPkCol("PK1");
-        ctxt.commitChanges();
+        context.commitChanges();
 
         object.setOtherCol("UPDATED");
-        ctxt.commitChanges();
+        context.commitChanges();
 
         SQLTemplate q = new SQLTemplate(
                 CharPkTestEntity.class,
                 "SELECT * FROM CHAR_PK_TEST");
         q.setFetchingDataRows(true);
 
-        List<?> rows = ctxt.performQuery(q);
+        List<?> rows = context.performQuery(q);
         assertNotNull(rows);
         assertEquals(1, rows.size());
-        Map row = (Map) rows.get(0);
+        DataRow row = (DataRow) rows.get(0);
         Object val = row.get("OTHER_COL");
         if (val == null) {
             val = row.get("other_col");



Mime
View raw message