cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r531207 - /cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/CayenneResources.java
Date Sun, 22 Apr 2007 15:47:18 GMT
Author: aadamchik
Date: Sun Apr 22 08:47:17 2007
New Revision: 531207

URL: http://svn.apache.org/viewvc?view=rev&rev=531207
Log:
CAY-780: Unit tests - test connections are not closed if an error happens in schema setup,
leading in unpredictbale behavior in the following tests
(fixed test setup order)

Modified:
    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/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?view=diff&rev=531207&r1=531206&r2=531207
==============================================================================
--- 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
Sun Apr 22 08:47:17 2007
@@ -66,7 +66,7 @@
 
     private static CayenneResources resources;
 
-    static CayenneResources loadResources() {
+    private static CayenneResources loadResources() {
 
         InputStream in = Thread
                 .currentThread()
@@ -87,13 +87,7 @@
 
         resources.setConnectionKey(System.getProperty(CONNECTION_NAME_KEY));
 
-        try {
-            resources.rebuildSchema();
-        }
-        catch (Exception ex) {
-            logObj.error("Error generating schema...", ex);
-            throw new RuntimeException("Error generating schema");
-        }
+        
 
         return resources;
     }
@@ -112,6 +106,17 @@
     public static CayenneResources getResources() {
         if (resources == null) {
             resources = loadResources();
+
+            // rebuild schema after the resources ivar is initialized so that after
+            // possible initial failure we don't attempt rebuilding schema in subseequent
+            // tests
+            try {
+                resources.rebuildSchema();
+            }
+            catch (Exception ex) {
+                logObj.error("Error generating schema...", ex);
+                throw new RuntimeException("Error generating schema");
+            }
         }
         return resources;
     }



Mime
View raw message