felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r809570 - in /felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration: ConfigurationBindingTest.java ConfigurationTestBase.java
Date Mon, 31 Aug 2009 13:03:12 GMT
Author: fmeschbe
Date: Mon Aug 31 13:03:11 2009
New Revision: 809570

URL: http://svn.apache.org/viewvc?rev=809570&view=rev
Log:
Instead of just sitting for a number of seconds we add a ConfigurationAdmin
scheduled task (assuming this would be the last after the expected
service update tasks) notifying the test of the end of asynchronous tasks

Modified:
    felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationBindingTest.java
    felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationTestBase.java

Modified: felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationBindingTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationBindingTest.java?rev=809570&r1=809569&r2=809570&view=diff
==============================================================================
--- felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationBindingTest.java
(original)
+++ felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationBindingTest.java
Mon Aug 31 13:03:11 2009
@@ -640,7 +640,6 @@
         // 5. Call Configuration.setBundleLocation( "locationB" )
         config.setBundleLocation( locationB );
         delay();
-        delay();
 
         // ==> configuration is bound to locationB
         TestCase.assertEquals( locationB, config.getBundleLocation() );
@@ -717,7 +716,6 @@
         // 5. Call Configuration.setBundleLocation( "locationB" )
         config.setBundleLocation( locationB );
         delay();
-        delay();
 
         // ==> configuration is bound to locationB
         TestCase.assertEquals( locationB, config.getBundleLocation() );
@@ -800,7 +798,6 @@
         // 5. Call Configuration.setBundleLocation( "locationB" )
         config.setBundleLocation( locationB );
         delay();
-        delay();
 
         // ==> configuration is bound to locationB
         TestCase.assertEquals( locationB, config.getBundleLocation() );
@@ -883,7 +880,6 @@
         // 5. Uninstall bundle A
         bundleA.uninstall();
         delay();
-        delay();
 
         /*
          * According to BJ Hargrave configuration is not re-dispatched
@@ -959,7 +955,6 @@
         // 5. Uninstall bundle A
         bundleA.uninstall();
         delay();
-        delay();
 
         /*
          * According to BJ Hargrave configuration is not re-dispatched

Modified: felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationTestBase.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationTestBase.java?rev=809570&r1=809569&r2=809570&view=diff
==============================================================================
--- felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationTestBase.java
(original)
+++ felix/trunk/configadmin/src/test/java/org/apache/felix/cm/integration/ConfigurationTestBase.java
Mon Aug 31 13:03:11 2009
@@ -22,14 +22,18 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
 import java.util.Dictionary;
 import java.util.Hashtable;
 
+import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
 
 import org.apache.felix.cm.integration.helper.BaseTestActivator;
 import org.apache.felix.cm.integration.helper.ManagedServiceTestActivator;
 import org.apache.felix.cm.integration.helper.MyTinyBundle;
+import org.apache.felix.cm.integration.helper.UpdateThreadSignalTask;
 import org.junit.After;
 import org.junit.Before;
 import org.ops4j.pax.exam.CoreOptions;
@@ -163,8 +167,42 @@
     }
 
 
-    protected static void delay()
+    protected void delay()
     {
+        Object ca = configAdminTracker.getService();
+        if ( ca != null )
+        {
+            try
+            {
+
+                Field caf = ca.getClass().getDeclaredField( "configurationManager" );
+                caf.setAccessible( true );
+                Object cm = caf.get( ca );
+
+                Field cmf = cm.getClass().getDeclaredField( "updateThread" );
+                cmf.setAccessible( true );
+                Object ut = cmf.get( cm );
+
+                Method utm = ut.getClass().getDeclaredMethod( "schedule" );
+                utm.setAccessible( true );
+
+                UpdateThreadSignalTask signalTask = new UpdateThreadSignalTask();
+                utm.invoke( ut, signalTask );
+                signalTask.waitSignal();
+
+                return;
+            }
+            catch ( AssertionFailedError afe )
+            {
+                throw afe;
+            }
+            catch ( Throwable t )
+            {
+                // ignore any problem and revert to timed delay (might log this)
+            }
+        }
+
+        // no configadmin or failure while setting up task
         try
         {
             Thread.sleep( 300 );



Mime
View raw message