[Libreoffice-commits] .: jurt/test
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Nov 6 08:43:51 PST 2012
jurt/test/com/sun/star/lib/uno/environments/remote/TestWorkAt.java | 11 ++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
New commits:
commit 0d26b10ab6776e741d5744079e5ceb2226ffd1c0
Author: Michael Stahl <mstahl at redhat.com>
Date: Tue Nov 6 17:37:26 2012 +0100
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
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 616a79f..6be7a7b 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);
}
}
More information about the Libreoffice-commits
mailing list