| 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.exceptions; |
| 15 |
|
| 16 |
import static org.junit.Assert.*; |
| 17 |
|
| 18 |
import java.util.List; |
| 19 |
|
| 20 |
import org.junit.*; |
| 21 |
|
| 22 |
import io.reactivex.rxjava3.core.*; |
| 23 |
import io.reactivex.rxjava3.internal.functions.Functions; |
| 24 |
import io.reactivex.rxjava3.plugins.RxJavaPlugins; |
| 25 |
import io.reactivex.rxjava3.testsupport.TestHelper; |
| 26 |
|
| 27 |
public class OnErrorNotImplementedExceptionTest extends RxJavaTest { |
| 28 |
|
| 29 |
List<Throwable> errors; |
| 30 |
|
| 31 |
@Before |
| 32 |
public void before() { |
| 33 |
errors = TestHelper.trackPluginErrors(); |
| 34 |
} |
| 35 |
|
| 36 |
@After |
| 37 |
public void after() { |
| 38 |
RxJavaPlugins.reset(); |
| 39 |
|
| 40 |
assertFalse("" + errors, errors.isEmpty()); |
| 41 |
TestHelper.assertError(errors, 0, OnErrorNotImplementedException.class); |
| 42 |
Throwable c = errors.get(0).getCause(); |
| 43 |
assertTrue("" + c, c instanceof TestException); |
| 44 |
} |
| 45 |
|
| 46 |
@Test |
| 47 |
public void flowableSubscribe0() { |
| 48 |
Flowable.error(new TestException()) |
| 49 |
.subscribe(); |
| 50 |
} |
| 51 |
|
| 52 |
@Test |
| 53 |
public void flowableSubscribe1() { |
| 54 |
Flowable.error(new TestException()) |
| 55 |
.subscribe(Functions.emptyConsumer()); |
| 56 |
} |
| 57 |
|
| 58 |
@Test |
| 59 |
public void flowableForEachWhile() { |
| 60 |
Flowable.error(new TestException()) |
| 61 |
.forEachWhile(Functions.alwaysTrue()); |
| 62 |
} |
| 63 |
|
| 64 |
@Test |
| 65 |
public void flowableBlockingSubscribe1() { |
| 66 |
Flowable.error(new TestException()) |
| 67 |
.blockingSubscribe(Functions.emptyConsumer()); |
| 68 |
} |
| 69 |
|
| 70 |
@Test |
| 71 |
public void flowableBoundedBlockingSubscribe1() { |
| 72 |
Flowable.error(new TestException()) |
| 73 |
.blockingSubscribe(Functions.emptyConsumer(), 128); |
| 74 |
} |
| 75 |
|
| 76 |
@Test |
| 77 |
public void observableSubscribe0() { |
| 78 |
Observable.error(new TestException()) |
| 79 |
.subscribe(); |
| 80 |
} |
| 81 |
|
| 82 |
@Test |
| 83 |
public void observableSubscribe1() { |
| 84 |
Observable.error(new TestException()) |
| 85 |
.subscribe(Functions.emptyConsumer()); |
| 86 |
} |
| 87 |
|
| 88 |
@Test |
| 89 |
public void observableForEachWhile() { |
| 90 |
Observable.error(new TestException()) |
| 91 |
.forEachWhile(Functions.alwaysTrue()); |
| 92 |
} |
| 93 |
|
| 94 |
@Test |
| 95 |
public void observableBlockingSubscribe1() { |
| 96 |
Observable.error(new TestException()) |
| 97 |
.blockingSubscribe(Functions.emptyConsumer()); |
| 98 |
} |
| 99 |
|
| 100 |
@Test |
| 101 |
public void singleSubscribe0() { |
| 102 |
Single.error(new TestException()) |
| 103 |
.subscribe(); |
| 104 |
} |
| 105 |
|
| 106 |
@Test |
| 107 |
public void singleSubscribe1() { |
| 108 |
Single.error(new TestException()) |
| 109 |
.subscribe(Functions.emptyConsumer()); |
| 110 |
} |
| 111 |
|
| 112 |
@Test |
| 113 |
public void maybeSubscribe0() { |
| 114 |
Maybe.error(new TestException()) |
| 115 |
.subscribe(); |
| 116 |
} |
| 117 |
|
| 118 |
@Test |
| 119 |
public void maybeSubscribe1() { |
| 120 |
Maybe.error(new TestException()) |
| 121 |
.subscribe(Functions.emptyConsumer()); |
| 122 |
} |
| 123 |
|
| 124 |
@Test |
| 125 |
public void completableSubscribe0() { |
| 126 |
Completable.error(new TestException()) |
| 127 |
.subscribe(); |
| 128 |
} |
| 129 |
|
| 130 |
@Test |
| 131 |
public void completableSubscribe1() { |
| 132 |
Completable.error(new TestException()) |
| 133 |
.subscribe(Functions.EMPTY_ACTION); |
| 134 |
} |
| 135 |
|
| 136 |
} |