jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1359596 - /jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java
Date Tue, 10 Jul 2012 10:57:57 GMT
Author: jukka
Date: Tue Jul 10 10:57:56 2012
New Revision: 1359596

URL: http://svn.apache.org/viewvc?rev=1359596&view=rev
Log:
OAK-177: Too fast timeout in MicroKernelIT.waitForCommit

Modified:
    jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java

Modified: jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java?rev=1359596&r1=1359595&r2=1359596&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java
(original)
+++ jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java
Tue Jul 10 10:57:56 2012
@@ -270,8 +270,9 @@ public class MicroKernelIT extends Abstr
     }
 
     @Test
-    public void waitForCommit() {
-        final long TIMEOUT = 100;
+    public void waitForCommit() throws InterruptedException {
+        final long SHORT_TIMEOUT = 1000;
+        final long LONG_TIMEOUT = 1000;
 
         // concurrent commit
         String oldHead = mk.getHeadRevision();
@@ -279,21 +280,13 @@ public class MicroKernelIT extends Abstr
         Thread t = new Thread("") {
             @Override
             public void run() {
-                try {
-                    sleep(TIMEOUT / 2);
-                } catch (InterruptedException ignore) {
-                }
                 String newHead = mk.commit("/", "+\"foo\":{}", null, "");
                 setName(newHead);
             }
         };
         t.start();
-        String newHead = null;
-        try {
-            newHead = mk.waitForCommit(oldHead, TIMEOUT);
-            t.join();
-        } catch (InterruptedException ignore) {
-        }
+        String newHead = mk.waitForCommit(oldHead, LONG_TIMEOUT);
+        t.join();
 
         assertFalse(oldHead.equals(newHead));
         assertEquals(newHead, t.getName());
@@ -302,27 +295,19 @@ public class MicroKernelIT extends Abstr
         // the current head is already more recent than oldRevision;
         // the method should return immediately (TIMEOUT not applied)
         String currentHead = mk.getHeadRevision();
-        newHead = null;
-        try {
-            long t0 = System.currentTimeMillis();
-            newHead = mk.waitForCommit(oldHead, TIMEOUT);
-            long t1 = System.currentTimeMillis();
-            assertTrue((t1 - t0) < TIMEOUT);
-        } catch (InterruptedException ignore) {
-        }
+        long t0 = System.currentTimeMillis();
+        newHead = mk.waitForCommit(oldHead, LONG_TIMEOUT);
+        long t1 = System.currentTimeMillis();
+        assertTrue((t1 - t0) < LONG_TIMEOUT);
         assertEquals(currentHead, newHead);
 
         // there's no more recent head available;
-        // the method should wait TIMEOUT ms
+        // the method should wait for the given short timeout
         currentHead = mk.getHeadRevision();
-        newHead = null;
-        try {
-            long t0 = System.currentTimeMillis();
-            newHead = mk.waitForCommit(currentHead, TIMEOUT);
-            long t1 = System.currentTimeMillis();
-            assertTrue((t1 - t0) >= TIMEOUT);
-        } catch (InterruptedException ignore) {
-        }
+        long t2 = System.currentTimeMillis();
+        newHead = mk.waitForCommit(currentHead, SHORT_TIMEOUT);
+        long t3 = System.currentTimeMillis();
+        assertTrue((t3 - t2) >= SHORT_TIMEOUT);
         assertEquals(currentHead, newHead);
     }
 



Mime
View raw message