@RunWith(VertxUnitRunner.class)
public class Khmmm extends VertxTestBase {
@Test
public void sometimesFails(TestContext tc) {
Async async = tc.async(2);
vertx.executeBlocking(fut -> {
vertx.setTimer(10, l -> {
System.out.println("timer1");
async.countDown();
});
vertx.setTimer(10, l -> {
System.out.println("timer2");
async.countDown();
});
fut.complete();
}, tc.asyncAssertSuccess());
async.await(1000);
}
}
Somethimes (but not every case) the very first (and only very first) execution fails:
Starting test: Khmmm#sometimesFails
timer2
java.util.concurrent.TimeoutException: Timed out
at io.vertx.ext.unit.impl.CompletionImpl.await(CompletionImpl.java:73)
at ru.finam.vertx.sql.Khmmm.sometimesFails(Khmmm.java:29)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.vertx.ext.unit.junit.VertxUnitRunner.invokeTestMethod(VertxUnitRunner.java:95)
at io.vertx.ext.unit.junit.VertxUnitRunner.lambda$invokeExplosively$0(VertxUnitRunner.java:114)
at io.vertx.ext.unit.impl.TestContextImpl.run(TestContextImpl.java:90)
....
Starting test: Khmmm#sometimesFails
timer1
timer2
Starting test: Khmmm#sometimesFails
timer1
timer2
It havens when I do this in verticle context or in test context.
It never happens if setTimer() executes from eventloop.
Vertx version=3.7.1
I try to run this test several times.
Somethimes (but not every case) the very first (and only very first) execution fails:
It havens when I do this in verticle context or in test context. It never happens if
setTimer()
executes from eventloop. Vertx version=3.7.1What am I doing wrong?