summaryrefslogtreecommitdiff
path: root/jurt/test
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-11-06 17:37:26 +0100
committerMichael Stahl <mstahl@redhat.com>2012-11-06 17:40:55 +0100
commit0d26b10ab6776e741d5744079e5ceb2226ffd1c0 (patch)
treed7d496800dcb99c5cbde5017e73d2b3e19761066 /jurt/test
parentc67b80892e6e35171882de926b1aa48447106f07 (diff)
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
Diffstat (limited to 'jurt/test')
-rw-r--r--jurt/test/com/sun/star/lib/uno/environments/remote/TestWorkAt.java11
1 files changed, 9 insertions, 2 deletions
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);
}
}