fix dodgy unit test
Testing a field which is being modified inside a synchronized block, outside of such a block, is going to lead to weird ordering issues when running a highly parallel test like this, so test the flag inside a synchronized block. Failure manifested as: JUnit version 4.13.2 ........E........... Time: 17,27 There was 1 failure: 1) testStaticThreadExecutesAsyncs(com.sun.star.lib.uno.environments.remote.JobQueue_Test) java.lang.AssertionError: expected:<35> but was:<34> at org.junit.Assert.fail(Assert.java:89) at org.junit.Assert.failNotEquals(Assert.java:835) at org.junit.Assert.assertEquals(Assert.java:647) at org.junit.Assert.assertEquals(Assert.java:633) at com.sun.star.lib.uno.environments.remote.TestWorkAt.passedAsyncTest(TestWorkAt.java:75) at com.sun.star.lib.uno.environments.remote.JobQueue_Test.testAsyncJobQueue(JobQueue_Test.java:180) at com.sun.star.lib.uno.environments.remote.JobQueue_Test.testStaticThreadExecutesAsyncs(JobQueue_Test.java:121) FAILURES!!! Tests run: 19, Failures: 1 Change-Id: Iad980aea1245bfd8ee89887b175eb9dc17643778 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163727 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
parent
ac1bb5eda1
commit
ee118a5e69
3 changed files with 11 additions and 7 deletions
|
@ -150,7 +150,7 @@ public final class JobQueue_Test {
|
|||
"notifyme"),
|
||||
true, null, false, null, null)),
|
||||
null);
|
||||
while (!workAt._notified) {
|
||||
while (!workAt.isNotified()) {
|
||||
workAt.wait();
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ public final class JobQueue_Test {
|
|||
__workAt_td.getMethodDescription("notifyme"),
|
||||
true, null, false, null, null)),
|
||||
null);
|
||||
while (!workAt._notified) {
|
||||
while (!workAt.isNotified()) {
|
||||
workAt.wait();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ class TestWorkAt implements TestIWorkAt {
|
|||
int _async_counter;
|
||||
|
||||
private boolean _passedAsync = true;
|
||||
boolean _notified = false;
|
||||
private boolean _notified = false;
|
||||
|
||||
public synchronized void syncCall() throws Throwable {
|
||||
++ _sync_counter;
|
||||
|
@ -71,6 +71,10 @@ class TestWorkAt implements TestIWorkAt {
|
|||
_notified = true;
|
||||
}
|
||||
|
||||
public synchronized boolean isNotified() {
|
||||
return _notified;
|
||||
}
|
||||
|
||||
public synchronized boolean passedAsyncTest() {
|
||||
assertEquals(MESSAGES, _sync_counter);
|
||||
assertTrue(_passedAsync);
|
||||
|
|
|
@ -74,7 +74,7 @@ public class ThreadPool_Test {
|
|||
synchronized(workAt) {
|
||||
putJob(workAt, false, threadId, "notifyme");
|
||||
|
||||
while(!workAt._notified) {
|
||||
while(!workAt.isNotified()) {
|
||||
workAt.wait();
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ public class ThreadPool_Test {
|
|||
synchronized(workAt) {
|
||||
putJob(workAt, true, threadId, "notifyme");
|
||||
|
||||
while(!workAt._notified) {
|
||||
while(!workAt.isNotified()) {
|
||||
workAt.wait();
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ public class ThreadPool_Test {
|
|||
synchronized(workAt) {
|
||||
putJob(workAt, true, threadId, "notifyme");
|
||||
|
||||
while(!workAt._notified) {
|
||||
while(!workAt.isNotified()) {
|
||||
workAt.wait();
|
||||
}
|
||||
}
|
||||
|
@ -326,7 +326,7 @@ public class ThreadPool_Test {
|
|||
synchronized(workAt) {
|
||||
putJob(workAt, false, threadId, "notifyme");
|
||||
|
||||
while(!workAt._notified) {
|
||||
while(!workAt.isNotified()) {
|
||||
workAt.wait();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue