Skip to content

Commit 2e53b67

Browse files
abersnazebenjchristensen
authored andcommitted
The test has to wait on each action independently.
Reduced the size of the iterable because I think it was blowing through the stack.
1 parent 22b6b3d commit 2e53b67

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

rxjava-core/src/test/java/rx/ObserveOnTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void testObserveOnWithNewThreadScheduler() {
3535
final AtomicInteger count = new AtomicInteger();
3636
final int _multiple = 99;
3737

38-
Observable.range(1, 100000).map(new Func1<Integer, Integer>() {
38+
Observable.range(1, 1000).map(new Func1<Integer, Integer>() {
3939

4040
@Override
4141
public Integer call(Integer t1) {
@@ -62,7 +62,7 @@ public void testObserveOnWithThreadPoolScheduler() {
6262
final AtomicInteger count = new AtomicInteger();
6363
final int _multiple = 99;
6464

65-
Observable.range(1, 100000).map(new Func1<Integer, Integer>() {
65+
Observable.range(1, 1000).map(new Func1<Integer, Integer>() {
6666

6767
@Override
6868
public Integer call(Integer t1) {
@@ -95,7 +95,7 @@ public void testObserveOnOrderingConcurrency() {
9595
final AtomicInteger count = new AtomicInteger();
9696
final int _multiple = 99;
9797

98-
Observable.range(1, 10000).map(new Func1<Integer, Integer>() {
98+
Observable.range(1, 1000).map(new Func1<Integer, Integer>() {
9999

100100
@Override
101101
public Integer call(Integer t1) {

rxjava-core/src/test/java/rx/schedulers/AbstractSchedulerTests.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,31 @@ public String call(String s) {
205205
assertTrue(strings.contains("names=>b-2"));
206206
}
207207

208+
/**
209+
* The order of execution is nondeterministic.
210+
* @throws InterruptedException
211+
*/
208212
@SuppressWarnings("rawtypes")
209213
@Test
210214
public final void testSequenceOfActions() throws InterruptedException {
211215
final Scheduler scheduler = getScheduler();
212216

213-
final CountDownLatch latch = new CountDownLatch(1);
217+
final CountDownLatch latch = new CountDownLatch(2);
214218
final Action0 first = mock(Action0.class);
215219
final Action0 second = mock(Action0.class);
216220

217-
// make it wait until after the second is called
221+
// make it wait until both the first and second are called
222+
doAnswer(new Answer() {
223+
224+
@Override
225+
public Object answer(InvocationOnMock invocation) throws Throwable {
226+
try {
227+
return invocation.getMock();
228+
} finally {
229+
latch.countDown();
230+
}
231+
}
232+
}).when(first).call();
218233
doAnswer(new Answer() {
219234

220235
@Override

0 commit comments

Comments
 (0)