@Test
public void testWindowViaObservableourceThrows() {

    PublishSubject<Integer> source = PublishSubject.create();
    PublishSubject<Integer> boundary = PublishSubject.create();
    @SuppressWarnings("unchecked")
    final Observer<Object> o = mock(Observer.class);
    final List<Observer<Object>> values = new ArrayList<Observer<Object>>();
    Observer<Observable<Integer>> wo = new Observer<Observable<Integer>>() {
        @Override
        public void onNext(Observable<Integer> args) {
            @SuppressWarnings("unchecked")
            final Observer<Object> mo = mock(Observer.class);
            values.add(mo);
            args.subscribe(mo);
        }
        @Override
        public void onError(Throwable e) {
            o.onError(e);
        }
        @Override
        public void onCompleted() {
            o.onCompleted();
        }
    };
    source.window(boundary).subscribe(wo);
    source.onNext(0);
    source.onNext(1);
    source.onNext(2);
    source.onError(new OperationReduceTest.CustomException());
    assertEquals(1, values.size());
    Observer<Object> mo = values.get(0);
    verify(mo).onNext(0);
    verify(mo).onNext(1);
    verify(mo).onNext(2);
    verify(mo).onError(any(OperationReduceTest.CustomException.class));
    verify(o, never()).onCompleted();
    verify(o).onError(any(OperationReduceTest.CustomException.class));
}