@SuppressWarnings("unchecked")
@Test
public void testBlockedObservableOfObservables() {

    Observer<String> observer = mock(Observer.class);
    final String[] o = { "1", "3", "5", "7" };
    final String[] e = { "2", "4", "6" };
    final Observable<String> odds = Observable.from(o);
    final Observable<String> even = Observable.from(e);
    final CountDownLatch callOnce = new CountDownLatch(1);
    final CountDownLatch okToContinue = new CountDownLatch(1);
    TestObservable<Observable<String>> observableOfObservables = new TestObservable<Observable<String>>(callOnce, okToContinue, odds, even);
    Observable.OnSubscribeFunc<String> concatF = concat(Observable.create(observableOfObservables));
    Observable<String> concat = Observable.create(concatF);
    concat.subscribe(observer);
    try {
        //Block main thread to allow observables to serve up o1.
        callOnce.await();
    } catch (Throwable ex) {
        ex.printStackTrace();
        fail(ex.getMessage());
    }
    // The concated observable should have served up all of the odds.
    verify(observer, times(1)).onNext("1");
    verify(observer, times(1)).onNext("3");
    verify(observer, times(1)).onNext("5");
    verify(observer, times(1)).onNext("7");
    try {
        // unblock observables so it can serve up o2 and complete
        okToContinue.countDown();
        observableOfObservables.t.join();
    } catch (Throwable ex) {
        ex.printStackTrace();
        fail(ex.getMessage());
    }
    // The concatenated observable should now have served up all the evens.
    verify(observer, times(1)).onNext("2");
    verify(observer, times(1)).onNext("4");
    verify(observer, times(1)).onNext("6");
}