FELIX-3680 fix test so it is might pass, and add shutdown logic

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1402236 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/Felix3680_2Test.java b/scr/src/test/java/org/apache/felix/scr/integration/Felix3680_2Test.java
index 57a5c58..4ff99f9 100644
--- a/scr/src/test/java/org/apache/felix/scr/integration/Felix3680_2Test.java
+++ b/scr/src/test/java/org/apache/felix/scr/integration/Felix3680_2Test.java
@@ -41,8 +41,9 @@
         //        paxRunnerVmOption = DEBUG_VM_OPTION;
         descriptorFile = "/integration_test_FELIX_3880_2.xml";
         
+        restrictedLogging = true;
         // Comment this for displaying debug messages
-        DS_LOGLEVEL = "debug";
+        DS_LOGLEVEL = "warn";
     }
 
     @Inject
@@ -69,6 +70,8 @@
         main.enable();
 
         delay( 30 );
+        main.disable();
+        delay(); //async deactivate
         for ( Iterator it = log.foundWarnings().iterator(); it.hasNext(); )
         {
             String message = ( String ) it.next();
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680_2/Main.java b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680_2/Main.java
index 0c2646d..57533a1 100644
--- a/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680_2/Main.java
+++ b/scr/src/test/java/org/apache/felix/scr/integration/components/felix3680_2/Main.java
@@ -47,6 +47,8 @@
     volatile ConcurrentHashMap<Class, ServiceRegistration> m_registrations = new ConcurrentHashMap<Class, ServiceRegistration>();
     volatile Exception _bindStackTrace;
 
+    private volatile boolean running = true;
+
 
     /**
      * Helper used to randomly enable or disable a list of components.
@@ -189,19 +191,22 @@
 
     void start( ComponentContext ctx )
     {
-        m_logService.log( LogService.LOG_WARNING, "Main.start" );
         m_ctx = ctx;
         m_bctx = ctx.getBundleContext();
         m_ctx.getBundleContext().registerService( Executor.class.getName(), m_exec, null );
         new Thread( this ).start();
     }
 
+    void stop()
+    {
+        running = false;
+    }
+
 
     public void run()
     {
-        m_logService.log( LogService.LOG_WARNING, "Main.run" );
         int loop = 0;
-        while ( true )
+        while ( running )
         {
             m_enabledLatch = new CountDownLatch( 11 ); // 10 for registrations of B,C,D,E,F,G,H,I,J,K + 1 for Main.bindA
             m_disabledLatch = new CountDownLatch( 11 ); // 10 for unregistrations of B,C,D,E,F,G,H,I,J,K + 1 for Main.unbindA
@@ -239,10 +244,10 @@
             }
 
             ++loop;
-            //            if ( loop % 100 == 0 )
-            //            {
-            m_logService.log( LogService.LOG_WARNING, "Performed " + loop + " tests." );
-            // }
+            if ( loop % 100 == 0 )
+            {
+                m_logService.log( LogService.LOG_WARNING, "Performed " + loop + " tests." );
+            }
         }
     }
 
diff --git a/scr/src/test/resources/integration_test_FELIX_3880_2.xml b/scr/src/test/resources/integration_test_FELIX_3880_2.xml
index f4e9d5e..a9f958a 100644
--- a/scr/src/test/resources/integration_test_FELIX_3880_2.xml
+++ b/scr/src/test/resources/integration_test_FELIX_3880_2.xml
@@ -12,7 +12,7 @@
 <components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
 	<scr:component xmlns:scr='http://www.osgi.org/xmlns/scr/v1.1.0'
 		enabled='false' name='org.apache.felix.scr.integration.components.felix3680_2.Main'
-		activate='start'>
+		activate='start' deactivate='stop'>
 		<implementation
 			class='org.apache.felix.scr.integration.components.felix3680_2.Main' />
 		<reference name='a'