From 0d26b10ab6776e741d5744079e5ceb2226ffd1c0 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 6 Nov 2012 17:37:26 +0100 Subject: jurt: remote test: synchronize updates to counters in TestWorkAt Apparently it is possible to lose updates there, or at least i've had a failure where only 34 out of 35 increments were performed when checking in passedAsyncTest from JobQueue_Test.testStaticThreadExecutesAsyncs. Change-Id: I823ac65980e4e94be21305a10b98b4cfca247c81 --- .../com/sun/star/lib/uno/environments/remote/TestWorkAt.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'jurt/test') diff --git a/jurt/test/com/sun/star/lib/uno/environments/remote/TestWorkAt.java b/jurt/test/com/sun/star/lib/uno/environments/remote/TestWorkAt.java index 616a79fe20f6..6be7a7bdd06f 100644 --- a/jurt/test/com/sun/star/lib/uno/environments/remote/TestWorkAt.java +++ b/jurt/test/com/sun/star/lib/uno/environments/remote/TestWorkAt.java @@ -18,6 +18,8 @@ package com.sun.star.lib.uno.environments.remote; +import static org.junit.Assert.*; + class TestWorkAt implements TestIWorkAt { /** * When set to true, enables various debugging output. @@ -38,9 +40,12 @@ class TestWorkAt implements TestIWorkAt { boolean _passedAync = true; boolean _notified = false; - public void syncCall() throws Throwable { + public synchronized void syncCall() throws Throwable { ++ _sync_counter; + // at least in currently run tests this should never fire, so dont + // defer the check until passedAsyncTest and assert here + assertEquals(MESSAGES, _async_counter); if(_async_counter != MESSAGES) _passedAync = false; @@ -53,7 +58,7 @@ class TestWorkAt implements TestIWorkAt { if(DEBUG) System.err.println("syncCall:" + _sync_counter + " " + _passedAync + " " + Thread.currentThread()); } - public void asyncCall() throws Throwable { + public synchronized void asyncCall() throws Throwable { // Thread.sleep(50); ++ _async_counter; @@ -83,6 +88,8 @@ class TestWorkAt implements TestIWorkAt { } public boolean passedAsyncTest() { + assertEquals(MESSAGES, _sync_counter); + assertTrue(_passedAync); return _passedAync && (_sync_counter == MESSAGES); } } -- cgit