cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1099027 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataDomainQueryActionTest.java
Date Tue, 03 May 2011 11:53:37 GMT
Author: aadamchik
Date: Tue May  3 11:53:37 2011
New Revision: 1099027

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

patches by Dzmitry Kazimirchyk:
DataDomainQueryActionTest

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

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataDomainQueryActionTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataDomainQueryActionTest.java?rev=1099027&r1=1099026&r2=1099027&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataDomainQueryActionTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataDomainQueryActionTest.java
Tue May  3 11:53:37 2011
@@ -21,69 +21,89 @@ package org.apache.cayenne.access;
 import java.io.Serializable;
 import java.util.List;
 
-import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.cache.MockQueryCache;
 import org.apache.cayenne.cache.QueryCache;
 import org.apache.cayenne.cache.QueryCacheEntryFactory;
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.query.QueryCacheStrategy;
 import org.apache.cayenne.query.QueryMetadata;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.query.SortOrder;
+import org.apache.cayenne.test.jdbc.DBHelper;
 import org.apache.cayenne.testdo.testmap.Painting;
-import org.apache.cayenne.unit.CayenneCase;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataDomainQueryActionTest extends ServerCase {
 
-public class DataDomainQueryActionTest extends CayenneCase {
+    @Inject
+    private DataContext context;
+
+    @Inject
+    private ServerRuntime runtime;
+
+    @Inject
+    private DBHelper dbHelper;
 
     @Override
-    public void setUp() throws Exception {
-        deleteTestData();
+    public void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("PAINTING_INFO");
+        dbHelper.deleteAll("PAINTING");
+        dbHelper.deleteAll("PAINTING1");
+        dbHelper.deleteAll("ARTIST_EXHIBIT");
+        dbHelper.deleteAll("ARTIST_GROUP");
+        dbHelper.deleteAll("ARTIST");
     }
-    
+
     @Override
-    public void tearDown() {
-        getDomain().resetProperties();
+    public void tearDownBeforeInjection() {
+        runtime.getDataDomain().resetProperties();
     }
-   
+
     public void testCachedQuery() {
-        
-        DataDomain domain = getDomain();
-        
-        ObjectContext context = createDataContext();
-        
+
+        DataDomain domain = runtime.getDataDomain();
+
         Painting p = context.newObject(Painting.class);
         p.setPaintingTitle("sample");
-        
+
         SelectQuery query = new SelectQuery(Painting.class);
-        
+
         query.addPrefetch(Painting.TO_GALLERY_PROPERTY);
         query.addPrefetch(Painting.TO_ARTIST_PROPERTY);
         query.addOrdering(Painting.PAINTING_TITLE_PROPERTY, SortOrder.ASCENDING);
         query.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
         query.setPageSize(5);
-        
+
         QueryCache cache = domain.queryCache;
-        
+
         domain.queryCache = new MockQueryCache() {
-           
+
             @Override
-            public List get(QueryMetadata metadata, QueryCacheEntryFactory factory) {
+            public List<?> get(QueryMetadata metadata, QueryCacheEntryFactory factory)
{
                 Object results = factory.createObject();
-                assertTrue("Query cache is not serializable.", results instanceof Serializable);
-                
+                assertTrue(
+                        "Query cache is not serializable.",
+                        results instanceof Serializable);
+
                 return null;
             }
-            
+
+            @SuppressWarnings("all")
             @Override
             public void put(QueryMetadata metadata, List results) {
-                assertTrue("Query cache is not serializable.", results instanceof Serializable);
+                assertTrue(
+                        "Query cache is not serializable.",
+                        results instanceof Serializable);
             }
         };
-        
+
         DataDomainQueryAction action = new DataDomainQueryAction(context, domain, query);
         action.execute();
-        
+
         domain.queryCache = cache;
     }
-    
+
 }



Mime
View raw message