cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1073911 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne: configuration/server/DataDomainProviderTest.java configuration/server/DefaultDbAdapterFactoryTest.java dba/MockDbAdapter.java
Date Wed, 23 Feb 2011 19:49:54 GMT
Author: aadamchik
Date: Wed Feb 23 19:49:53 2011
New Revision: 1073911

URL: http://svn.apache.org/viewvc?rev=1073911&view=rev
Log:
tests cleanup

switching to Mockito

Removed:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/MockDbAdapter.java
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/server/DataDomainProviderTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/server/DefaultDbAdapterFactoryTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/server/DataDomainProviderTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/server/DataDomainProviderTest.java?rev=1073911&r1=1073910&r2=1073911&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/server/DataDomainProviderTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/server/DataDomainProviderTest.java
Wed Feb 23 19:49:53 2011
@@ -18,6 +18,8 @@
  ****************************************************************/
 package org.apache.cayenne.configuration.server;
 
+import static org.mockito.Mockito.mock;
+
 import java.util.Collection;
 import java.util.Collections;
 
@@ -45,7 +47,6 @@ import org.apache.cayenne.configuration.
 import org.apache.cayenne.configuration.RuntimeProperties;
 import org.apache.cayenne.configuration.mock.MockDataSourceFactory;
 import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.dba.MockDbAdapter;
 import org.apache.cayenne.dba.oracle.OracleAdapter;
 import org.apache.cayenne.di.Binder;
 import org.apache.cayenne.di.DIBootstrap;
@@ -66,6 +67,8 @@ public class DataDomainProviderTest exte
         // create dependencies
         final String testConfigName = "testConfig";
         final DataChannelDescriptor testDescriptor = new DataChannelDescriptor();
+        
+        final DbAdapter mockAdapter = mock(DbAdapter.class);
 
         DataMap map1 = new DataMap("map1");
         testDescriptor.getDataMaps().add(map1);
@@ -137,7 +140,7 @@ public class DataDomainProviderTest exte
                                     nodeDescriptor.getAdapterType()).newInstance();
                         }
 
-                        return new MockDbAdapter();
+                        return mockAdapter;
                     }
                 });
 
@@ -203,6 +206,6 @@ public class DataDomainProviderTest exte
                 .getName());
 
         assertNotNull(node2.getAdapter());
-        assertEquals(MockDbAdapter.class, node2.getAdapter().getClass());
+        assertSame(mockAdapter, node2.getAdapter());
     }
 }

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=1073911&r1=1073910&r2=1073911&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 Feb 23 19:49:53 2011
@@ -18,6 +18,10 @@
  ****************************************************************/
 package org.apache.cayenne.configuration.server;
 
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 import java.sql.DatabaseMetaData;
 import java.sql.SQLException;
 import java.util.ArrayList;
@@ -28,11 +32,9 @@ import junit.framework.TestCase;
 import org.apache.cayenne.configuration.AdhocObjectFactory;
 import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.configuration.DefaultAdhocObjectFactory;
-import org.apache.cayenne.configuration.server.DbAdapterDetector;
-import org.apache.cayenne.configuration.server.DefaultDbAdapterFactory;
 import org.apache.cayenne.dba.AutoAdapter;
 import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.dba.MockDbAdapter;
+import org.apache.cayenne.dba.sybase.SybaseAdapter;
 import org.apache.cayenne.di.Binder;
 import org.apache.cayenne.di.DIBootstrap;
 import org.apache.cayenne.di.Injector;
@@ -48,13 +50,8 @@ public class DefaultDbAdapterFactoryTest
 
     public void testCreatedAdapter_Auto() throws Exception {
 
-        final DbAdapter adapter = new MockDbAdapter() {
-
-            @Override
-            public String createTable(DbEntity ent) {
-                return "XXXXX";
-            }
-        };
+        final DbAdapter adapter = mock(DbAdapter.class);
+        when(adapter.createTable(any(DbEntity.class))).thenReturn("XXXXX");
 
         List<DbAdapterDetector> detectors = new ArrayList<DbAdapterDetector>();
         detectors.add(new DbAdapterDetector() {
@@ -120,7 +117,7 @@ public class DefaultDbAdapterFactoryTest
     public void testCreatedAdapter_Custom() throws Exception {
 
         DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
-        nodeDescriptor.setAdapterType(MockDbAdapter.class.getName());
+        nodeDescriptor.setAdapterType(SybaseAdapter.class.getName());
 
         List<DbAdapterDetector> detectors = new ArrayList<DbAdapterDetector>();
 
@@ -143,6 +140,6 @@ public class DefaultDbAdapterFactoryTest
         assertNotNull(createdAdapter);
         assertTrue(
                 "Unexpected class: " + createdAdapter.getClass().getName(),
-                createdAdapter instanceof MockDbAdapter);
+                createdAdapter instanceof SybaseAdapter);
     }
 }



Mime
View raw message