Skip to content

Commit 98778aa

Browse files
committed
Failing unit test for reduce, showing it does not implement backpressure correctly
1 parent 08bf50f commit 98778aa

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

rxjava-core/src/test/java/rx/internal/operators/OperatorReduceTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package rx.internal.operators;
1818

19+
import static org.junit.Assert.assertEquals;
1920
import static org.mockito.Matchers.any;
2021
import static org.mockito.Mockito.never;
2122
import static org.mockito.Mockito.times;
@@ -114,4 +115,18 @@ public Integer call(Integer t1) {
114115
verify(observer, times(1)).onError(any(TestException.class));
115116
}
116117

118+
@Test(timeout = 13000)
119+
public void testBackpressure() throws InterruptedException {
120+
Observable<Integer> source = Observable.from(1, 2, 3, 4, 5, 6);
121+
Observable<Integer> reduced = source.reduce(new Func2<Integer, Integer, Integer>() {
122+
@Override
123+
public Integer call(Integer i1, Integer i2) {
124+
return i1 + i2;
125+
}
126+
});
127+
128+
Integer r = reduced.toBlocking().first();
129+
assertEquals(21, r.intValue());
130+
}
131+
117132
}

0 commit comments

Comments
 (0)