Created
January 20, 2020 15:27
-
-
Save akarnokd/47b96ac10497e4edde3deb5488914636 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package servicetalk; | |
import org.reactivestreams.Publisher; | |
import org.reactivestreams.tck.*; | |
import org.testng.annotations.*; | |
import io.servicetalk.concurrent.api.*; | |
import io.servicetalk.concurrent.reactivestreams.ReactiveStreamsAdapters; | |
@Test | |
public class PublishOnOverrideTckTest extends PublisherVerification<Integer> { | |
static Executor exec; | |
static Executor exec0; | |
PublishOnOverrideTckTest() { | |
super(new TestEnvironment(25)); | |
} | |
@BeforeClass | |
public static void before() { | |
exec = Executors.newCachedThreadExecutor(); | |
exec0 = Executors.newCachedThreadExecutor(); | |
} | |
@AfterClass | |
public static void after() { | |
try { | |
exec.closeAsync().toFuture().get(); | |
} catch (Throwable ignored) { | |
} | |
try { | |
exec0.closeAsync().toFuture().get(); | |
} catch (Throwable ignored) { | |
} | |
} | |
@Override | |
public Publisher<Integer> createPublisher(long elements) { | |
return ReactiveStreamsAdapters.toReactiveStreamsPublisher( | |
io.servicetalk.concurrent.api.Publisher.from(items(elements)) | |
.publishOn(exec0) | |
.publishOnOverride(exec) | |
); | |
} | |
static Integer[] items(long count) { | |
int c = (int)count; | |
Integer[] result = new Integer[c]; | |
for (int i = 0; i < c; i++) { | |
result[i] = i; | |
} | |
return result; | |
} | |
@Override | |
public Publisher<Integer> createFailedPublisher() { | |
// TODO Auto-generated method stub | |
return null; | |
} | |
@Override | |
public long maxElementsFromPublisher() { | |
return 1024; | |
} | |
} |
Author
akarnokd
commented
Jan 20, 2020
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment