Debian Codegraph @

src/test/java/io/reactivex/rxjava3/internal/operators/completable/CompletableSubscribeOnTest.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.completable;
15
16 import static org.junit.Assert.assertTrue;
17
18 import java.util.List;
19 import java.util.concurrent.TimeUnit;
20
21 import org.junit.Test;
22
23 import io.reactivex.rxjava3.core.*;
24 import io.reactivex.rxjava3.functions.Function;
25 import io.reactivex.rxjava3.observers.TestObserver;
26 import io.reactivex.rxjava3.plugins.RxJavaPlugins;
27 import io.reactivex.rxjava3.schedulers.*;
28 import io.reactivex.rxjava3.subjects.PublishSubject;
29 import io.reactivex.rxjava3.testsupport.TestHelper;
30
31 public class CompletableSubscribeOnTest extends RxJavaTest {
32
33 @Test
34 public void normal() {
35 List<Throwable> list = TestHelper.trackPluginErrors();
36 try {
37 TestScheduler scheduler = new TestScheduler();
38
39 TestObserver<Void> to = Completable.complete()
40 .subscribeOn(scheduler)
41 .test();
42
43 scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
44
45 to.assertResult();
46
47 assertTrue(list.toString(), list.isEmpty());
48 } finally {
49 RxJavaPlugins.reset();
50 }
51 }
52
53 @Test
54 public void dispose() {
55 TestHelper.checkDisposed(PublishSubject.create().ignoreElements().subscribeOn(new TestScheduler()));
56 }
57
58 @Test
59 public void doubleOnSubscribe() {
60 TestHelper.checkDoubleOnSubscribeCompletable(new Function<Completable, CompletableSource>() {
61 @Override
62 public CompletableSource apply(Completable c) throws Exception {
63 return c.subscribeOn(Schedulers.single());
64 }
65 });
66 }
67 }