You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ja...@apache.org on 2009/10/26 21:37:17 UTC

svn commit: r829943 - in /incubator/jspwiki/trunk/tests/java/org/apache/wiki/auth: authorize/JDBCGroupDatabaseTest.java user/XMLUserDatabaseTest.java

Author: jalkanen
Date: Mon Oct 26 20:37:17 2009
New Revision: 829943

URL: http://svn.apache.org/viewvc?rev=829943&view=rev
Log:
Fixed to call shutdown() properly in case either tearDown() or setUp() fail.

Modified:
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/auth/authorize/JDBCGroupDatabaseTest.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/auth/user/XMLUserDatabaseTest.java

Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/auth/authorize/JDBCGroupDatabaseTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/auth/authorize/JDBCGroupDatabaseTest.java?rev=829943&r1=829942&r2=829943&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/auth/authorize/JDBCGroupDatabaseTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/auth/authorize/JDBCGroupDatabaseTest.java Mon Oct 26 20:37:17 2009
@@ -85,6 +85,7 @@
                                "please make sure that you have started your database "+
                                "(e.g. by running ant hsql-start)");
 
+            m_engine.shutdown();
             throw (SQLException) e.fillInStackTrace();
         }
 
@@ -95,12 +96,17 @@
 
     public void tearDown() throws Exception
     {
-        if ( m_conn != null )
+        try
+        {
+            if ( m_conn != null )
+            {
+                m_conn.close();
+            }
+        }
+        finally
         {
-            m_conn.close();
+            m_engine.shutdown();
         }
-        
-        m_engine.shutdown();
     }
 
     public void testDelete() throws WikiException

Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/auth/user/XMLUserDatabaseTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/auth/user/XMLUserDatabaseTest.java?rev=829943&r1=829942&r2=829943&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/auth/user/XMLUserDatabaseTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/auth/user/XMLUserDatabaseTest.java Mon Oct 26 20:37:17 2009
@@ -64,9 +64,16 @@
   
   protected void tearDown() throws Exception
   {
-      assertEquals( 8, m_db.getWikiNames().length );
-      super.tearDown();
-      m_engine.shutdown();
+      try
+      {
+          // If this fails, shutdown() is never called unless it's wrapped in a finally block.
+          assertEquals( 8, m_db.getWikiNames().length );
+      }
+      finally
+      {
+          super.tearDown();
+          m_engine.shutdown();
+      }
   }
 
   public void testDeleteByLoginName() throws WikiSecurityException