cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1080003 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne: configuration/server/DefaultDbAdapterFactoryTest.java unit/CayenneResources.java
Date Wed, 09 Mar 2011 21:16:39 GMT
Author: aadamchik
Date: Wed Mar  9 21:16:39 2011
New Revision: 1080003

URL: http://svn.apache.org/viewvc?rev=1080003&view=rev
Log:
CAY-1549 Migrate BatchQueryBuilderFactory to DI

fixing unit tests

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/server/DefaultDbAdapterFactoryTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/CayenneResources.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/server/DefaultDbAdapterFactoryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/server/DefaultDbAdapterFactoryTest.java?rev=1080003&r1=1080002&r2=1080003&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/server/DefaultDbAdapterFactoryTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/server/DefaultDbAdapterFactoryTest.java
Wed Mar  9 21:16:39 2011
@@ -29,6 +29,7 @@ import java.util.List;
 
 import junit.framework.TestCase;
 
+import org.apache.cayenne.access.jdbc.BatchQueryBuilderFactory;
 import org.apache.cayenne.configuration.AdhocObjectFactory;
 import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.configuration.DefaultAdhocObjectFactory;
@@ -126,6 +127,8 @@ public class DefaultDbAdapterFactoryTest
             public void configure(Binder binder) {
                 binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class);
                 binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class);
+                binder.bind(BatchQueryBuilderFactory.class).toInstance(
+                        mock(BatchQueryBuilderFactory.class));
             }
         };
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/CayenneResources.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/CayenneResources.java?rev=1080003&r1=1080002&r2=1080003&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/CayenneResources.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/CayenneResources.java
Wed Mar  9 21:16:39 2011
@@ -26,9 +26,12 @@ import java.util.Map;
 import javax.sql.DataSource;
 
 import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.access.jdbc.BatchQueryBuilderFactory;
+import org.apache.cayenne.access.jdbc.DefaultBatchQueryBuilderFactory;
 import org.apache.cayenne.conn.DataSourceInfo;
 import org.apache.cayenne.conn.PoolDataSource;
 import org.apache.cayenne.conn.PoolManager;
+import org.apache.cayenne.dba.JdbcAdapter;
 import org.apache.cayenne.unit.util.SQLTemplateCustomizer;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -83,12 +86,10 @@ public class CayenneResources implements
     protected DataSourceInfo connectionInfo;
     protected DataSource dataSource;
     protected BeanFactory beanFactory;
-    protected Map adapterMap;
+    protected Map<String, AccessStackAdapter> adapterMap;
 
     /**
      * Returns shared test resource instance.
-     * 
-     * @return CayenneTestResources
      */
     public static CayenneResources getResources() {
         if (resources == null) {
@@ -108,8 +109,14 @@ public class CayenneResources implements
         return resources;
     }
 
-    public CayenneResources(Map adapterMap) {
+    public CayenneResources(Map<String, AccessStackAdapter> adapterMap) {
         this.adapterMap = adapterMap;
+
+        // kludge until we stop using Spring for unit tests and use Cayenne DI
+        BatchQueryBuilderFactory factory = new DefaultBatchQueryBuilderFactory();
+        for (AccessStackAdapter adapter : adapterMap.values()) {
+            ((JdbcAdapter) adapter.getAdapter()).setBatchQueryBuilderFactory(factory);
+        }
     }
 
     /**



Mime
View raw message