| 1 |
/************************************************************************ |
| 2 |
* Licensed under Public Domain (CC0) * |
| 3 |
* * |
| 4 |
* To the extent possible under law, the person who associated CC0 with * |
| 5 |
* this code has waived all copyright and related or neighboring * |
| 6 |
* rights to this code. * |
| 7 |
* * |
| 8 |
* You should have received a copy of the CC0 legalcode along with this * |
| 9 |
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.* |
| 10 |
************************************************************************/ |
| 11 |
|
| 12 |
package org.reactivestreams.tck.flow; |
| 13 |
|
| 14 |
import java.util.concurrent.Flow; |
| 15 |
import java.util.concurrent.Flow.Publisher; |
| 16 |
|
| 17 |
import org.reactivestreams.FlowAdapters; |
| 18 |
import org.reactivestreams.example.unicast.AsyncIterablePublisher; |
| 19 |
import org.reactivestreams.tck.TestEnvironment; |
| 20 |
import org.testng.annotations.AfterClass; |
| 21 |
import org.testng.annotations.BeforeClass; |
| 22 |
import org.testng.annotations.Test; |
| 23 |
|
| 24 |
import java.util.Collections; |
| 25 |
import java.util.concurrent.ExecutorService; |
| 26 |
import java.util.concurrent.Executors; |
| 27 |
|
| 28 |
@Test |
| 29 |
public class SingleElementFlowPublisherTest extends FlowPublisherVerification<Integer> { |
| 30 |
|
| 31 |
private ExecutorService ex; |
| 32 |
|
| 33 |
public SingleElementFlowPublisherTest() { |
| 34 |
super(new TestEnvironment()); |
| 35 |
} |
| 36 |
|
| 37 |
@BeforeClass |
| 38 |
void before() { ex = Executors.newFixedThreadPool(4); } |
| 39 |
|
| 40 |
@AfterClass |
| 41 |
void after() { if (ex != null) ex.shutdown(); } |
| 42 |
|
| 43 |
@Override |
| 44 |
public Flow.Publisher<Integer> createFlowPublisher(long elements) { |
| 45 |
return FlowAdapters.toFlowPublisher(new AsyncIterablePublisher<Integer>(Collections.singleton(1), ex)); |
| 46 |
} |
| 47 |
|
| 48 |
@Override |
| 49 |
public Publisher<Integer> createFailedFlowPublisher() { |
| 50 |
return null; |
| 51 |
} |
| 52 |
|
| 53 |
@Override |
| 54 |
public long maxElementsFromPublisher() { |
| 55 |
return 1; |
| 56 |
} |
| 57 |
} |