Skip to content

Commit

Permalink
Merge pull request ReactiveX#473 from benjchristensen/fix-nondetermin…
Browse files Browse the repository at this point in the history
…istic-unit-test

Fix non-deterministic unit test
  • Loading branch information
benjchristensen committed Nov 7, 2013
2 parents f52eb41 + a7c5a64 commit 682590c
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions rxjava-core/src/test/java/rx/operators/OperationMapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,29 +264,21 @@ public Integer call(Integer arg0) {
}).toBlockingObservable().single();
}

@Test
@Test(expected = IllegalArgumentException.class)
public void testMapWithErrorInFuncAndThreadPoolScheduler() throws InterruptedException {
// The error will throw in one of threads in the thread pool.
// If map does not handle it, the error will disappear.
// so map needs to handle the error by itself.
final CountDownLatch latch = new CountDownLatch(1);
Observable<String> m = Observable.from("one")
.observeOn(Schedulers.threadPoolForComputation())
.map(new Func1<String, String>() {
public String call(String arg0) {
try {
throw new IllegalArgumentException("any error");
} finally {
latch.countDown();
}
throw new IllegalArgumentException("any error");
}
});

m.subscribe(stringObserver);
latch.await();
InOrder inorder = inOrder(stringObserver);
inorder.verify(stringObserver, times(1)).onError(any(IllegalArgumentException.class));
inorder.verifyNoMoreInteractions();
// block for response, expecting exception thrown
m.toBlockingObservable().last();
}

/**
Expand Down

0 comments on commit 682590c

Please sign in to comment.