cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1103408 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SQLTemplateTest.java
Date Sun, 15 May 2011 14:47:58 GMT
Author: aadamchik
Date: Sun May 15 14:47:58 2011
New Revision: 1103408

URL: http://svn.apache.org/viewvc?rev=1103408&view=rev
Log:
CAY-1564 CayenneCase unit tests conversion(4)

patch by Dzmitry Kazimirchyk - SQLTemplateTest

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

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SQLTemplateTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SQLTemplateTest.java?rev=1103408&r1=1103407&r2=1103408&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SQLTemplateTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SQLTemplateTest.java
Sun May 15 14:47:58 2011
@@ -28,24 +28,31 @@ import java.util.Map;
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.DataRow;
 import org.apache.cayenne.access.DataContext;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.remote.hessian.service.HessianUtil;
-import org.apache.cayenne.unit.CayenneCase;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 import org.apache.cayenne.util.Util;
 
-/**
- */
-public class SQLTemplateTest extends CayenneCase {
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class SQLTemplateTest extends ServerCase {
 
-    protected DataContext context;
+    @Inject
+    private DataContext context;
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+    @Inject
+    private DBHelper dbHelper;
 
-        deleteTestData();
-        context = createDataContext();
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("PAINTING_INFO");
+        dbHelper.deleteAll("PAINTING");
+        dbHelper.deleteAll("ARTIST_EXHIBIT");
+        dbHelper.deleteAll("ARTIST_GROUP");
+        dbHelper.deleteAll("ARTIST");
     }
 
     public void testBindCHARInWHERE() {
@@ -68,7 +75,7 @@ public class SQLTemplateTest extends Cay
                 testDataMap,
                 "SELECT * FROM ARTIST WHERE ARTIST_NAME = #bind($ARTIST_NAME)",
                 true);
-        //whitespace after name is for reason
+        // whitespace after name is for reason
         s1.setParameters(Collections.singletonMap("ARTIST_NAME", "Surikov "));
         List<DataRow> result = context.performQuery(s1);
         assertEquals(1, result.size());
@@ -167,7 +174,7 @@ public class SQLTemplateTest extends Cay
         assertEquals(o.getDefaultTemplate(), c1.getDefaultTemplate());
 
         // set immutable parameters ... query must recast them to mutable version
-        Map[] parameters = new Map[] {
+        Map<String, Object>[] parameters = new Map[] {
             Collections.EMPTY_MAP
         };
         o.setParameters(parameters);
@@ -207,12 +214,12 @@ public class SQLTemplateTest extends Cay
         assertNotNull(query.getParameters());
         assertTrue(query.getParameters().isEmpty());
 
-        Map params = new HashMap();
+        Map<String, Object> params = new HashMap<String, Object>();
         params.put("a", "b");
 
         query.setParameters(params);
         assertEquals(params, query.getParameters());
-        Iterator it = query.parametersIterator();
+        Iterator<?> it = query.parametersIterator();
         assertTrue(it.hasNext());
         assertEquals(params, it.next());
         assertFalse(it.hasNext());
@@ -230,23 +237,23 @@ public class SQLTemplateTest extends Cay
         assertNotNull(query.getParameters());
         assertTrue(query.getParameters().isEmpty());
 
-        Map params1 = new HashMap();
+        Map<String, Object> params1 = new HashMap<String, Object>();
         params1.put("a", "b");
 
-        Map params2 = new HashMap();
+        Map<String, Object> params2 = new HashMap<String, Object>();
         params2.put("1", "2");
 
         query.setParameters(new Map[] {
                 params1, params2, null
         });
         assertEquals(params1, query.getParameters());
-        Iterator it = query.parametersIterator();
+        Iterator<?> it = query.parametersIterator();
         assertTrue(it.hasNext());
         assertEquals(params1, it.next());
         assertTrue(it.hasNext());
         assertEquals(params2, it.next());
         assertTrue(it.hasNext());
-        assertTrue(((Map) it.next()).isEmpty());
+        assertTrue(((Map<String, Object>) it.next()).isEmpty());
         assertFalse(it.hasNext());
 
         query.setParameters((Map[]) null);



Mime
View raw message