use of io.reactivex.rxjava3.observables.ConnectableObservable in project RxJava by ReactiveX.
the class RxJavaPluginsTest method clearIsPassthrough.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void clearIsPassthrough() {
try {
RxJavaPlugins.reset();
assertNull(RxJavaPlugins.onAssembly((Observable) null));
assertNull(RxJavaPlugins.onAssembly((ConnectableObservable) null));
assertNull(RxJavaPlugins.onAssembly((Flowable) null));
assertNull(RxJavaPlugins.onAssembly((ConnectableFlowable) null));
Observable oos = new Observable() {
@Override
public void subscribeActual(Observer t) {
}
};
Flowable fos = new Flowable() {
@Override
public void subscribeActual(Subscriber t) {
}
};
assertSame(oos, RxJavaPlugins.onAssembly(oos));
assertSame(fos, RxJavaPlugins.onAssembly(fos));
assertNull(RxJavaPlugins.onAssembly((Single) null));
Single sos = new Single() {
@Override
public void subscribeActual(SingleObserver t) {
}
};
assertSame(sos, RxJavaPlugins.onAssembly(sos));
assertNull(RxJavaPlugins.onAssembly((Completable) null));
Completable cos = new Completable() {
@Override
public void subscribeActual(CompletableObserver t) {
}
};
assertSame(cos, RxJavaPlugins.onAssembly(cos));
assertNull(RxJavaPlugins.onAssembly((Maybe) null));
Maybe myb = new Maybe() {
@Override
public void subscribeActual(MaybeObserver t) {
}
};
assertSame(myb, RxJavaPlugins.onAssembly(myb));
Runnable action = Functions.EMPTY_RUNNABLE;
assertSame(action, RxJavaPlugins.onSchedule(action));
class AllSubscriber implements Subscriber, Observer, SingleObserver, CompletableObserver, MaybeObserver {
@Override
public void onSuccess(Object value) {
}
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onSubscribe(Subscription s) {
}
@Override
public void onNext(Object t) {
}
@Override
public void onError(Throwable t) {
}
@Override
public void onComplete() {
}
}
AllSubscriber all = new AllSubscriber();
Subscriber[] allArray = { all };
assertNull(RxJavaPlugins.onSubscribe(Observable.never(), null));
assertSame(all, RxJavaPlugins.onSubscribe(Observable.never(), all));
assertNull(RxJavaPlugins.onSubscribe(Flowable.never(), null));
assertSame(all, RxJavaPlugins.onSubscribe(Flowable.never(), all));
assertNull(RxJavaPlugins.onSubscribe(Single.just(1), null));
assertSame(all, RxJavaPlugins.onSubscribe(Single.just(1), all));
assertNull(RxJavaPlugins.onSubscribe(Completable.never(), null));
assertSame(all, RxJavaPlugins.onSubscribe(Completable.never(), all));
assertNull(RxJavaPlugins.onSubscribe(Maybe.never(), null));
assertSame(all, RxJavaPlugins.onSubscribe(Maybe.never(), all));
assertNull(RxJavaPlugins.onSubscribe(Flowable.never().parallel(), null));
assertSame(allArray, RxJavaPlugins.onSubscribe(Flowable.never().parallel(), allArray));
final Scheduler s = ImmediateThinScheduler.INSTANCE;
Supplier<Scheduler> c = new Supplier<Scheduler>() {
@Override
public Scheduler get() throws Exception {
return s;
}
};
assertSame(s, RxJavaPlugins.onComputationScheduler(s));
assertSame(s, RxJavaPlugins.onIoScheduler(s));
assertSame(s, RxJavaPlugins.onNewThreadScheduler(s));
assertSame(s, RxJavaPlugins.onSingleScheduler(s));
assertSame(s, RxJavaPlugins.initComputationScheduler(c));
assertSame(s, RxJavaPlugins.initIoScheduler(c));
assertSame(s, RxJavaPlugins.initNewThreadScheduler(c));
assertSame(s, RxJavaPlugins.initSingleScheduler(c));
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.observables.ConnectableObservable in project RxJava by ReactiveX.
the class ObservableReplayEagerTruncateTest method connectConsumerThrows.
@Test
public void connectConsumerThrows() {
ConnectableObservable<Integer> co = Observable.range(1, 2).replay();
try {
co.connect(new Consumer<Disposable>() {
@Override
public void accept(Disposable t) throws Exception {
throw new TestException();
}
});
fail("Should have thrown");
} catch (TestException ex) {
// expected
}
co.test().assertEmpty().dispose();
co.connect();
co.test().assertResult(1, 2);
}
use of io.reactivex.rxjava3.observables.ConnectableObservable in project RxJava by ReactiveX.
the class ObservableReplayEagerTruncateTest method disposeNoNeedForResetTimeAndSIzeBound.
@Test
public void disposeNoNeedForResetTimeAndSIzeBound() {
PublishSubject<Integer> ps = PublishSubject.create();
ConnectableObservable<Integer> co = ps.replay(10, 10, TimeUnit.MINUTES, Schedulers.single(), true);
TestObserver<Integer> to = co.test();
Disposable d = co.connect();
ps.onNext(1);
d.dispose();
to = co.test();
to.assertEmpty();
co.connect();
to.assertEmpty();
ps.onNext(2);
to.assertValuesOnly(2);
}
use of io.reactivex.rxjava3.observables.ConnectableObservable in project RxJava by ReactiveX.
the class ObservablePublishTest method onErrorAvailableUntilReset.
@Test
public void onErrorAvailableUntilReset() {
ConnectableObservable<Integer> co = Observable.just(1).concatWith(Observable.<Integer>error(new TestException())).publish();
TestObserver<Integer> to = co.test();
to.assertEmpty();
co.connect();
to.assertFailure(TestException.class, 1);
co.test().assertFailure(TestException.class);
co.reset();
to = co.test();
to.assertEmpty();
co.connect();
to.assertFailure(TestException.class, 1);
}
use of io.reactivex.rxjava3.observables.ConnectableObservable in project RxJava by ReactiveX.
the class JavadocWording method observableDocRefersToObservableTypes.
@Test
public void observableDocRefersToObservableTypes() throws Exception {
List<RxMethod> list = BaseTypeParser.parse(TestHelper.findSource("Observable"), "Observable");
assertFalse(list.isEmpty());
StringBuilder e = new StringBuilder();
for (RxMethod m : list) {
int jdx;
if (m.javadoc != null) {
jdx = 0;
for (; ; ) {
int idx = m.javadoc.indexOf("onSuccess", jdx);
if (idx >= 0) {
if (!m.signature.contains("Maybe") && !m.signature.contains("MaybeSource") && !m.signature.contains("Single") && !m.signature.contains("SingleSource")) {
e.append("java.lang.RuntimeException: Observable doc mentions onSuccess\r\n at io.reactivex.rxjava3.core.").append("Observable.method(Observable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
}
jdx = idx + 6;
} else {
break;
}
}
jdx = 0;
for (; ; ) {
int idx = m.javadoc.indexOf(" Subscription", jdx);
if (idx >= 0) {
if (!m.signature.contains("Flowable") && !m.signature.contains("Publisher")) {
e.append("java.lang.RuntimeException: Observable doc mentions Subscription but not using Flowable\r\n at io.reactivex.rxjava3.core.").append("Observable.method(Observable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
}
jdx = idx + 6;
} else {
break;
}
}
jdx = 0;
for (; ; ) {
int idx = m.javadoc.indexOf("Flowable", jdx);
if (idx >= 0) {
if (!m.signature.contains("Flowable")) {
if (idx < 6 || !m.javadoc.substring(idx - 6, idx + 8).equals("@link Flowable")) {
e.append("java.lang.RuntimeException: Observable doc mentions Flowable but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Observable.method(Observable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
}
}
jdx = idx + 6;
} else {
break;
}
}
jdx = 0;
for (; ; ) {
int idx = m.javadoc.indexOf("Publisher", jdx);
if (idx >= 0) {
if (!m.signature.contains("Publisher")) {
e.append("java.lang.RuntimeException: Observable doc mentions Publisher but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Observable.method(Observable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
}
jdx = idx + 6;
} else {
break;
}
}
jdx = 0;
for (; ; ) {
int idx = m.javadoc.indexOf("Subscriber", jdx);
if (idx >= 0) {
if (!m.signature.contains("Publisher") && !m.signature.contains("Flowable")) {
e.append("java.lang.RuntimeException: Observable doc mentions Subscriber but not using Flowable\r\n at io.reactivex.rxjava3.core.").append("Observable.method(Observable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
}
jdx = idx + 6;
} else {
break;
}
}
checkAtReturnAndSignatureMatch("Observable", m, e, "Flowable", "Observable", "Maybe", "Single", "Completable", "ConnectableObservable", "Disposable", "Iterable", "Stream", "Future", "CompletionStage");
aOrAn(e, m, "Observable");
missingClosingDD(e, m, "Observable", "io.reactivex.rxjava3.core");
backpressureMentionedWithoutAnnotation(e, m, "Observable");
}
}
if (e.length() != 0) {
System.out.println(e);
fail(e.toString());
}
}
Aggregations