use of io.reactivex.rxjava3.core.Observable in project RxJava by ReactiveX.
the class ObservableMergeWithSingleTest method onErrorMainOverflow.
@Test
public void onErrorMainOverflow() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final AtomicReference<Observer<?>> observerRef = new AtomicReference<>();
TestObserver<Integer> to = new Observable<Integer>() {
@Override
protected void subscribeActual(Observer<? super Integer> observer) {
observer.onSubscribe(Disposable.empty());
observerRef.set(observer);
}
}.mergeWith(Single.<Integer>error(new IOException())).test();
observerRef.get().onError(new TestException());
to.assertFailure(IOException.class);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.core.Observable 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.core.Observable in project RxJava by ReactiveX.
the class ObservablePublishTest method badSource.
@Test
public void badSource() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
new Observable<Integer>() {
@Override
protected void subscribeActual(Observer<? super Integer> observer) {
observer.onSubscribe(Disposable.empty());
observer.onNext(1);
observer.onComplete();
observer.onNext(2);
observer.onError(new TestException());
observer.onComplete();
}
}.publish().autoConnect().test().assertResult(1);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.core.Observable in project RxJava by ReactiveX.
the class ObservableRepeatTest method noCancelPreviousRepeat.
@Test
public void noCancelPreviousRepeat() {
final AtomicInteger counter = new AtomicInteger();
Observable<Integer> source = Observable.just(1).doOnDispose(new Action() {
@Override
public void run() throws Exception {
counter.getAndIncrement();
}
});
source.repeat(5).test().assertResult(1, 1, 1, 1, 1);
assertEquals(0, counter.get());
}
use of io.reactivex.rxjava3.core.Observable in project RxJava by ReactiveX.
the class JavadocWording method flowableDocRefersToFlowableTypes.
@Test
public void flowableDocRefersToFlowableTypes() throws Exception {
List<RxMethod> list = BaseTypeParser.parse(TestHelper.findSource("Flowable"), "Flowable");
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: Flowable doc mentions onSuccess\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.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(" Observer", jdx);
if (idx >= 0) {
if (!m.signature.contains("ObservableSource") && !m.signature.contains("Observable")) {
e.append("java.lang.RuntimeException: Flowable doc mentions Observer but not using Observable\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.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(" SingleObserver", jdx);
if (idx >= 0) {
if (!m.signature.contains("SingleSource") && !m.signature.contains("Single")) {
e.append("java.lang.RuntimeException: Flowable doc mentions SingleObserver but not using Single\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.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(" MaybeObserver", jdx);
if (idx >= 0) {
if (!m.signature.contains("MaybeSource") && !m.signature.contains("Maybe")) {
e.append("java.lang.RuntimeException: Flowable doc mentions MaybeObserver but not using Maybe\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.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(" Disposable", jdx);
if (idx >= 0) {
if (!m.signature.contains("Observable") && !m.signature.contains("ObservableSource") && !m.signature.contains("Single") && !m.signature.contains("SingleSource") && !m.signature.contains("Completable") && !m.signature.contains("CompletableSource") && !m.signature.contains("Maybe") && !m.signature.contains("MaybeSource") && !m.signature.contains("Disposable") && !m.signature.contains("void subscribe")) {
CharSequence subSequence = m.javadoc.subSequence(idx - 6, idx + 11);
if (idx < 6 || !subSequence.equals("{@link Disposable")) {
e.append("java.lang.RuntimeException: Flowable doc mentions Disposable but not using Flowable\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.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("Observable", jdx);
if (idx >= 0) {
if (!m.signature.contains("Observable")) {
e.append("java.lang.RuntimeException: Flowable doc mentions Observable but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.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("ObservableSource", jdx);
if (idx >= 0) {
if (!m.signature.contains("ObservableSource")) {
e.append("java.lang.RuntimeException: Flowable doc mentions ObservableSource but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
}
jdx = idx + 6;
} else {
break;
}
}
checkAtReturnAndSignatureMatch("Flowable", m, e, "Flowable", "Observable", "Maybe", "Single", "Completable", "ConnectableFlowable", "ParallelFlowable", "Disposable", "Iterable", "Stream", "Future", "CompletionStage");
aOrAn(e, m, "Flowable");
missingClosingDD(e, m, "Flowable", "io.reactivex.rxjava3.core");
backpressureMentionedWithoutAnnotation(e, m, "Flowable");
}
}
if (e.length() != 0) {
System.out.println(e);
fail(e.toString());
}
}
Aggregations