Debian Codegraph @

src/test/java/io/reactivex/rxjava3/internal/subscribers/EmptyComponentTest.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.subscribers;
15
16 import static org.junit.Assert.assertTrue;
17
18 import java.util.List;
19
20 import org.junit.Test;
21
22 import io.reactivex.rxjava3.core.RxJavaTest;
23 import io.reactivex.rxjava3.disposables.*;
24 import io.reactivex.rxjava3.exceptions.TestException;
25 import io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription;
26 import io.reactivex.rxjava3.internal.util.EmptyComponent;
27 import io.reactivex.rxjava3.plugins.RxJavaPlugins;
28 import io.reactivex.rxjava3.testsupport.TestHelper;
29
30 public class EmptyComponentTest extends RxJavaTest {
31
32 @Test
33 public void normal() {
34 List<Throwable> errors = TestHelper.trackPluginErrors();
35
36 try {
37 TestHelper.checkEnum(EmptyComponent.class);
38
39 EmptyComponent c = EmptyComponent.INSTANCE;
40
41 assertTrue(c.isDisposed());
42
43 c.request(10);
44
45 c.request(-10);
46
47 Disposable d = Disposable.empty();
48
49 c.onSubscribe(d);
50
51 assertTrue(d.isDisposed());
52
53 BooleanSubscription s = new BooleanSubscription();
54
55 c.onSubscribe(s);
56
57 assertTrue(s.isCancelled());
58
59 c.onNext(null);
60
61 c.onNext(1);
62
63 c.onComplete();
64
65 c.onError(new TestException());
66
67 c.onSuccess(2);
68
69 c.cancel();
70
71 TestHelper.assertUndeliverable(errors, 0, TestException.class);
72 } finally {
73 RxJavaPlugins.reset();
74 }
75 }
76 }