felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1761365 - /felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FELIX5337.java
Date Sun, 18 Sep 2016 21:22:05 GMT
Author: pderop
Date: Sun Sep 18 21:22:05 2016
New Revision: 1761365

URL: http://svn.apache.org/viewvc?rev=1761365&view=rev
Log:
FELIX-5337: wait for 2 seconds before counting number of services because some services may
be started asynchronously.

Modified:
    felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FELIX5337.java

Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FELIX5337.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FELIX5337.java?rev=1761365&r1=1761364&r2=1761365&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FELIX5337.java
(original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FELIX5337.java
Sun Sep 18 21:22:05 2016
@@ -90,8 +90,7 @@ public class FELIX5337 implements Framew
 	 */
 	@ServiceDependency(filter = "(objectClass=*)")
 	void bindService(Object service) {
-		m_services++; // thread safe, in DM, service callbacks are always thread
-						// safe.
+		m_services++; // thread safe, in DM, service callbacks are always thread safe.
 	}
 
 	@Start
@@ -120,9 +119,18 @@ public class FELIX5337 implements Framew
 	public void frameworkEvent(FrameworkEvent event) {
 		switch (event.getType()) {
 		case FrameworkEvent.STARTED:
-			// Make sure all services found using DM api matches the number of services found using
annotations.
-			Assert.assertEquals(m_services, m_servicesAPI);
-			m_sequencer.step(2);
+		    // some services may be registered asynchronously. so, wait 2 seconds to be sure all
services are registered (it's dirty, but how to avoid this ?)
+		    new Thread(() -> {
+		        try
+                {
+                    Thread.sleep(2000);
+                } catch (InterruptedException e)
+                {
+                }
+		        // Make sure all services found using DM api matches the number of services found
using annotations.
+		        Assert.assertEquals(m_services, m_servicesAPI);
+		        m_sequencer.step(2);
+		    }).start();
 			break;
 		}
 	}



Mime
View raw message