cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1126300 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne: access/jdbc/ResultDirectiveTest.java dba/JdbcAdapterTest.java unit/UnitDbAdapter.java unit/di/server/SchemaHelper.java
Date Mon, 23 May 2011 02:30:15 GMT
Author: aadamchik
Date: Mon May 23 02:30:14 2011
New Revision: 1126300

URL: http://svn.apache.org/viewvc?rev=1126300&view=rev
Log:
unit test refactoring

refactoring

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/ResultDirectiveTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/JdbcAdapterTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/SchemaHelper.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/ResultDirectiveTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/ResultDirectiveTest.java?rev=1126300&r1=1126299&r2=1126300&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/ResultDirectiveTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/ResultDirectiveTest.java
Mon May 23 02:30:14 2011
@@ -27,13 +27,13 @@ import java.util.Map;
 import org.apache.cayenne.DataRow;
 import org.apache.cayenne.access.MockOperationObserver;
 import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.query.CapsStrategy;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.test.jdbc.DBHelper;
 import org.apache.cayenne.testdo.testmap.Artist;
-import org.apache.cayenne.unit.UnitDbAdapter;
 import org.apache.cayenne.unit.di.server.ServerCase;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
@@ -47,10 +47,10 @@ public class ResultDirectiveTest extends
     private ServerRuntime runtime;
 
     @Inject
-    private UnitDbAdapter accessStackAdapter;
+    private DBHelper dbHelper;
 
     @Inject
-    private DBHelper dbHelper;
+    private DbAdapter dbAdapter;
 
     @Override
     protected void setUpAfterInjection() throws Exception {
@@ -141,9 +141,10 @@ public class ResultDirectiveTest extends
 
         template.setParameters(parameters);
 
-        SQLTemplateAction action = new SQLTemplateAction(template, accessStackAdapter
-                .getAdapter(), runtime.getDataDomain().getEntityResolver());
-        assertSame(accessStackAdapter.getAdapter(), action.getAdapter());
+        SQLTemplateAction action = new SQLTemplateAction(template, dbAdapter, runtime
+                .getDataDomain()
+                .getEntityResolver());
+        assertSame(dbAdapter, action.getAdapter());
 
         Connection c = runtime
                 .getDataDomain()

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/JdbcAdapterTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/JdbcAdapterTest.java?rev=1126300&r1=1126299&r2=1126300&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/JdbcAdapterTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/JdbcAdapterTest.java
Mon May 23 02:30:14 2011
@@ -27,7 +27,6 @@ import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbKeyGenerator;
-import org.apache.cayenne.unit.UnitDbAdapter;
 import org.apache.cayenne.unit.di.server.ServerCase;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
@@ -35,7 +34,7 @@ import org.apache.cayenne.unit.di.server
 public class JdbcAdapterTest extends ServerCase {
 
     @Inject
-    private UnitDbAdapter accessStackAdapter;
+    private DbAdapter dbAdapter;
 
     public void testExternalTypesForJdbcType() throws Exception {
         // check a few types
@@ -56,7 +55,7 @@ public class JdbcAdapterTest extends Ser
 
     public void testCreateTableQuoteSqlIdentifiers() {
 
-        if (accessStackAdapter.getAdapter() instanceof MySQLAdapter) {
+        if (dbAdapter instanceof MySQLAdapter) {
 
             DbEntity entity = new DbEntity();
             DbAttribute attr = new DbAttribute();
@@ -72,7 +71,7 @@ public class JdbcAdapterTest extends Ser
             entity.setDataMap(dm);
             entity.setName("name table");
 
-            MySQLAdapter adaptMySQL = (MySQLAdapter) accessStackAdapter.getAdapter();
+            MySQLAdapter adaptMySQL = (MySQLAdapter) dbAdapter;
             String str = "CREATE TABLE `name table` (`name column` CHAR NULL) ENGINE=InnoDB";
             assertEquals(str, adaptMySQL.createTable(entity));
         }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java?rev=1126300&r1=1126299&r2=1126300&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java
Mon May 23 02:30:14 2011
@@ -61,10 +61,6 @@ public class UnitDbAdapter {
         this.adapter = adapter;
     }
 
-    public DbAdapter getAdapter() {
-        return adapter;
-    }
-
     /**
      * Drops all table constraints.
      */
@@ -98,7 +94,7 @@ public class UnitDbAdapter {
             }
             boolean status = entity.getDataMap() != null
                     && entity.getDataMap().isQuotingSQLIdentifiers();
-            QuotingStrategy strategy = getAdapter().getQuotingStrategy(status);
+            QuotingStrategy strategy = adapter.getQuotingStrategy(status);
 
             for (String constraint : constraints) {
                 StringBuilder drop = new StringBuilder();
@@ -244,7 +240,7 @@ public class UnitDbAdapter {
     /**
      * Returns a file under test resources DDL directory for the specified database.
      */
-    String ddlString(String database, String name) {
+    private String ddlString(String database, String name) {
         StringBuffer location = new StringBuffer();
         location.append("ddl/").append(database).append("/").append(name);
 
@@ -304,7 +300,7 @@ public class UnitDbAdapter {
             }
             boolean status = entity.getDataMap() != null
                     && entity.getDataMap().isQuotingSQLIdentifiers();
-            QuotingStrategy strategy = getAdapter().getQuotingStrategy(status);
+            QuotingStrategy strategy = adapter.getQuotingStrategy(status);
 
             // Get all constraints for the table
             ResultSet rs = metadata.getExportedKeys(entity.getCatalog(), entity

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/SchemaHelper.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/SchemaHelper.java?rev=1126300&r1=1126299&r2=1126300&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/SchemaHelper.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/SchemaHelper.java
Mon May 23 02:30:14 2011
@@ -82,12 +82,15 @@ public class SchemaHelper {
 
     private DataSource dataSource;
     private UnitDbAdapter unitDbAdapter;
+    private DbAdapter dbAdapter;
 
     private DataDomain domain;
 
-    public SchemaHelper(@Inject DataSource dataSource, @Inject UnitDbAdapter unitDbAdapter)
{
+    public SchemaHelper(@Inject DataSource dataSource,
+            @Inject UnitDbAdapter unitDbAdapter, @Inject DbAdapter dbAdapter) {
         this.dataSource = dataSource;
         this.unitDbAdapter = unitDbAdapter;
+        this.dbAdapter = dbAdapter;
     }
 
     /**
@@ -138,7 +141,7 @@ public class SchemaHelper {
     private void initNode(DataMap map) throws Exception {
 
         DataNode node = new DataNode(map.getName());
-        node.setAdapter(unitDbAdapter.getAdapter());
+        node.setAdapter(dbAdapter);
         node.setDataSource(dataSource);
 
         // setup test extended types



Mime
View raw message