Debian Codegraph @

src/test/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableOnBackpressureErrorTest.java

raw
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.internal.operators.flowable;
15
16 import static org.junit.Assert.*;
17
18 import org.junit.Test;
19 import org.reactivestreams.Publisher;
20
21 import io.reactivex.rxjava3.core.*;
22 import io.reactivex.rxjava3.exceptions.MissingBackpressureException;
23 import io.reactivex.rxjava3.functions.Function;
24 import io.reactivex.rxjava3.subjects.PublishSubject;
25 import io.reactivex.rxjava3.subscribers.TestSubscriber;
26 import io.reactivex.rxjava3.testsupport.TestHelper;
27
28 public class FlowableOnBackpressureErrorTest extends RxJavaTest {
29
30 @Test
31 public void dispose() {
32 TestHelper.checkDisposed(Observable.just(1).toFlowable(BackpressureStrategy.ERROR));
33 }
34
35 @Test
36 public void badRequest() {
37 TestHelper.assertBadRequestReported(Observable.just(1).toFlowable(BackpressureStrategy.ERROR));
38 }
39
40 @Test
41 public void doubleOnSubscribe() {
42 TestHelper.checkDoubleOnSubscribeFlowable(new Function<Flowable<Object>, Publisher<Object>>() {
43 @Override
44 public Publisher<Object> apply(Flowable<Object> f) throws Exception {
45 return new FlowableOnBackpressureError<>(f);
46 }
47 });
48 }
49
50 @Test
51 public void badSource() {
52 TestHelper.<Integer>checkBadSourceFlowable(new Function<Flowable<Integer>, Object>() {
53 @Override
54 public Object apply(Flowable<Integer> f) throws Exception {
55 return new FlowableOnBackpressureError<>(f);
56 }
57 }, false, 1, 1, 1);
58 }
59
60 @Test
61 public void overflowCancels() {
62 PublishSubject<Integer> ps = PublishSubject.create();
63
64 TestSubscriber<Integer> ts = ps.toFlowable(BackpressureStrategy.ERROR)
65 .test(0L);
66
67 assertTrue(ps.hasObservers());
68
69 ps.onNext(1);
70
71 assertFalse(ps.hasObservers());
72
73 ts.assertFailure(MissingBackpressureException.class);
74 }
75 }