reactor.core.publisher.Flux.never()方法的使用及代码示例

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

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

Flux.never介绍

[英]Create a Flux that will never signal any data, error or completion signal.
[中]创建一个永远不会发出任何数据、错误或完成信号的通量。

代码示例

代码示例来源:origin: spring-projects/spring-framework

@GetMapping("/infinite")
  Flux<String> infinite() {
    return Flux.just(0, 1).map(l -> "foo " + l)
        .mergeWith(Flux.never())
        .doOnCancel(() -> cancellation.onComplete());
  }
}

代码示例来源:origin: reactor/reactor-core

@Test(expected = IllegalArgumentException.class)
public void size2Invalid() {
  Flux.never()
    .window(0, 2);
}

代码示例来源:origin: reactor/reactor-core

@Test(expected = NullPointerException.class)
public void predicateNull() {
  Flux.never()
    .filter(null);
}

代码示例来源:origin: reactor/reactor-core

@Test(expected = IllegalArgumentException.class)
public void timesInvalid() {
  Flux.never()
    .retry(-1);
}

代码示例来源:origin: reactor/reactor-core

@Test(expected=IllegalArgumentException.class)
public void failPrefetch(){
  Flux.never()
    .flatMapIterable(t -> null, -1);
}

代码示例来源:origin: reactor/reactor-core

@Test(expected = IllegalArgumentException.class)
public void failPrefetch(){
  Flux.never()
    .replay( -1);
}

代码示例来源:origin: reactor/reactor-core

@Test(expected = IllegalArgumentException.class)
public void failPrefetch(){
  Flux.never()
    .publish( -1);
}

代码示例来源:origin: reactor/reactor-core

@Test
public void openCloseMainError() {
  StepVerifier.create(Flux.error(new IllegalStateException("boom"))
      .bufferWhen(Flux.never(), a -> Flux.never())
  )
        .verifyErrorMessage("boom");
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response) {
  String path = request.getURI().getPath();
  switch (path) {
    case "/write-and-flush":
      return response.writeAndFlushWith(
          testInterval(Duration.ofMillis(50), 2)
              .map(longValue -> wrap("data" + longValue + "\n", response))
              .map(Flux::just)
              .mergeWith(Flux.never()));
    case "/write-and-complete":
      return response.writeWith(
          chunks1K().take(64).map(s -> wrap(s, response)));
    case "/write-and-never-complete":
      // Reactor requires at least 50 to flush, Tomcat/Undertow 8, Jetty 1
      return response.writeWith(
          chunks1K().take(64).map(s -> wrap(s, response)).mergeWith(Flux.never()));
    default:
      return response.writeWith(Flux.empty());
  }
}

代码示例来源:origin: reactor/reactor-core

@Test(expected = IllegalArgumentException.class)
public void failTime(){
  Flux.never()
    .replay( Duration.ofDays(-1));
}

代码示例来源:origin: reactor/reactor-core

@Test
public void emptyIterable() {
  StepVerifier.create(Flux.never().zipWithIterable(new ArrayList<>()))
        .verifyComplete();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void arrayOneIsNullSource() {
  AssertSubscriber<Object> ts = AssertSubscriber.create();
  Flux.first(Flux.never(), null, Flux.never())
    .subscribe
   (ts);
  ts.assertNoValues()
   .assertNotComplete()
   .assertError(NullPointerException.class);
}

代码示例来源:origin: reactor/reactor-core

@Test
public void noTimeout() {
  AssertSubscriber<Integer> ts = AssertSubscriber.create();
  Flux.range(1, 10)
    .timeout(Flux.never(), v -> Flux.never())
    .subscribe(ts);
  ts.assertValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
   .assertComplete()
   .assertNoError();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void verifyNever() {
  Flux<String> flux = Flux.never();
  StepVerifier.create(flux)
        .expectSubscription()
        .thenCancel()
        .verify();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void neverTriggered() {
  AssertSubscriber<Integer> ts = AssertSubscriber.create();
  Flux.range(1, 10)
    .delaySubscription(Flux.never())
    .subscribe(ts);
  ts.assertNoValues()
   .assertNoError()
   .assertNotComplete();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void secondWinner() {
  AssertSubscriber<Integer> ts = AssertSubscriber.create();
  Flux.first(Flux.never(),
      Flux.range(11, 10)
        .log())
    .subscribe(ts);
  ts.assertValues(11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
   .assertComplete()
   .assertNoError();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void mainDoneThenNext() {
  TestPublisher<Integer> source = TestPublisher.createNoncompliant(TestPublisher.Violation.CLEANUP_ON_TERMINATE);
  StepVerifier.create(source.flux()
              .windowWhen(Flux.never(), v -> Mono.just(1))
              .flatMap(Flux.identityFunction()))
        .then(() -> source.complete().next(1))
        .expectComplete()
        .verifyThenAssertThat()
        .hasDropped(1);
}

代码示例来源:origin: reactor/reactor-core

@Test
public void assertWasCancelledFlux() {
  PublisherProbe<Void> probe = PublisherProbe.of(Flux.never());
  Disposable d = probe.flux().subscribe();
  assertThatExceptionOfType(AssertionError.class)
      .isThrownBy(probe::assertWasCancelled)
      .withMessage("PublisherProbe should have been cancelled but it wasn't");
  d.dispose();
  probe.assertWasCancelled();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void assertWasNotCancelledFlux() {
  PublisherProbe<Void> probe = PublisherProbe.of(Flux.never());
  Disposable d = probe.flux().subscribe();
  probe.assertWasNotCancelled();
  d.dispose();
  assertThatExceptionOfType(AssertionError.class)
      .isThrownBy(probe::assertWasNotCancelled)
      .withMessage("PublisherProbe should not have been cancelled but it was");
}

代码示例来源:origin: reactor/reactor-core

@Test
public void cancelComposes() {
  AssertSubscriber<Integer> ts = AssertSubscriber.create();
  EmitterProcessor<Integer> sp = EmitterProcessor.create();
  sp.publish(o -> Flux.<Integer>never())
   .subscribe(ts);
  Assert.assertTrue("Not subscribed?", sp.downstreamCount() != 0);
  ts.cancel();
  Assert.assertTrue("Still subscribed?", sp.downstreamCount() == 0);
}

相关文章

Flux类方法