cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1400534 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/merge/MergeCase.java
Date Sat, 20 Oct 2012 23:40:36 GMT
Author: aadamchik
Date: Sat Oct 20 23:40:35 2012
New Revision: 1400534

URL: http://svn.apache.org/viewvc?rev=1400534&view=rev
Log:
refactoring merge tests

allowing exceptions to bubble up

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/merge/MergeCase.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/merge/MergeCase.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/merge/MergeCase.java?rev=1400534&r1=1400533&r2=1400534&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/merge/MergeCase.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/merge/MergeCase.java
Sat Oct 20 23:40:35 2012
@@ -37,9 +37,13 @@ import org.apache.cayenne.test.jdbc.DBHe
 import org.apache.cayenne.unit.UnitDbAdapter;
 import org.apache.cayenne.unit.di.server.ServerCase;
 import org.apache.cayenne.unit.di.server.ServerCaseDataSourceFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 public abstract class MergeCase extends ServerCase {
 
+    private Log logger = LogFactory.getLog(MergeCase.class);
+
     @Inject
     private DBHelper dbHelper;
 
@@ -136,7 +140,7 @@ public abstract class MergeCase extends 
         }
     }
 
-    protected void execute(List<MergerToken> tokens) throws Exception {
+    protected void execute(List<MergerToken> tokens) {
         MergerContext mergerContext = new ExecutingMergerContext(map, node);
         for (MergerToken tok : tokens) {
             tok.execute(mergerContext);
@@ -185,30 +189,35 @@ public abstract class MergeCase extends 
 
     protected void assertTokensAndExecute(int expectedToDb, int expectedToModel) {
         List<MergerToken> tokens = createMergeTokens();
-
         assertTokens(tokens, expectedToDb, expectedToModel);
-        if (!tokens.isEmpty()) {
-            try {
-                execute(tokens);
-            } catch (Exception e) {
-                fail(e.getMessage());
-            }
-        }
+        execute(tokens);
     }
 
     protected MergerFactory mergerFactory() {
         return node.getAdapter().mergerFactory();
     }
 
-    protected void dropTableIfPresent(DataNode node, String tableName) {
+    protected void dropTableIfPresent(DataNode node, String tableName)
+            throws Exception {
+
+        // must have a dummy datamap for the dummy table for the downstream code
+        // to work
+        DataMap map = new DataMap("dummy");
+        map.setQuotingSQLIdentifiers(map.isQuotingSQLIdentifiers());
         DbEntity entity = new DbEntity(tableName);
+        map.addDbEntity(entity);
+
         AbstractToDbToken t = (AbstractToDbToken) mergerFactory()
                 .createDropTableToDb(entity);
-        try {
-            for (String sql : t.createSql(node.getAdapter())) {
+
+        for (String sql : t.createSql(node.getAdapter())) {
+
+            try {
                 executeSql(sql);
+            } catch (Exception e) {
+                logger.info("Exception dropping table " + tableName
+                        + ", probably abscent..");
             }
-        } catch (Exception e) {
         }
     }
 }



Mime
View raw message