cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1101571 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne: ./ access/ access/dbsync/ unit/di/server/
Date Tue, 10 May 2011 18:01:46 GMT
Author: aadamchik
Date: Tue May 10 18:01:45 2011
New Revision: 1101571

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

patch by Dzmitry Kazimirchyk - SchemaUpdateStrategyTest + plus better model context setup
+ correct DataNode injection scope

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CDOQualifiedEntitiesTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/GenericMappingTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/EmbeddingTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCase.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CDOQualifiedEntitiesTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CDOQualifiedEntitiesTest.java?rev=1101571&r1=1101570&r2=1101571&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CDOQualifiedEntitiesTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CDOQualifiedEntitiesTest.java
Tue May 10 18:01:45 2011
@@ -30,7 +30,7 @@ import org.apache.cayenne.unit.AccessSta
 import org.apache.cayenne.unit.di.server.ServerCase;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
-@UseServerRuntime("cayenne-default.xml")
+@UseServerRuntime(ServerCase.DEFAULT_PROJECT)
 public class CDOQualifiedEntitiesTest extends ServerCase {
 
     @Inject

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/GenericMappingTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/GenericMappingTest.java?rev=1101571&r1=1101570&r2=1101571&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/GenericMappingTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/GenericMappingTest.java
Tue May 10 18:01:45 2011
@@ -31,14 +31,14 @@ import org.apache.cayenne.test.jdbc.DBHe
 import org.apache.cayenne.unit.di.server.ServerCase;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
-@UseServerRuntime("cayenne-default.xml")
+@UseServerRuntime(ServerCase.DEFAULT_PROJECT)
 public class GenericMappingTest extends ServerCase {
 
     @Inject
     private DataContext context;
 
     @Inject
-    protected DBHelper dbHelper;
+    private DBHelper dbHelper;
 
     @Override
     protected void setUpAfterInjection() throws Exception {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/EmbeddingTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/EmbeddingTest.java?rev=1101571&r1=1101570&r2=1101571&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/EmbeddingTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/EmbeddingTest.java
Tue May 10 18:01:45 2011
@@ -34,7 +34,7 @@ import org.apache.cayenne.testdo.embedda
 import org.apache.cayenne.unit.di.server.ServerCase;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
-@UseServerRuntime("cayenne-default.xml")
+@UseServerRuntime(ServerCase.DEFAULT_PROJECT)
 public class EmbeddingTest extends ServerCase {
     
     @Inject

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyTest.java?rev=1101571&r1=1101570&r2=1101571&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/dbsync/SchemaUpdateStrategyTest.java
Tue May 10 18:01:45 2011
@@ -32,43 +32,32 @@ import java.util.Map;
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.access.MockOperationObserver;
-import org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy;
-import org.apache.cayenne.access.dbsync.SchemaUpdateStrategy;
-import org.apache.cayenne.access.dbsync.ThrowOnPartialOrCreateSchemaStrategy;
-import org.apache.cayenne.access.dbsync.ThrowOnPartialSchemaStrategy;
-import org.apache.cayenne.dba.JdbcAdapter;
+import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.MapLoader;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.SQLTemplate;
-import org.apache.cayenne.unit.CayenneCase;
 import org.apache.cayenne.unit.CayenneResources;
-import org.xml.sax.InputSource;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
-public class SchemaUpdateStrategyTest extends CayenneCase {
+@UseServerRuntime(ServerCase.DEFAULT_PROJECT)
+public class SchemaUpdateStrategyTest extends ServerCase {
 
-    private DataMap dataMap;
+    @Inject
+    private DataNode node;
 
-    public DataMap getDataMap() {
-        if (dataMap == null) {
-            MapLoader mapLoader = new MapLoader();
-            dataMap = mapLoader.loadDataMap(getMapXml("sus-map.map.xml"));
-        }
-        return dataMap;
-    }
-
-    private InputSource getMapXml(String mapName) {
-        return new InputSource(getClass().getClassLoader().getResourceAsStream(mapName));
-    }
+    @Inject
+    private DbAdapter adapter;
 
     public void testDBGeneratorStrategy() throws Exception {
 
         String template = "SELECT #result('id' 'int') FROM SUS1";
         SQLTemplate query = new SQLTemplate(Object.class, template);
-        DataMap map = getDataMap();
-        assertNotNull(map);
+
+        DataMap map = node.getEntityResolver().getDataMap("sus-map");
         DataNode dataNode = createDataNode(map);
         int sizeDB = getNameTablesInDB(dataNode).size();
         MockOperationObserver observer = new MockOperationObserver();
@@ -94,8 +83,7 @@ public class SchemaUpdateStrategyTest ex
 
         String template = "SELECT #result('ARTIST_ID' 'int') FROM ARTIST ORDER BY ARTIST_ID";
         SQLTemplate query = new SQLTemplate(Object.class, template);
-        DataMap map = getDataMap();
-        assertNotNull(map);
+        DataMap map = node.getEntityResolver().getDataMap("sus-map");
         MockOperationObserver observer = new MockOperationObserver();
         DataNode dataNode = createDataNode(map);
 
@@ -130,8 +118,7 @@ public class SchemaUpdateStrategyTest ex
 
         String template = "SELECT #result('id' 'int') FROM SUS1";
         SQLTemplate query = new SQLTemplate(Object.class, template);
-        DataMap map = getDataMap();
-        assertNotNull(map);
+        DataMap map = node.getEntityResolver().getDataMap("sus-map");
         DataNode dataNode = createDataNode(map);
         int sizeDB = getNameTablesInDB(dataNode).size();
         MockOperationObserver observer = new MockOperationObserver();
@@ -172,8 +159,7 @@ public class SchemaUpdateStrategyTest ex
         String template = "SELECT #result('ARTIST_ID' 'int') FROM ARTIST ORDER BY ARTIST_ID";
         SQLTemplate query = new SQLTemplate(Object.class, template);
         MockOperationObserver observer = new MockOperationObserver();
-        DataMap map = getDataMap();
-        assertNotNull(map);
+        DataMap map = node.getEntityResolver().getDataMap("sus-map");
         DataNode dataNode = createDataNode(map);
 
         setStrategy(TestSchemaUpdateStrategy.class.getName(), dataNode);
@@ -186,8 +172,7 @@ public class SchemaUpdateStrategyTest ex
         DbEntity entity = null;
         String template = "SELECT #result('ARTIST_ID' 'int') FROM ARTIST ORDER BY ARTIST_ID";
         SQLTemplate query = new SQLTemplate(Object.class, template);
-        DataMap map = getDataMap();
-        assertNotNull(map);
+        DataMap map = node.getEntityResolver().getDataMap("sus-map");
         MockOperationObserver observer = new MockOperationObserver();
         DataNode dataNode = createDataNode(map);
 
@@ -234,8 +219,7 @@ public class SchemaUpdateStrategyTest ex
 
         String template = "SELECT #result('ARTIST_ID' 'int') FROM ARTIST ORDER BY ARTIST_ID";
         SQLTemplate query = new SQLTemplate(Object.class, template);
-        DataMap map = getDataMap();
-        assertNotNull(map);
+        DataMap map = node.getEntityResolver().getDataMap("sus-map");
         MockOperationObserver observer = new MockOperationObserver();
         DataNode dataNode = createDataNode(map);
         int sizeDB = getNameTablesInDB(dataNode).size();
@@ -254,7 +238,7 @@ public class SchemaUpdateStrategyTest ex
     }
 
     private DbEntity createOneTable(DataNode dataNode) {
-        DataMap map = getDataMap();
+        DataMap map = node.getEntityResolver().getDataMap("sus-map");
         Collection<DbEntity> ent = map.getDbEntities();
         DbEntity entity = ent.iterator().next();
         String template = dataNode.getAdapter().createTable(entity);
@@ -269,15 +253,14 @@ public class SchemaUpdateStrategyTest ex
     }
 
     private DataNode createDataNode(DataMap map) {
-        JdbcAdapter adapter = (JdbcAdapter) getAccessStackAdapter().getAdapter();
         Collection<DataMap> colection = new ArrayList<DataMap>();
         colection.add(map);
         DataNode dataNode = new DataNode();
         dataNode.setDataMaps(colection);
         dataNode.setAdapter(adapter);
         dataNode.setDataSource(CayenneResources.getResources().getDataSource());
-        dataNode.setDataSourceFactory(getNode().getDataSourceFactory());
-        dataNode.setSchemaUpdateStrategyName(getNode().getSchemaUpdateStrategyName());
+        dataNode.setDataSourceFactory(node.getDataSourceFactory());
+        dataNode.setSchemaUpdateStrategyName(node.getSchemaUpdateStrategyName());
         dataNode.setEntityResolver(new EntityResolver(colection));
         return dataNode;
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCase.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCase.java?rev=1101571&r1=1101570&r2=1101571&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCase.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCase.java
Tue May 10 18:01:45 2011
@@ -36,6 +36,7 @@ public class ServerCase extends DICase {
     public static final String PEOPLE_PROJECT = "cayenne-people.xml";
     public static final String RELATIONSHIPS_PROJECT = "cayenne-relationships.xml";
     public static final String TESTMAP_PROJECT = "cayenne-testmap.xml";
+    public static final String DEFAULT_PROJECT = "cayenne-default.xml";
 
     private static final Injector injector;
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java?rev=1101571&r1=1101570&r2=1101571&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/ServerCaseModule.java
Tue May 10 18:01:45 2011
@@ -68,7 +68,6 @@ public class ServerCaseModule implements
                 new CayenneResourcesDbAdapterProvider(resources));
         binder.bind(AccessStackAdapter.class).toProviderInstance(
                 new CayenneResourcesAccessStackAdapterProvider(resources));
-        binder.bind(DataNode.class).toProvider(ServerCaseDataNodeProvider.class);
         binder.bind(BatchQueryBuilderFactory.class).toProvider(
                 ServerCaseBatchQueryBuilderFactoryProvider.class);
         binder.bind(DataChannelInterceptor.class).to(
@@ -77,6 +76,8 @@ public class ServerCaseModule implements
                 new CayenneResourcesSQLTemplateCustomizerProvider(resources));
 
         // test-scoped objects
+        binder.bind(DataNode.class).toProvider(ServerCaseDataNodeProvider.class).in(
+                testScope);
         binder.bind(ServerCaseProperties.class).to(ServerCaseProperties.class).in(
                 testScope);
         binder.bind(ServerRuntime.class).toProviderInstance(



Mime
View raw message