Skip to content

Commit

Permalink
Added additional test to prove issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Todd Nine authored and benjchristensen committed Feb 21, 2014
1 parent 27c0956 commit c7f7d57
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions rxjava-core/src/test/java/rx/ZipTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
*/
package rx;

import static org.junit.Assert.*;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -31,6 +35,7 @@
import rx.functions.Action1;
import rx.functions.Func1;
import rx.functions.Func2;
import rx.functions.FuncN;
import rx.observables.GroupedObservable;

public class ZipTests {
Expand Down Expand Up @@ -91,6 +96,28 @@ public void testCovarianceOfZip() {
Observable.<Movie, CoolRating, Result> zip(horrors, ratings, combine);
}

/**
* Occasionally zip may be invoked with 0 observables. This blocks indefinitely instead
* of immediately invoking zip with 0 argument.
*/
@Test(timeout = 5000)
public void nonBlockingObservable() {

final Object invoked = new Object();

Collection<Observable<Object>> observables = Collections.emptyList();

Observable<Object> result = Observable.zip(observables, new FuncN<Object>() {
@Override
public Object call(final Object... args) {
assertEquals("No argument should have been passed", 0, args.length);
return invoked;
}
});

assertSame(invoked, result.toBlockingObservable().last());
}

Func2<Media, Rating, ExtendedResult> combine = new Func2<Media, Rating, ExtendedResult>() {
@Override
public ExtendedResult call(Media m, Rating r) {
Expand Down

0 comments on commit c7f7d57

Please sign in to comment.