Search in sources :

Example 16 with io.reactivex.rxjava3.functions

use of io.reactivex.rxjava3.functions in project RxJava by ReactiveX.

the class ParallelSortedJoinTest method error3.

@Test
public void error3() {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        Flowable.<Integer>error(new TestException()).parallel().sorted(Functions.<Integer>naturalComparator()).test(0).assertFailure(TestException.class);
        assertTrue(errors.isEmpty());
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 17 with io.reactivex.rxjava3.functions

use of io.reactivex.rxjava3.functions in project RxJava by ReactiveX.

the class ParallelSortedJoinTest method error.

@Test
public void error() {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        Flowable.<Integer>error(new TestException()).parallel().sorted(Functions.<Integer>naturalComparator()).test().assertFailure(TestException.class);
        assertTrue(errors.isEmpty());
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 18 with io.reactivex.rxjava3.functions

use of io.reactivex.rxjava3.functions in project RxJava by ReactiveX.

the class TestObserverTest method assertError.

@Test
public void assertError() {
    TestObserver<Integer> to = TestObserver.create();
    try {
        to.assertError(TestException.class);
        throw new RuntimeException("Should have thrown");
    } catch (AssertionError ex) {
    // expected
    }
    try {
        to.assertError(new TestException());
        throw new RuntimeException("Should have thrown");
    } catch (AssertionError ex) {
    // expected
    }
    try {
        to.assertError(Functions.<Throwable>alwaysTrue());
        throw new RuntimeException("Should have thrown");
    } catch (AssertionError ex) {
    // expected
    }
    try {
        to.assertSubscribed();
        throw new RuntimeException("Should have thrown");
    } catch (AssertionError exc) {
    // expected
    }
    to.onSubscribe(Disposable.empty());
    to.assertSubscribed();
    to.assertNoErrors();
    TestException ex = new TestException("Forced failure");
    to.onError(ex);
    to.assertError(ex);
    to.assertError(TestException.class);
    to.assertError(Functions.<Throwable>alwaysTrue());
    to.assertError(new Predicate<Throwable>() {

        @Override
        public boolean test(Throwable t) throws Exception {
            return t.getMessage() != null && t.getMessage().contains("Forced");
        }
    });
    try {
        to.assertError(new RuntimeException());
        throw new RuntimeException("Should have thrown");
    } catch (AssertionError exc) {
    // expected
    }
    try {
        to.assertError(IOException.class);
        throw new RuntimeException("Should have thrown");
    } catch (AssertionError exc) {
    // expected
    }
    try {
        to.assertError(Functions.<Throwable>alwaysFalse());
        throw new RuntimeException("Should have thrown");
    } catch (AssertionError exc) {
    // expected
    }
    try {
        to.assertNoErrors();
        throw new RuntimeException("Should have thrown");
    } catch (AssertionError exc) {
    // expected
    }
    to.assertValueCount(0);
    to.assertNoValues();
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) TestException(io.reactivex.rxjava3.exceptions.TestException) IOException(java.io.IOException) Test(org.junit.Test)

Example 19 with io.reactivex.rxjava3.functions

use of io.reactivex.rxjava3.functions in project RxJava by ReactiveX.

the class TestObserverTest method assertErrorMultiple.

@Test
public void assertErrorMultiple() {
    TestObserver<Integer> to = new TestObserver<>();
    TestException e = new TestException();
    to.onError(e);
    to.onError(new TestException());
    try {
        to.assertError(TestException.class);
        throw new RuntimeException("Should have thrown!");
    } catch (AssertionError ex) {
    // expected
    }
    try {
        to.assertError(e);
        throw new RuntimeException("Should have thrown!");
    } catch (AssertionError ex) {
    // expected
    }
    try {
        to.assertError(Functions.<Throwable>alwaysTrue());
        throw new RuntimeException("Should have thrown!");
    } catch (AssertionError ex) {
    // expected
    }
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 20 with io.reactivex.rxjava3.functions

use of io.reactivex.rxjava3.functions in project RxJava by ReactiveX.

the class ConnectableFlowable method connect.

/**
 * Instructs the {@code ConnectableFlowable} to begin emitting the items from its underlying
 * {@link Flowable} to its {@link Subscriber}s.
 * <p>
 * To disconnect from a synchronous source, use the {@link #connect(io.reactivex.rxjava3.functions.Consumer)} method.
 * <dl>
 *  <dt><b>Scheduler:</b></dt>
 *  <dd>The behavior is determined by the implementor of this abstract class.</dd>
 * </dl>
 *
 * @return the subscription representing the connection
 * @see <a href="http://reactivex.io/documentation/operators/connect.html">ReactiveX documentation: Connect</a>
 */
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public final Disposable connect() {
    ConnectConsumer cc = new ConnectConsumer();
    connect(cc);
    return cc.disposable;
}
Also used : ConnectConsumer(io.reactivex.rxjava3.internal.util.ConnectConsumer)

Aggregations

Test (org.junit.Test)30 TestException (io.reactivex.rxjava3.exceptions.TestException)24 RxMethod (io.reactivex.rxjava3.validators.BaseTypeParser.RxMethod)6 IOException (java.io.IOException)6 Observable (io.reactivex.rxjava3.core.Observable)5 RxJavaTest (io.reactivex.rxjava3.core.RxJavaTest)5 BooleanSubscription (io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)4 Maps (com.google.common.collect.Maps)2 String.format (java.lang.String.format)2 ByteBuffer (java.nio.ByteBuffer)2 CharacterCodingException (java.nio.charset.CharacterCodingException)2 java.util (java.util)2 TimeUnit (java.util.concurrent.TimeUnit)2 Pattern (java.util.regex.Pattern)2 Collectors (java.util.stream.Collectors)2 Collectors.toList (java.util.stream.Collectors.toList)2 Collectors.toSet (java.util.stream.Collectors.toSet)2 org.apache.cassandra.config (org.apache.cassandra.config)2 org.apache.cassandra.cql3 (org.apache.cassandra.cql3)2 QueryProcessor.executeInternal (org.apache.cassandra.cql3.QueryProcessor.executeInternal)2