incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1375908 - /sling/trunk/launchpad/base/src/test/java/org/apache/sling/launchpad/base/impl/SlingFelixTest.java
Date Wed, 22 Aug 2012 07:12:34 GMT
Author: cziegeler
Date: Wed Aug 22 07:12:33 2012
New Revision: 1375908

URL: http://svn.apache.org/viewvc?rev=1375908&view=rev
Log:
SLING-2571 : Random test failures in SlingFelixTest.test_start_stop()

Modified:
    sling/trunk/launchpad/base/src/test/java/org/apache/sling/launchpad/base/impl/SlingFelixTest.java

Modified: sling/trunk/launchpad/base/src/test/java/org/apache/sling/launchpad/base/impl/SlingFelixTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/test/java/org/apache/sling/launchpad/base/impl/SlingFelixTest.java?rev=1375908&r1=1375907&r2=1375908&view=diff
==============================================================================
--- sling/trunk/launchpad/base/src/test/java/org/apache/sling/launchpad/base/impl/SlingFelixTest.java
(original)
+++ sling/trunk/launchpad/base/src/test/java/org/apache/sling/launchpad/base/impl/SlingFelixTest.java
Wed Aug 22 07:12:33 2012
@@ -56,6 +56,18 @@ public class SlingFelixTest {
         stopSling();
         TestCase.assertNull("Expect the framework field to be cleared", this.framework);
 
+        // as the notifiable is notified async we wait
+        final long start = System.currentTimeMillis();
+        while ( !this.notifiable.stoppedCalled ) {
+            // we wait max 3 seconds
+            if ( System.currentTimeMillis() - start > 3000 ) {
+                break;
+            }
+            try {
+                Thread.sleep(200);
+            } catch (InterruptedException ignore) {
+            }
+        }
         TestCase.assertTrue("Expect Notifiable.stopped to be called", this.notifiable.stoppedCalled);
         TestCase.assertFalse("Expect Notifiable.updated to not be called", this.notifiable.updatedCalled);
         TestCase.assertNull("Expect Notifiable.updated to not be called", this.notifiable.updatedCalledFile);
@@ -172,11 +184,11 @@ public class SlingFelixTest {
 
     private static class TestNotifiable implements Notifiable {
 
-        boolean stoppedCalled = false;
+        volatile boolean stoppedCalled = false;
 
-        boolean updatedCalled = false;
+        volatile boolean updatedCalled = false;
 
-        File updatedCalledFile = null;
+        volatile File updatedCalledFile = null;
 
         public void stopped() {
             this.stoppedCalled = true;



Mime
View raw message