Skip to content

Commit fe255ad

Browse files
Merge pull request #473 from benjchristensen/fix-nondeterministic-unit-test
Fix non-deterministic unit test
2 parents a57042c + 8acdaa1 commit fe255ad

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

rxjava-core/src/test/java/rx/operators/OperationMapTest.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -264,29 +264,21 @@ public Integer call(Integer arg0) {
264264
}).toBlockingObservable().single();
265265
}
266266

267-
@Test
267+
@Test(expected = IllegalArgumentException.class)
268268
public void testMapWithErrorInFuncAndThreadPoolScheduler() throws InterruptedException {
269269
// The error will throw in one of threads in the thread pool.
270270
// If map does not handle it, the error will disappear.
271271
// so map needs to handle the error by itself.
272-
final CountDownLatch latch = new CountDownLatch(1);
273272
Observable<String> m = Observable.from("one")
274273
.observeOn(Schedulers.threadPoolForComputation())
275274
.map(new Func1<String, String>() {
276275
public String call(String arg0) {
277-
try {
278-
throw new IllegalArgumentException("any error");
279-
} finally {
280-
latch.countDown();
281-
}
276+
throw new IllegalArgumentException("any error");
282277
}
283278
});
284279

285-
m.subscribe(stringObserver);
286-
latch.await();
287-
InOrder inorder = inOrder(stringObserver);
288-
inorder.verify(stringObserver, times(1)).onError(any(IllegalArgumentException.class));
289-
inorder.verifyNoMoreInteractions();
280+
// block for response, expecting exception thrown
281+
m.toBlockingObservable().last();
290282
}
291283

292284
/**

0 commit comments

Comments
 (0)