io.reactivex.Flowable.error()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(176)

本文整理了Java中io.reactivex.Flowable.error()方法的一些代码示例,展示了Flowable.error()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flowable.error()方法的具体详情如下:
包路径:io.reactivex.Flowable
类名称:Flowable
方法名:error

Flowable.error介绍

[英]Returns a Flowable that invokes a Subscriber's Subscriber#onError method when the Subscriber subscribes to it.

Backpressure: This source doesn't produce any elements and effectively ignores downstream backpressure. Scheduler: error does not operate by default on a particular Scheduler.
[中]返回一个Flowable,当订阅者订阅它时,它调用订阅者的订阅者#onError方法。
背压:该源不产生任何元素,有效地忽略了下游背压。计划程序:默认情况下,错误不会在特定计划程序上运行。

代码示例

代码示例来源:origin: ReactiveX/RxJava

@Test
public void testCountError() {
  Flowable<String> f = Flowable.error(new Callable<Throwable>() {
    @Override
    public Throwable call() {
      return new RuntimeException();
    }
  });
  f.count().subscribe(wo);
  verify(wo, never()).onSuccess(anyInt());
  verify(wo, times(1)).onError(any(RuntimeException.class));
}

代码示例来源:origin: ReactiveX/RxJava

@Test(expected = NullPointerException.class)
public void testForEachWithNull() {
  Flowable.error(new Exception("boo"))
  //
  .forEach(null);
}

代码示例来源:origin: ReactiveX/RxJava

@Test(timeout = 2000)
public void testRepeatError() {
  Subscriber<Object> subscriber = TestHelper.mockSubscriber();
  Flowable.error(new TestException()).repeat(10).subscribe(subscriber);
  verify(subscriber).onError(any(TestException.class));
  verify(subscriber, never()).onNext(any());
  verify(subscriber, never()).onComplete();
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void testSkipError() {
  Exception e = new Exception();
  Flowable<String> ok = Flowable.just("one");
  Flowable<String> error = Flowable.error(e);
  Flowable<String> skip = Flowable.concat(ok, error).skip(100);
  Subscriber<String> subscriber = TestHelper.mockSubscriber();
  skip.subscribe(subscriber);
  verify(subscriber, never()).onNext(any(String.class));
  verify(subscriber, times(1)).onError(e);
  verify(subscriber, never()).onComplete();
}

代码示例来源:origin: ReactiveX/RxJava

@Test(/* timeout = 1000, */expected = RuntimeException.class)
public void testHasNextThrows() {
  TestScheduler scheduler = new TestScheduler();
  Flowable<Long> source = Flowable.<Long> error(new RuntimeException("Forced failure!")).subscribeOn(scheduler);
  Iterable<Long> iter = source.blockingLatest();
  Iterator<Long> it = iter.iterator();
  scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
  it.hasNext();
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void testAssertError() {
  RuntimeException e = new RuntimeException("Oops");
  TestSubscriber<Object> subscriber = new TestSubscriber<Object>();
  Flowable.error(e).subscribe(subscriber);
  subscriber.assertError(e);
}

代码示例来源:origin: ReactiveX/RxJava

@Test(timeout = 5000, expected = TestException.class)
public void concatObservableError() {
  Completable c = Completable.concat(Flowable.<Completable>error(new Callable<Throwable>() {
    @Override
    public Throwable call() {
      return new TestException();
    }
  }));
  c.blockingAwait();
}

代码示例来源:origin: ReactiveX/RxJava

@Test(timeout = 5000, expected = TestException.class)
public void mergeObservableError() {
  Completable c = Completable.merge(Flowable.<Completable>error(new Callable<Throwable>() {
    @Override
    public Throwable call() {
      return new TestException();
    }
  }));
  c.blockingAwait();
}

代码示例来源:origin: ReactiveX/RxJava

@Test(timeout = 5000, expected = TestException.class)
public void mergeDelayErrorObservableError() {
  Completable c = Completable.mergeDelayError(Flowable.<Completable>error(new Callable<Throwable>() {
    @Override
    public Throwable call() {
      return new TestException();
    }
  }));
  c.blockingAwait();
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void flowableBoundedBlockingSubscribe1() {
  Flowable.error(new TestException())
      .blockingSubscribe(Functions.emptyConsumer(), 128);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void testWithError3() {
  Single<Boolean> single = Flowable.sequenceEqual(
      Flowable.concat(Flowable.just("one"),
          Flowable.<String> error(new TestException())),
      Flowable.concat(Flowable.just("one"),
          Flowable.<String> error(new TestException())));
  verifyError(single);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void error() {
  Flowable.error(new TestException())
  .throttleLatest(1, TimeUnit.MINUTES)
  .test()
  .assertFailure(TestException.class);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void error() {
  Flowable.error(new TestException())
  .takeLast(5)
  .test()
  .assertFailure(TestException.class);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void fromFlowableError() {
  Flowable.error(new TestException())
  .singleElement()
  .test()
  .assertFailure(TestException.class);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
  public void error() {
    Flowable.error(new TestException())
    .skipWhile(Functions.alwaysFalse())
    .test()
    .assertFailure(TestException.class);
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void dontRetry() {
  Flowable.error(new TestException("Outer"))
  .retry(Functions.alwaysFalse())
  .test()
  .assertFailureAndMessage(TestException.class, "Outer");
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void mainError() {
  Flowable.error(new TestException())
  .window(Functions.justCallable(Flowable.never()))
  .test()
  .assertError(TestException.class);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void boundaryOnError() {
  TestSubscriber<Object> ts = Flowable.error(new TestException())
  .window(Flowable.never())
  .flatMap(Functions.<Flowable<Object>>identity(), true)
  .test()
  .assertFailure(CompositeException.class);
  List<Throwable> errors = TestHelper.compositeList(ts.errors().get(0));
  TestHelper.assertError(errors, 0, TestException.class);
}

代码示例来源:origin: ReactiveX/RxJava

@Test(timeout = 5000)
public void startWithFlowableError() {
  Flowable<Object> c = normal.completable
      .startWith(Flowable.error(new TestException()));
  TestSubscriber<Object> ts = new TestSubscriber<Object>();
  c.subscribe(ts);
  normal.assertSubscriptions(0);
  ts.assertNoValues();
  ts.assertError(TestException.class);
  ts.assertNotComplete();
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void boundaryError() {
  BehaviorProcessor.createDefault(1)
  .window(Functions.justCallable(Flowable.error(new TestException())))
  .test()
  .assertValueCount(1)
  .assertNotComplete()
  .assertError(TestException.class);
}

相关文章

Flowable类方法