| 1 |
/* |
| 2 |
* Copyright (c) 2016-present, RxJava Contributors. |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in |
| 5 |
* compliance with the License. You may obtain a copy of the License at |
| 6 |
* |
| 7 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
* |
| 9 |
* Unless required by applicable law or agreed to in writing, software distributed under the License is |
| 10 |
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See |
| 11 |
* the License for the specific language governing permissions and limitations under the License. |
| 12 |
*/ |
| 13 |
|
| 14 |
package io.reactivex.rxjava3.tck; |
| 15 |
|
| 16 |
import java.util.concurrent.*; |
| 17 |
|
| 18 |
import org.reactivestreams.*; |
| 19 |
import org.reactivestreams.tck.*; |
| 20 |
import org.testng.annotations.Test; |
| 21 |
|
| 22 |
import io.reactivex.rxjava3.exceptions.TestException; |
| 23 |
import io.reactivex.rxjava3.processors.UnicastProcessor; |
| 24 |
|
| 25 |
@Test |
| 26 |
public class UnicastProcessorTckTest extends IdentityProcessorVerification<Integer> { |
| 27 |
|
| 28 |
public UnicastProcessorTckTest() { |
| 29 |
super(new TestEnvironment(50)); |
| 30 |
} |
| 31 |
|
| 32 |
@Override |
| 33 |
public Processor<Integer, Integer> createIdentityProcessor(int bufferSize) { |
| 34 |
UnicastProcessor<Integer> up = UnicastProcessor.create(); |
| 35 |
return new RefCountProcessor<>(up); |
| 36 |
} |
| 37 |
|
| 38 |
@Override |
| 39 |
public Publisher<Integer> createFailedPublisher() { |
| 40 |
UnicastProcessor<Integer> up = UnicastProcessor.create(); |
| 41 |
up.onError(new TestException()); |
| 42 |
return up; |
| 43 |
} |
| 44 |
|
| 45 |
@Override |
| 46 |
public ExecutorService publisherExecutorService() { |
| 47 |
return Executors.newCachedThreadPool(); |
| 48 |
} |
| 49 |
|
| 50 |
@Override |
| 51 |
public Integer createElement(int element) { |
| 52 |
return element; |
| 53 |
} |
| 54 |
|
| 55 |
@Override |
| 56 |
public long maxSupportedSubscribers() { |
| 57 |
return 1; |
| 58 |
} |
| 59 |
|
| 60 |
@Override |
| 61 |
public long maxElementsFromPublisher() { |
| 62 |
return 1024; |
| 63 |
} |
| 64 |
} |