cayenne-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?rev=1099179&view=rev
Log:
CAY-1563 CayenneCase unit tests conversion(3)

patches by Dzmitry Kazimirchyk:
EnumTest (+ new data set API)

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

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/EnumTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/EnumTest.java?rev=1099179&r1=1099178&r2=1099179&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/EnumTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/EnumTest.java
Tue May  3 18:35:56 2011
@@ -20,35 +20,49 @@ package org.apache.cayenne.access;
 
 import org.apache.cayenne.Cayenne;
 import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.exp.ExpressionFactory;
 import org.apache.cayenne.query.CapsStrategy;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
 import org.apache.cayenne.testdo.testmap.Enum1;
 import org.apache.cayenne.testdo.testmap.EnumEntity;
-import org.apache.cayenne.unit.CayenneCase;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
-public class EnumTest extends CayenneCase {
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class EnumTest extends ServerCase {
 
-    public void testInsert() {
-        ObjectContext context = createDataContext();
+    @Inject
+    private ObjectContext context;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("ENUM_ENTITY");
+
+    }
+
+    private void createDataSet() throws Exception {
+        TableHelper tEnumEntity = new TableHelper(dbHelper, "ENUM_ENTITY");
+        tEnumEntity.setColumns("ID", "ENUM_ATTRIBUTE");
+
+        tEnumEntity.insert(1, "two");
+        tEnumEntity.insert(2, "one");
+    }
 
+    public void testInsert() {
         EnumEntity e = context.newObject(EnumEntity.class);
         e.setEnumAttribute(Enum1.one);
-
         context.commitChanges();
     }
 
     public void testSelectQuery() throws Exception {
-        deleteTestData();
-        ObjectContext context = createDataContext();
-
-        context.performGenericQuery(new SQLTemplate(
-                EnumEntity.class,
-                "insert into ENUM_ENTITY (ID, ENUM_ATTRIBUTE) VALUES (1, 'two')"));
-        context.performGenericQuery(new SQLTemplate(
-                EnumEntity.class,
-                "insert into ENUM_ENTITY (ID, ENUM_ATTRIBUTE) VALUES (2, 'one')"));
+        createDataSet();
 
         SelectQuery q = new SelectQuery(EnumEntity.class);
         q.andQualifier(ExpressionFactory.matchExp(
@@ -61,15 +75,7 @@ public class EnumTest extends CayenneCas
     }
 
     public void testSQLTemplate() throws Exception {
-        deleteTestData();
-        ObjectContext context = createDataContext();
-
-        context.performGenericQuery(new SQLTemplate(
-                EnumEntity.class,
-                "insert into ENUM_ENTITY (ID, ENUM_ATTRIBUTE) VALUES (1, 'two')"));
-        context.performGenericQuery(new SQLTemplate(
-                EnumEntity.class,
-                "insert into ENUM_ENTITY (ID, ENUM_ATTRIBUTE) VALUES (2, 'one')"));
+        createDataSet();
 
         SQLTemplate q = new SQLTemplate(
                 EnumEntity.class,



Mime
View raw message