cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r583240 - in /cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit: AccessStackAdapter.java CayenneResources.java
Date Tue, 09 Oct 2007 17:47:26 GMT
Author: aadamchik
Date: Tue Oct  9 10:47:26 2007
New Revision: 583240

URL: http://svn.apache.org/viewvc?rev=583240&view=rev
Log:
support for non-pooling DS for unit tests

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/AccessStackAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/CayenneResources.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/AccessStackAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/AccessStackAdapter.java?rev=583240&r1=583239&r2=583240&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/AccessStackAdapter.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/AccessStackAdapter.java
Tue Oct  9 10:47:26 2007
@@ -62,6 +62,10 @@
         }
         this.adapter = adapter;
     }
+    
+    public boolean usePooledDataSource() {
+        return true;
+    }
 
     public DbAdapter getAdapter() {
         return adapter;

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/CayenneResources.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/CayenneResources.java?rev=583240&r1=583239&r2=583240&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/CayenneResources.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/CayenneResources.java
Tue Oct  9 10:47:26 2007
@@ -31,6 +31,7 @@
 import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.conf.ConnectionProperties;
 import org.apache.cayenne.conn.DataSourceInfo;
+import org.apache.cayenne.conn.DriverDataSource;
 import org.apache.cayenne.conn.PoolDataSource;
 import org.apache.cayenne.conn.PoolManager;
 import org.apache.cayenne.unit.util.SQLTemplateCustomizer;
@@ -87,8 +88,6 @@
 
         resources.setConnectionKey(System.getProperty(CONNECTION_NAME_KEY));
 
-        
-
         return resources;
     }
 
@@ -297,17 +296,29 @@
     }
 
     public DataSource createDataSource() {
+
         try {
-            // data source
-            PoolDataSource poolDS = new PoolDataSource(
-                    connectionInfo.getJdbcDriver(),
-                    connectionInfo.getDataSourceUrl());
-            return new PoolManager(
-                    poolDS,
-                    1,
-                    1,
-                    connectionInfo.getUserName(),
-                    connectionInfo.getPassword());
+            AccessStackAdapter adapter = getAccessStackAdapter(Class
+                    .forName(connectionInfo.getAdapterClassName()));
+
+            if (adapter.usePooledDataSource()) {
+                PoolDataSource poolDS = new PoolDataSource(
+                        connectionInfo.getJdbcDriver(),
+                        connectionInfo.getDataSourceUrl());
+                return new PoolManager(
+                        poolDS,
+                        1,
+                        1,
+                        connectionInfo.getUserName(),
+                        connectionInfo.getPassword());
+            }
+            else {
+                return new DriverDataSource(
+                        connectionInfo.getJdbcDriver(),
+                        connectionInfo.getDataSourceUrl(),
+                        connectionInfo.getUserName(),
+                        connectionInfo.getPassword());
+            }
         }
         catch (Exception ex) {
             logObj.error("Can not create shared data source.", ex);



Mime
View raw message