/************************************************************************
* Licensed under Public Domain (CC0) *
* *
* To the extent possible under law, the person who associated CC0 with *
* this code has waived all copyright and related or neighboring *
* rights to this code. *
* *
* You should have received a copy of the CC0 legalcode along with this *
* work. If not, see .*
************************************************************************/
package org.reactivestreams.tck.flow;
import java.util.concurrent.Flow;
import java.util.concurrent.Flow.Publisher;
import org.reactivestreams.FlowAdapters;
import org.reactivestreams.example.unicast.AsyncIterablePublisher;
import org.reactivestreams.tck.TestEnvironment;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.util.Collections;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Test
public class SingleElementFlowPublisherTest extends FlowPublisherVerification {
private ExecutorService ex;
public SingleElementFlowPublisherTest() {
super(new TestEnvironment());
}
@BeforeClass
void before() { ex = Executors.newFixedThreadPool(4); }
@AfterClass
void after() { if (ex != null) ex.shutdown(); }
@Override
public Flow.Publisher createFlowPublisher(long elements) {
return FlowAdapters.toFlowPublisher(new AsyncIterablePublisher(Collections.singleton(1), ex));
}
@Override
public Publisher createFailedFlowPublisher() {
return null;
}
@Override
public long maxElementsFromPublisher() {
return 1;
}
}