Author: jawi
Date: Wed Oct 16 18:28:12 2013
New Revision: 1532847

URL: http://svn.apache.org/r1532847
Log:
Overridden the runBare method:

- to ensure that a failing set up always causes the 
  tear down method to be called. By default, JUnit does
  not do this, causing subtle side effects in a running
  OSGi framework (some services might already be up and
  running, while others aren't, provisioned configurations
  and so on).


Modified:
    ace/trunk/org.apache.ace.test/src/org/apache/ace/it/IntegrationTestBase.java

Modified: 
ace/trunk/org.apache.ace.test/src/org/apache/ace/it/IntegrationTestBase.java
URL: 
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.test/src/org/apache/ace/it/IntegrationTestBase.java?rev=1532847&r1=1532846&r2=1532847&view=diff
==============================================================================
--- 
ace/trunk/org.apache.ace.test/src/org/apache/ace/it/IntegrationTestBase.java 
(original)
+++ 
ace/trunk/org.apache.ace.test/src/org/apache/ace/it/IntegrationTestBase.java 
Wed Oct 16 18:28:12 2013
@@ -125,6 +125,36 @@ public class IntegrationTestBase extends
     protected Component m_loggingComponent;
 
     /**
+     * Overridden to ensure that our {@link #tearDown()} method is always 
called, even when {@link #setUp()} fails with
+     * an exception (by default, JUnit does not call this method when the set 
up fails).
+     * 
+     * @see junit.framework.TestCase#runBare()
+     */
+    @Override
+    public final void runBare() throws Throwable {
+        Throwable exception = null;
+        try {
+            setUp();
+
+            runTest();
+        }
+        catch (Throwable running) {
+            exception = running;
+        }
+        finally {
+            try {
+                tearDown();
+            }
+            catch (Throwable tearingDown) {
+                if (exception == null)
+                    exception = tearingDown;
+            }
+        }
+        if (exception != null)
+            throw exception;
+    }
+
+    /**
      * Write configuration for a single service. For example,
      * 
      * <pre>


Reply via email to