Search in sources :

Example 11 with Subscriber

use of io.servicetalk.concurrent.PublisherSource.Subscriber in project servicetalk by apple.

the class PublisherConcatMapIterableTest method upstreamRecoverWithMakesProgress.

@Test
void upstreamRecoverWithMakesProgress() throws Exception {
    @SuppressWarnings("unchecked") Subscriber<String> mockSubscriber = mock(Subscriber.class);
    CountDownLatch latchOnSubscribe = new CountDownLatch(1);
    CountDownLatch latchOnError = new CountDownLatch(1);
    AtomicReference<Throwable> causeRef = new AtomicReference<>();
    AtomicInteger nextCount = new AtomicInteger();
    List<String> results = new ArrayList<>();
    doAnswer(a -> {
        Subscription s = a.getArgument(0);
        s.request(Long.MAX_VALUE);
        latchOnSubscribe.countDown();
        return null;
    }).when(mockSubscriber).onSubscribe(any(Subscription.class));
    doAnswer(a -> {
        causeRef.set(a.getArgument(0));
        latchOnError.countDown();
        return null;
    }).when(mockSubscriber).onError(eq(DELIBERATE_EXCEPTION));
    doAnswer(a -> {
        results.add(a.getArgument(0));
        if (nextCount.getAndIncrement() == 0) {
            throw new DeliberateException();
        }
        // final exception
        throw DELIBERATE_EXCEPTION;
    }).when(mockSubscriber).onNext(any());
    Processor<List<String>, List<String>> processor = newPublisherProcessor();
    toSource(fromSource(processor).onErrorResume(cause -> {
        if (cause != DELIBERATE_EXCEPTION) {
            // recover!
            return from(singletonList("two"));
        }
        return failed(cause);
    }).flatMapConcatIterable(identity())).subscribe(mockSubscriber);
    latchOnSubscribe.await();
    processor.onNext(asList("one", "ignored!"));
    latchOnError.await();
    assertThat(results, contains("one", "two"));
    assertThat(causeRef.get(), is(DELIBERATE_EXCEPTION));
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) PlatformDependent.throwException(io.servicetalk.utils.internal.PlatformDependent.throwException) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Processor(io.servicetalk.concurrent.PublisherSource.Processor) DeliberateException(io.servicetalk.concurrent.internal.DeliberateException) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) Subscriber(io.servicetalk.concurrent.PublisherSource.Subscriber) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) SourceAdapters.fromSource(io.servicetalk.concurrent.api.SourceAdapters.fromSource) Future(java.util.concurrent.Future) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Arrays.asList(java.util.Arrays.asList) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Mockito.doAnswer(org.mockito.Mockito.doAnswer) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Publisher.from(io.servicetalk.concurrent.api.Publisher.from) DELIBERATE_EXCEPTION(io.servicetalk.concurrent.internal.DeliberateException.DELIBERATE_EXCEPTION) TestPublisherSubscriber(io.servicetalk.concurrent.test.internal.TestPublisherSubscriber) CyclicBarrier(java.util.concurrent.CyclicBarrier) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Subscription(io.servicetalk.concurrent.PublisherSource.Subscription) Processors.newPublisherProcessor(io.servicetalk.concurrent.api.Processors.newPublisherProcessor) SourceAdapters.toSource(io.servicetalk.concurrent.api.SourceAdapters.toSource) BlockingIterable(io.servicetalk.concurrent.BlockingIterable) Test(org.junit.jupiter.api.Test) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) Publisher.failed(io.servicetalk.concurrent.api.Publisher.failed) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.sameInstance(org.hamcrest.Matchers.sameInstance) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Function.identity(java.util.function.Function.identity) Matchers.is(org.hamcrest.Matchers.is) Mockito.mock(org.mockito.Mockito.mock) ArrayList(java.util.ArrayList) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) Subscription(io.servicetalk.concurrent.PublisherSource.Subscription) DeliberateException(io.servicetalk.concurrent.internal.DeliberateException) Test(org.junit.jupiter.api.Test)

Example 12 with Subscriber

use of io.servicetalk.concurrent.PublisherSource.Subscriber in project servicetalk by apple.

the class PublisherConcatMapIterableTest method cancellableIterableIsCancelled.

@Test
void cancellableIterableIsCancelled() {
    toSource(cancellablePublisher.flatMapConcatIterable(identity())).subscribe(subscriber);
    cancellablePublisher.onSubscribe(subscription);
    subscriber.awaitSubscription().request(1);
    AtomicBoolean cancelled = new AtomicBoolean();
    cancellablePublisher.onNext(new TestIterableToBlockingIterable<>(asList("one", "two"), (time, unit) -> {
    }, (time, unit) -> {
    }, () -> cancelled.set(true)));
    assertThat(subscriber.takeOnNext(), is("one"));
    assertThat(subscriber.pollOnNext(10, MILLISECONDS), is(nullValue()));
    assertThat(subscriber.pollTerminal(10, MILLISECONDS), is(nullValue()));
    subscriber.awaitSubscription().cancel();
    assertTrue(cancelled.get());
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) PlatformDependent.throwException(io.servicetalk.utils.internal.PlatformDependent.throwException) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Processor(io.servicetalk.concurrent.PublisherSource.Processor) DeliberateException(io.servicetalk.concurrent.internal.DeliberateException) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) Subscriber(io.servicetalk.concurrent.PublisherSource.Subscriber) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) SourceAdapters.fromSource(io.servicetalk.concurrent.api.SourceAdapters.fromSource) Future(java.util.concurrent.Future) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Arrays.asList(java.util.Arrays.asList) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Mockito.doAnswer(org.mockito.Mockito.doAnswer) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Publisher.from(io.servicetalk.concurrent.api.Publisher.from) DELIBERATE_EXCEPTION(io.servicetalk.concurrent.internal.DeliberateException.DELIBERATE_EXCEPTION) TestPublisherSubscriber(io.servicetalk.concurrent.test.internal.TestPublisherSubscriber) CyclicBarrier(java.util.concurrent.CyclicBarrier) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Subscription(io.servicetalk.concurrent.PublisherSource.Subscription) Processors.newPublisherProcessor(io.servicetalk.concurrent.api.Processors.newPublisherProcessor) SourceAdapters.toSource(io.servicetalk.concurrent.api.SourceAdapters.toSource) BlockingIterable(io.servicetalk.concurrent.BlockingIterable) Test(org.junit.jupiter.api.Test) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) Publisher.failed(io.servicetalk.concurrent.api.Publisher.failed) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.sameInstance(org.hamcrest.Matchers.sameInstance) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Function.identity(java.util.function.Function.identity) Matchers.is(org.hamcrest.Matchers.is) Mockito.mock(org.mockito.Mockito.mock) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Test(org.junit.jupiter.api.Test)

Example 13 with Subscriber

use of io.servicetalk.concurrent.PublisherSource.Subscriber in project servicetalk by apple.

the class PublisherConcatMapIterableTest method testExceptionFromBufferedOnNextThenTerminalIsPropagated.

@Test
void testExceptionFromBufferedOnNextThenTerminalIsPropagated() {
    final DeliberateException ex2 = new DeliberateException();
    final AtomicBoolean errored = new AtomicBoolean();
    toSource(publisher.flatMapConcatIterable(identity()).map((Function<String, String>) s -> {
        if (!errored.getAndSet(true)) {
            publisher.onError(DELIBERATE_EXCEPTION);
        }
        throw ex2;
    })).subscribe(subscriber);
    subscriber.awaitSubscription().request(3);
    publisher.onNext(asList("one", "two", "three"));
    assertThat(subscriber.awaitOnError(), is(ex2));
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) PlatformDependent.throwException(io.servicetalk.utils.internal.PlatformDependent.throwException) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Processor(io.servicetalk.concurrent.PublisherSource.Processor) DeliberateException(io.servicetalk.concurrent.internal.DeliberateException) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) Subscriber(io.servicetalk.concurrent.PublisherSource.Subscriber) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) SourceAdapters.fromSource(io.servicetalk.concurrent.api.SourceAdapters.fromSource) Future(java.util.concurrent.Future) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Arrays.asList(java.util.Arrays.asList) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Mockito.doAnswer(org.mockito.Mockito.doAnswer) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Publisher.from(io.servicetalk.concurrent.api.Publisher.from) DELIBERATE_EXCEPTION(io.servicetalk.concurrent.internal.DeliberateException.DELIBERATE_EXCEPTION) TestPublisherSubscriber(io.servicetalk.concurrent.test.internal.TestPublisherSubscriber) CyclicBarrier(java.util.concurrent.CyclicBarrier) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Subscription(io.servicetalk.concurrent.PublisherSource.Subscription) Processors.newPublisherProcessor(io.servicetalk.concurrent.api.Processors.newPublisherProcessor) SourceAdapters.toSource(io.servicetalk.concurrent.api.SourceAdapters.toSource) BlockingIterable(io.servicetalk.concurrent.BlockingIterable) Test(org.junit.jupiter.api.Test) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) Publisher.failed(io.servicetalk.concurrent.api.Publisher.failed) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.sameInstance(org.hamcrest.Matchers.sameInstance) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Function.identity(java.util.function.Function.identity) Matchers.is(org.hamcrest.Matchers.is) Mockito.mock(org.mockito.Mockito.mock) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DeliberateException(io.servicetalk.concurrent.internal.DeliberateException) Test(org.junit.jupiter.api.Test)

Example 14 with Subscriber

use of io.servicetalk.concurrent.PublisherSource.Subscriber in project servicetalk by apple.

the class PublisherFlatMapMergeTest method mappedRecoverMakesProgress.

@Test
void mappedRecoverMakesProgress() throws Exception {
    @SuppressWarnings("unchecked") Subscriber<Integer> mockSubscriber = mock(Subscriber.class);
    CountDownLatch latchOnSubscribe = new CountDownLatch(1);
    CountDownLatch latchOnError = new CountDownLatch(1);
    AtomicReference<Throwable> causeRef = new AtomicReference<>();
    BlockingQueue<Integer> results = new ArrayBlockingQueue<>(10);
    doAnswer(a -> {
        Subscription s = a.getArgument(0);
        s.request(4);
        latchOnSubscribe.countDown();
        return null;
    }).when(mockSubscriber).onSubscribe(any(Subscription.class));
    doAnswer(a -> {
        causeRef.set(a.getArgument(0));
        latchOnError.countDown();
        return null;
    }).when(mockSubscriber).onError(any());
    doAnswer(a -> {
        results.add(a.getArgument(0));
        throw DELIBERATE_EXCEPTION;
    }).when(mockSubscriber).onNext(any());
    Processor<Integer, Integer> processor = newPublisherProcessor();
    toSource(fromSource(processor).flatMapMergeDelayError(i -> from(i + 10).onErrorResume(cause -> from(i + 20).concat(failed(cause))))).subscribe(mockSubscriber);
    latchOnSubscribe.await();
    processor.onNext(1);
    assertThat(results.take(), is(11));
    assertThat(results.take(), is(21));
    assertThat(causeRef.get(), is(nullValue()));
    processor.onComplete();
    latchOnError.await();
    final Throwable t = causeRef.get();
    assertThat(t, is(DELIBERATE_EXCEPTION));
}
Also used : PlatformDependent.throwException(io.servicetalk.utils.internal.PlatformDependent.throwException) AfterAll(org.junit.jupiter.api.AfterAll) SourceAdapters.fromSource(io.servicetalk.concurrent.api.SourceAdapters.fromSource) Future(java.util.concurrent.Future) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) BeforeAll(org.junit.jupiter.api.BeforeAll) EMPTY_SUBSCRIPTION(io.servicetalk.concurrent.internal.EmptySubscriptions.EMPTY_SUBSCRIPTION) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Mockito.doAnswer(org.mockito.Mockito.doAnswer) TestPublisherSubscriber(io.servicetalk.concurrent.test.internal.TestPublisherSubscriber) PublisherSource(io.servicetalk.concurrent.PublisherSource) BlockingQueue(java.util.concurrent.BlockingQueue) Math.min(java.lang.Math.min) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Test(org.junit.jupiter.api.Test) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Matchers.is(org.hamcrest.Matchers.is) Queue(java.util.Queue) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) Mockito.mock(org.mockito.Mockito.mock) IntStream(java.util.stream.IntStream) Publisher.never(io.servicetalk.concurrent.api.Publisher.never) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Processor(io.servicetalk.concurrent.PublisherSource.Processor) DeliberateException(io.servicetalk.concurrent.internal.DeliberateException) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) HashMap(java.util.HashMap) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) Publisher.range(io.servicetalk.concurrent.api.Publisher.range) Subscriber(io.servicetalk.concurrent.PublisherSource.Subscriber) ArrayList(java.util.ArrayList) Single.succeeded(io.servicetalk.concurrent.api.Single.succeeded) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Publisher.from(io.servicetalk.concurrent.api.Publisher.from) DELIBERATE_EXCEPTION(io.servicetalk.concurrent.internal.DeliberateException.DELIBERATE_EXCEPTION) ExecutorService(java.util.concurrent.ExecutorService) Nullable(javax.annotation.Nullable) ValueSource(org.junit.jupiter.params.provider.ValueSource) Matchers.empty(org.hamcrest.Matchers.empty) Subscription(io.servicetalk.concurrent.PublisherSource.Subscription) Processors.newPublisherProcessor(io.servicetalk.concurrent.api.Processors.newPublisherProcessor) SourceAdapters.toSource(io.servicetalk.concurrent.api.SourceAdapters.toSource) Mockito.verify(org.mockito.Mockito.verify) ExecutionException(java.util.concurrent.ExecutionException) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Publisher.failed(io.servicetalk.concurrent.api.Publisher.failed) Matchers.sameInstance(org.hamcrest.Matchers.sameInstance) ArrayDeque(java.util.ArrayDeque) SECONDS(java.util.concurrent.TimeUnit.SECONDS) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) Subscription(io.servicetalk.concurrent.PublisherSource.Subscription) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 15 with Subscriber

use of io.servicetalk.concurrent.PublisherSource.Subscriber in project servicetalk by apple.

the class PublisherFlatMapMergeTest method errorFromMappedSubscriberIsSequencedWithOnNextSignals.

@Test
void errorFromMappedSubscriberIsSequencedWithOnNextSignals() throws InterruptedException {
    List<TestSubscriptionPublisherPair<Integer>> mappedPublishers = new ArrayList<>();
    TestSubscription upstreamSubscription = new TestSubscription();
    publisher = new TestPublisher.Builder<Integer>().disableAutoOnSubscribe().build(subscriber1 -> {
        subscriber1.onSubscribe(upstreamSubscription);
        return subscriber1;
    });
    toSource(publisher.flatMapMerge(i -> {
        TestSubscriptionPublisherPair<Integer> pair = new TestSubscriptionPublisherPair<>(i);
        mappedPublishers.add(pair);
        return pair.mappedPublisher;
    }, 2)).subscribe(subscriber);
    Subscription subscription = subscriber.awaitSubscription();
    subscription.request(1);
    verifyCumulativeDemand(upstreamSubscription, 2);
    publisher.onNext(1, 2);
    assertThat(mappedPublishers, hasSize(2));
    TestSubscriptionPublisherPair<Integer> first = mappedPublishers.get(0);
    TestSubscriptionPublisherPair<Integer> second = mappedPublishers.get(1);
    first.doOnSubscribe(1);
    first.mappedSubscription.awaitRequestN(1);
    second.doOnSubscribe(2);
    second.mappedSubscription.awaitRequestN(1);
    // Exhaust outstanding requestN from downstream
    first.mappedPublisher.onNext(10);
    assertThat(subscriber.pollAllOnNext(), contains(10));
    // These signals should be queued, and the error shouldn't jump the queue.
    second.mappedPublisher.onNext(11);
    second.mappedPublisher.onError(DELIBERATE_EXCEPTION);
    assertThat(subscriber.pollAllOnNext(), is(empty()));
    assertTrue(upstreamSubscription.isCancelled());
    subscription.request(1);
    assertThat(subscriber.pollAllOnNext(), contains(11));
    assertThat(subscriber.awaitOnError(), sameInstance(DELIBERATE_EXCEPTION));
}
Also used : PlatformDependent.throwException(io.servicetalk.utils.internal.PlatformDependent.throwException) AfterAll(org.junit.jupiter.api.AfterAll) SourceAdapters.fromSource(io.servicetalk.concurrent.api.SourceAdapters.fromSource) Future(java.util.concurrent.Future) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) BeforeAll(org.junit.jupiter.api.BeforeAll) EMPTY_SUBSCRIPTION(io.servicetalk.concurrent.internal.EmptySubscriptions.EMPTY_SUBSCRIPTION) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Mockito.doAnswer(org.mockito.Mockito.doAnswer) TestPublisherSubscriber(io.servicetalk.concurrent.test.internal.TestPublisherSubscriber) PublisherSource(io.servicetalk.concurrent.PublisherSource) BlockingQueue(java.util.concurrent.BlockingQueue) Math.min(java.lang.Math.min) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Test(org.junit.jupiter.api.Test) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Matchers.is(org.hamcrest.Matchers.is) Queue(java.util.Queue) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) Mockito.mock(org.mockito.Mockito.mock) IntStream(java.util.stream.IntStream) Publisher.never(io.servicetalk.concurrent.api.Publisher.never) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Processor(io.servicetalk.concurrent.PublisherSource.Processor) DeliberateException(io.servicetalk.concurrent.internal.DeliberateException) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) HashMap(java.util.HashMap) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) Publisher.range(io.servicetalk.concurrent.api.Publisher.range) Subscriber(io.servicetalk.concurrent.PublisherSource.Subscriber) ArrayList(java.util.ArrayList) Single.succeeded(io.servicetalk.concurrent.api.Single.succeeded) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Publisher.from(io.servicetalk.concurrent.api.Publisher.from) DELIBERATE_EXCEPTION(io.servicetalk.concurrent.internal.DeliberateException.DELIBERATE_EXCEPTION) ExecutorService(java.util.concurrent.ExecutorService) Nullable(javax.annotation.Nullable) ValueSource(org.junit.jupiter.params.provider.ValueSource) Matchers.empty(org.hamcrest.Matchers.empty) Subscription(io.servicetalk.concurrent.PublisherSource.Subscription) Processors.newPublisherProcessor(io.servicetalk.concurrent.api.Processors.newPublisherProcessor) SourceAdapters.toSource(io.servicetalk.concurrent.api.SourceAdapters.toSource) Mockito.verify(org.mockito.Mockito.verify) ExecutionException(java.util.concurrent.ExecutionException) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Publisher.failed(io.servicetalk.concurrent.api.Publisher.failed) Matchers.sameInstance(org.hamcrest.Matchers.sameInstance) ArrayDeque(java.util.ArrayDeque) SECONDS(java.util.concurrent.TimeUnit.SECONDS) ArrayList(java.util.ArrayList) Subscription(io.servicetalk.concurrent.PublisherSource.Subscription) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Subscriber (io.servicetalk.concurrent.PublisherSource.Subscriber)31 Test (org.junit.jupiter.api.Test)29 Subscription (io.servicetalk.concurrent.PublisherSource.Subscription)27 DELIBERATE_EXCEPTION (io.servicetalk.concurrent.internal.DeliberateException.DELIBERATE_EXCEPTION)23 AtomicReference (java.util.concurrent.atomic.AtomicReference)22 TestPublisherSubscriber (io.servicetalk.concurrent.test.internal.TestPublisherSubscriber)20 CountDownLatch (java.util.concurrent.CountDownLatch)20 Mockito.mock (org.mockito.Mockito.mock)20 SourceAdapters.toSource (io.servicetalk.concurrent.api.SourceAdapters.toSource)19 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)19 Matchers.is (org.hamcrest.Matchers.is)19 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)19 Mockito.doAnswer (org.mockito.Mockito.doAnswer)19 Publisher.from (io.servicetalk.concurrent.api.Publisher.from)18 Arrays.asList (java.util.Arrays.asList)18 PlatformDependent.throwException (io.servicetalk.utils.internal.PlatformDependent.throwException)16 ArrayList (java.util.ArrayList)16 List (java.util.List)16 Function (java.util.function.Function)16 Mockito.verify (org.mockito.Mockito.verify)16