@Test
public void testConcatNonBlockingObservables() {

    final CountDownLatch okToContinueW1 = new CountDownLatch(1);
    final CountDownLatch okToContinueW2 = new CountDownLatch(1);
    final TestObservable<String> w1 = new TestObservable<String>(null, okToContinueW1, "one", "two", "three");
    final TestObservable<String> w2 = new TestObservable<String>(null, okToContinueW2, "four", "five", "six");
    @SuppressWarnings("unchecked")
    Observer<String> observer = mock(Observer.class);
    Observable<Observable<String>> observableOfObservables = Observable.create(new Observable.OnSubscribeFunc<Observable<String>>() {
        @Override
        public Subscription onSubscribe(Observer<? super Observable<String>> observer) {
            // simulate what would happen in an observable
            observer.onNext(Observable.create(w1));
            observer.onNext(Observable.create(w2));
            observer.onCompleted();
            return Subscriptions.empty();
        }
    });
    Observable<String> concat = Observable.create(concat(observableOfObservables));
    concat.subscribe(observer);
    verify(observer, times(0)).onCompleted();
    try {
        // release both threads
        okToContinueW1.countDown();
        okToContinueW2.countDown();
        // wait for both to finish
        w1.t.join();
        w2.t.join();
    } catch (InterruptedException e) {
        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(1)).onNext("four");
    inOrder.verify(observer, times(1)).onNext("five");
    inOrder.verify(observer, times(1)).onNext("six");
    verify(observer, times(1)).onCompleted();
}