cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1124487 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/EntityResolverTest.java
Date Thu, 19 May 2011 01:06:26 GMT
Author: aadamchik
Date: Thu May 19 01:06:25 2011
New Revision: 1124487

URL: http://svn.apache.org/viewvc?rev=1124487&view=rev
Log:
CAY-1565 CayenneCase unit tests conversion(5)

patches by Dzmitry Kazimirchyk - EntityResolverTest

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

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/EntityResolverTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/EntityResolverTest.java?rev=1124487&r1=1124486&r2=1124487&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/EntityResolverTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/EntityResolverTest.java
Thu May 19 01:06:25 2011
@@ -26,16 +26,29 @@ import java.util.List;
 
 import org.apache.cayenne.CayenneDataObject;
 import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.access.DataContext;
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.query.MockQuery;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.testdo.mt.ClientMtTable1;
 import org.apache.cayenne.testdo.mt.MtTable1;
 import org.apache.cayenne.testdo.testmap.Artist;
 import org.apache.cayenne.unit.AccessStack;
-import org.apache.cayenne.unit.CayenneCase;
 import org.apache.cayenne.unit.CayenneResources;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
-public class EntityResolverTest extends CayenneCase {
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class EntityResolverTest extends ServerCase {
+    
+    public static final String MULTI_TIER_ACCESS_STACK = "MultiTierStack";
+    
+    @Inject
+    private ServerRuntime runtime;
+    
+    @Inject
+    private DataContext context;
 
     public void testObjEntityLookupDuplicates() {
         AccessStack stack = CayenneResources
@@ -87,23 +100,23 @@ public class EntityResolverTest extends 
     }
 
     public void testGetObjEntity() {
-        EntityResolver resolver = new EntityResolver(getDomain().getDataMaps());
+        EntityResolver resolver = new EntityResolver(runtime.getDataDomain().getDataMaps());
         assertIsArtistObjEntity(resolver.getObjEntity("Artist"));
     }
 
     public void testLookupObjEntityByClass() {
-        EntityResolver resolver = new EntityResolver(getDomain().getDataMaps());
+        EntityResolver resolver = new EntityResolver(runtime.getDataDomain().getDataMaps());
         assertIsArtistObjEntity(resolver.lookupObjEntity(Artist.class));
     }
 
     public void testLookupObjEntityByInstance() {
-        EntityResolver resolver = new EntityResolver(getDomain().getDataMaps());
+        EntityResolver resolver = new EntityResolver(runtime.getDataDomain().getDataMaps());
         assertIsArtistObjEntity(resolver.lookupObjEntity(new Artist()));
     }
 
     public void testLookupObjEntityByDataobject() {
-        EntityResolver resolver = new EntityResolver(getDomain().getDataMaps());
-        Artist artist = (Artist) this.createDataContext().newObject("Artist");
+        EntityResolver resolver = new EntityResolver(runtime.getDataDomain().getDataMaps());
+        Artist artist = (Artist) context.newObject("Artist");
         assertIsArtistObjEntity(resolver.lookupObjEntity(artist));
     }
 
@@ -115,7 +128,7 @@ public class EntityResolverTest extends 
         list.add(m2);
 
         EntityResolver resolver = new EntityResolver(list);
-        Collection maps = resolver.getDataMaps();
+        Collection<?> maps = resolver.getDataMaps();
         assertNotNull(maps);
         assertEquals(2, maps.size());
         assertTrue(maps.containsAll(list));
@@ -204,5 +217,28 @@ public class EntityResolverTest extends 
         assertNotNull(ae);
         assertEquals(ae, getObjEntity("Artist"));
     }
+    
+    private DbEntity getDbEntity(String dbEntityName) {
+        for (DataMap map : runtime.getDataDomain().getDataMaps()) {
+            for (DbEntity e : map.getDbEntities()) {
+                if (dbEntityName.equals(e.getName())) {
+                    return e;
+                }
+            }
+        }
+
+        throw new CayenneRuntimeException("No DbEntity found: " + dbEntityName);
+    }
 
+    private ObjEntity getObjEntity(String objEntityName) {
+        for (DataMap map : runtime.getDataDomain().getDataMaps()) {
+            for (ObjEntity e : map.getObjEntities()) {
+                if (objEntityName.equals(e.getName())) {
+                    return e;
+                }
+            }
+        }
+
+        throw new CayenneRuntimeException("No ObjEntity found: " + objEntityName);
+    }
 }



Mime
View raw message