Skip to content

Commit c3512f1

Browse files
committed
add bombardScheduler() test
1 parent 90a6ca4 commit c3512f1

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/test/java/rx/schedulers/JavaFxSchedulerTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,37 @@ public void testNestedActions() throws Exception {
145145
TestAction.verifyOrder(a, b, a1n, async, a2n, a1n1, a1n2, a2n1, a2n2);
146146
}
147147

148+
@Test
149+
public void bombardScheduler() {
150+
Scheduler.Worker w = JavaFxScheduler.platform().createWorker();
151+
152+
CountDownLatch cdl = new CountDownLatch(2);
153+
int[] counter = { 0, 0 };
154+
155+
new Thread(() -> {
156+
for (int i = 0; i < 1_000_000; i++) {
157+
w.schedule(() -> counter[0]++);
158+
}
159+
w.schedule(cdl::countDown);
160+
}).start();
161+
162+
for (int i = 0; i < 1_000_000; i++) {
163+
w.schedule(() -> counter[1]++);
164+
}
165+
w.schedule(cdl::countDown);
166+
167+
try {
168+
cdl.await();
169+
} catch (InterruptedException e) {
170+
e.printStackTrace();
171+
}
172+
173+
assertEquals(1_000_000, counter[0]);
174+
assertEquals(1_000_000, counter[1]);
175+
176+
w.unsubscribe();
177+
}
178+
148179
static class TestAction implements Action0 {
149180
private final Runnable userRunnable;
150181
private final Runnable start;

0 commit comments

Comments
 (0)