Created
October 22, 2015 20:10
-
-
Save alexlehm/1f274afe2409aab3e2de to your computer and use it in GitHub Desktop.
TimerCancelTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.atomic.AtomicBoolean; | |
import org.junit.Test; | |
import io.vertx.core.Vertx; | |
import io.vertx.core.eventbus.impl.HandlerRegistration; | |
import io.vertx.test.core.VertxTestBase; | |
/** | |
* @author <a href="http://oss.lehmann.cx/">Alexander Lehmann</a> | |
* | |
*/ | |
public class TimerCancelTest extends VertxTestBase { | |
@Test | |
public void testTimerCancel() { | |
Vertx vertx = Vertx.vertx(); | |
HandlerRegistration<String> handlerRegistration = new HandlerRegistration<String>(vertx, null, null, null, false, | |
false, null, -1); | |
AtomicBoolean timerFinished = new AtomicBoolean(false); | |
long tid1 = vertx.setTimer(1000, id -> { | |
timerFinished.set(true); | |
}); | |
if (tid1 != 0) { | |
fail("timer id is not 0, the issue will not show"); | |
} | |
handlerRegistration.unregister(); | |
vertx.setTimer(2000, id2 -> { | |
assertTrue("timer did not finish", timerFinished.get()); | |
testComplete(); | |
}); | |
await(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment