use of java.util.concurrent.Flow.Subscriber in project helidon by oracle.
the class MultiPartEncoderTest method testRequests.
@Test
public void testRequests() throws Exception {
MultiPartEncoder enc = MultiPartEncoder.create("boundary", MEDIA_CONTEXT.writerContext());
Multi.create(LongStream.range(1, 500).mapToObj(i -> WriteableBodyPart.builder().entity("part" + i).build())).subscribe(enc);
final CountDownLatch latch = new CountDownLatch(3);
Subscriber<DataChunk> subscriber = new Subscriber<DataChunk>() {
@Override
public void onSubscribe(final Flow.Subscription subscription) {
subscription.request(3L);
}
@Override
public void onNext(final DataChunk item) {
latch.countDown();
}
@Override
public void onComplete() {
}
@Override
public void onError(Throwable throwable) {
}
};
enc.subscribe(subscriber);
waitOnLatch(latch);
}
Aggregations