-
Notifications
You must be signed in to change notification settings - Fork 534
/
Copy pathSingleElementFlowPublisherTest.java
57 lines (45 loc) · 1.93 KB
/
SingleElementFlowPublisherTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/************************************************************************
* 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 <http://creativecommons.org/publicdomain/zero/1.0/>.*
************************************************************************/
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<Integer> {
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<Integer> createFlowPublisher(long elements) {
return FlowAdapters.toFlowPublisher(new AsyncIterablePublisher<Integer>(Collections.singleton(1), ex));
}
@Override
public Publisher<Integer> createFailedFlowPublisher() {
return null;
}
@Override
public long maxElementsFromPublisher() {
return 1;
}
}