@Test
public void testConcatConcurrentWithInfinity() {

    final TestObservable<String> w1 = new TestObservable<String>("one", "two", "three");
    //This observable will send "hello" MAX_VALUE time.
    final TestObservable<String> w2 = new TestObservable<String>("hello", Integer.MAX_VALUE);
    @SuppressWarnings("unchecked")
    Observer<String> observer = mock(Observer.class);
    @SuppressWarnings("unchecked")
    TestObservable<Observable<String>> observableOfObservables = new TestObservable<Observable<String>>(Observable.create(w1), Observable.create(w2));
    Observable.OnSubscribeFunc<String> concatF = concat(Observable.create(observableOfObservables));
    Observable<String> concat = Observable.create(concatF);
    concat.take(50).subscribe(observer);
    //Wait for the thread to start up.
    try {
        w1.waitForThreadDone();
        w2.waitForThreadDone();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    InOrder inOrder = inOrder(observer);
    inOrder.verify(observer, times(1)).onNext("one");
    inOrder.verify(observer, times(1)).onNext("two");
    inOrder.verify(observer, times(1)).onNext("three");
    inOrder.verify(observer, times(47)).onNext("hello");
    verify(observer, times(1)).onCompleted();
    verify(observer, never()).onError(any(Throwable.class));
}