You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by pd...@apache.org on 2014/05/28 15:01:51 UTC

svn commit: r1598003 - /felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/TestBase.java

Author: pderop
Date: Wed May 28 13:01:51 2014
New Revision: 1598003

URL: http://svn.apache.org/r1598003
Log:
Clear all dependency managers by default when an integration test is finished.

Modified:
    felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/TestBase.java

Modified: felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/TestBase.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/TestBase.java?rev=1598003&r1=1598002&r2=1598003&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/TestBase.java (original)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/TestBase.java Wed May 28 13:01:51 2014
@@ -26,6 +26,10 @@ public abstract class TestBase extends T
     // Default OSGI log service level.
     protected final static int LOG_LEVEL = LogService.LOG_WARNING;
     
+    // By default, we clear all dependendency managers when a test is done. Overriden by runtime tests, 
+    // where we must not clear managers created by the runtime itself.
+    protected final boolean m_autoClearDependencyManagers;
+    
     // Flag used to check if some errors have been logged during the execution of a given test.
     private volatile boolean m_errorsLogged;
 
@@ -33,7 +37,15 @@ public abstract class TestBase extends T
     protected ServiceRegistration logService;
     
     protected BundleContext context;
+    
+    public TestBase() {
+        this(true);
+    }
        
+    public TestBase(boolean autoClearDependencyManagers) {
+        m_autoClearDependencyManagers = autoClearDependencyManagers;
+    }
+    
     public void setUp() throws Exception {
     	warn("Setting up test " + getClass().getName());
     	context = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
@@ -45,6 +57,17 @@ public abstract class TestBase extends T
     	warn("Tearing down test " + getClass().getName());
     	logService.unregister();
     	context.removeFrameworkListener(this);
+    	if (m_autoClearDependencyManagers) {
+    	    clearAllManagers();
+    	}
+    }
+    
+    protected void clearAllManagers() {
+        // clear all dependency managers
+        List<DependencyManager> list = DependencyManager.getDependencyManagers();
+        for (DependencyManager m : list) {
+            m.clear();
+        }    
     }
 
     /**