Exemplo n.º 1
0
  @Override
  public Publisher<Long> createFailedPublisher() {
    if (!DependencyUtils.hasJdk9Flow()) {
      throw new SkipException("no jdk 9 classes found");
    }

    SubmissionPublisher<Long> pub = new SubmissionPublisher<>();
    pub.closeExceptionally(new Exception("jdk9-test"));
    return Publishers.convert(pub);
  }
Exemplo n.º 2
0
 /** If closedExceptionally, upon subscription, the subscriber's onError method is invoked */
 public void testSubscribe3() {
   TestSubscriber s = new TestSubscriber();
   SubmissionPublisher<Integer> p = basicPublisher();
   Throwable ex = new SPException();
   p.closeExceptionally(ex);
   assertTrue(p.isClosed());
   assertSame(p.getClosedException(), ex);
   p.subscribe(s);
   s.awaitError();
   assertEquals(0, s.nexts);
   assertEquals(1, s.errors);
 }
Exemplo n.º 3
0
 /** Closing a publisher exceptionally causes onError to subscribers */
 public void testCloseExceptionallyError() {
   SubmissionPublisher<Integer> p = basicPublisher();
   TestSubscriber s1 = new TestSubscriber();
   TestSubscriber s2 = new TestSubscriber();
   p.subscribe(s1);
   p.subscribe(s2);
   p.submit(1);
   p.closeExceptionally(new SPException());
   assertTrue(p.isClosed());
   s1.awaitError();
   assertTrue(s1.nexts <= 1);
   assertEquals(1, s1.errors);
   s2.awaitError();
   assertTrue(s2.nexts <= 1);
   assertEquals(1, s2.errors);
 }
Exemplo n.º 4
0
 /**
  * A publisher closedExceptionally reports isClosed with the closedException and throws ISE upon
  * attempted submission; a subsequent close or closeExceptionally has no additional effect.
  */
 public void testCloseExceptionally() {
   SubmissionPublisher<Integer> p = basicPublisher();
   checkInitialState(p);
   Throwable ex = new SPException();
   p.closeExceptionally(ex);
   assertTrue(p.isClosed());
   assertSame(p.getClosedException(), ex);
   try {
     p.submit(1);
     shouldThrow();
   } catch (IllegalStateException success) {
   }
   p.close();
   assertTrue(p.isClosed());
   assertSame(p.getClosedException(), ex);
 }