Simplify cancellation test, fix a typo

This commit is contained in:
Kai S. K. Engelbart 2020-11-25 08:35:51 +01:00
parent 8aefb43823
commit 659bd7888f
Signed by: kske
GPG Key ID: 8BEB13EC5DF7EF13

View File

@ -12,8 +12,7 @@ import org.junit.jupiter.api.*;
*/ */
class EventBusTest implements EventListener { class EventBusTest implements EventListener {
int hits; int hits, cancelledHits;
static int canceledHits;
@BeforeEach @BeforeEach
public void registerListener() { public void registerListener() {
@ -28,10 +27,8 @@ class EventBusTest implements EventListener {
@Test @Test
void testCancellation() { void testCancellation() {
var test2 = new EventBusTest();
test2.registerListener();
EventBus.getInstance().dispatch(new SimpleCancelEvent()); EventBus.getInstance().dispatch(new SimpleCancelEvent());
assertTrue(canceledHits == 1); assertTrue(cancelledHits == 1);
} }
@Event(eventType = SimpleEvent.class, includeSubtypes = true, priority = 200) @Event(eventType = SimpleEvent.class, includeSubtypes = true, priority = 200)
@ -54,8 +51,8 @@ class EventBusTest implements EventListener {
@Event(eventType = SimpleCancelEvent.class, priority = 500) @Event(eventType = SimpleCancelEvent.class, priority = 500)
private void onSimpleCancelFirst() { private void onSimpleCancelFirst() {
++canceledHits; ++cancelledHits;
assertTrue(canceledHits == 1); assertTrue(cancelledHits == 1);
EventBus.getInstance().cancel(); EventBus.getInstance().cancel();
} }