Java Code Examples for io.reactivex.plugins.RxJavaPlugins#reset()

The following examples show how to use io.reactivex.plugins.RxJavaPlugins#reset() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RxJavaTestSchedulerRule.java    From Awesome-WanAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public Statement apply(Statement base, Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            RxJavaPlugins.setIoSchedulerHandler(scheduler -> mTestScheduler);
            RxJavaPlugins.setComputationSchedulerHandler(scheduler -> mTestScheduler);
            RxJavaPlugins.setNewThreadSchedulerHandler(scheduler -> mTestScheduler);
            RxAndroidPlugins.setMainThreadSchedulerHandler(scheduler -> mTestScheduler);

            try {
                base.evaluate();
            } finally {
                RxJavaPlugins.reset();
                RxAndroidPlugins.reset();
            }
        }
    };
}
 
Example 2
Source File: RxSchedulersOverrideRule.java    From incubator-taverna-mobile with Apache License 2.0 6 votes vote down vote up
@Override
public Statement apply(final Statement base, Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            RxAndroidPlugins.reset();
            RxAndroidPlugins.setInitMainThreadSchedulerHandler(mRxAndroidSchedulersHook);

            RxJavaPlugins.reset();
            RxJavaPlugins.setIoSchedulerHandler(mRxJavaImmediateScheduler);
            RxJavaPlugins.setNewThreadSchedulerHandler(mRxJavaImmediateScheduler);

            base.evaluate();

            RxAndroidPlugins.reset();
            RxJavaPlugins.reset();
        }
    };
}
 
Example 3
Source File: TestSchedulerRule.java    From resilience4j with Apache License 2.0 6 votes vote down vote up
@Override
public Statement apply(final Statement statement, Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            RxJavaPlugins.setIoSchedulerHandler(scheduler -> testScheduler);
            RxJavaPlugins.setComputationSchedulerHandler(scheduler -> testScheduler);
            RxJavaPlugins.setNewThreadSchedulerHandler(scheduler -> testScheduler);
            try {
                statement.evaluate();
            } finally {
                RxJavaPlugins.reset();
            }
        }
    };
}
 
Example 4
Source File: RxSchedulerRule.java    From MovieGuide with MIT License 6 votes vote down vote up
@Override
public Statement apply(final Statement base, Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            RxAndroidPlugins.reset();
            RxAndroidPlugins.setInitMainThreadSchedulerHandler(schedulerFunctionLazy);

            RxJavaPlugins.reset();
            RxJavaPlugins.setIoSchedulerHandler(schedulerFunction);
            RxJavaPlugins.setNewThreadSchedulerHandler(schedulerFunction);
            RxJavaPlugins.setComputationSchedulerHandler(schedulerFunction);

            base.evaluate();

            RxAndroidPlugins.reset();
            RxJavaPlugins.reset();
        }
    };
}
 
Example 5
Source File: FlowableCollectWhileTest.java    From rxjava2-extras with Apache License 2.0 6 votes vote down vote up
@Test
public void testDoesNotTwoErrorsIfUpstreamDoesNotHonourCancellationImmediately() {
    try {
        List<Throwable> list = new CopyOnWriteArrayList<Throwable>();
        RxJavaPlugins.setErrorHandler(Consumers.addTo(list));
        Burst.items(1).error(new ThrowingException())//
                .compose(Transformers. //
                        collectWhile( //
                                Callables.<List<Integer>>constant(Lists.<Integer>newArrayList()), ADD, //
                                BiPredicates.throwing())) //
                .test() //
                .assertNoValues() //
                .assertError(ThrowingException.class);
        assertEquals(1, list.size());
        System.out.println(list.get(0));
        assertTrue(list.get(0) instanceof UndeliverableException);
        assertTrue(list.get(0).getCause() instanceof ThrowingException);
    } finally {
        RxJavaPlugins.reset();
    }
}
 
Example 6
Source File: RxJavaRuler.java    From Awesome-WanAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public Statement apply(Statement base, Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            RxJavaPlugins.reset();
            RxJavaPlugins.setIoSchedulerHandler(scheduler -> Schedulers.trampoline());
            RxAndroidPlugins.reset();
            RxAndroidPlugins.setMainThreadSchedulerHandler(scheduler -> Schedulers.trampoline());
            base.evaluate();
        }
    };
}
 
Example 7
Source File: FlowableStateMachineTest.java    From rxjava2-extras with Apache License 2.0 5 votes vote down vote up
@Test
public void testPassThroughEmitterErrorAfterCompletion() {
    List<Throwable> list = new CopyOnWriteArrayList<Throwable>();
    try {
        RxJavaPlugins.setErrorHandler(Consumers.addTo(list));
        FlowableTransformer<Integer, Integer> sm = StateMachine2.builder() //
                .initialState("") //
                .transition(PASS_THROUGH_TRANSITION) //
                .completion(new Completion2<String, Integer>() {
                    @Override
                    public void accept(String state, Emitter<Integer> emitter) {
                        emitter.onComplete_();
                        emitter.onError_(new ThrowingException());
                    }
                }) //
                .requestBatchSize(1) //
                .build();

        Flowable.just(1, 2, 3, 4, 5, 6) //
                .compose(sm) //
                .test() //
                .assertValues(1, 2, 3, 4, 5, 6) //
                .assertComplete();
        assertEquals(1, list.size());
    } finally {
        RxJavaPlugins.reset();
    }

}
 
Example 8
Source File: RxJavaRule.java    From My-MVP with Apache License 2.0 5 votes vote down vote up
@Override
public Statement apply(final Statement base, Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            RxJavaPlugins.reset();
            RxJavaPlugins.setIoSchedulerHandler(scheduler -> Schedulers.trampoline());
            RxAndroidPlugins.reset();
            RxAndroidPlugins.setMainThreadSchedulerHandler(scheduler -> Schedulers.trampoline());

            base.evaluate();
        }
    };
}
 
Example 9
Source File: CoreConnectionManagerTest.java    From RxCentralBle with Apache License 2.0 4 votes vote down vote up
@After
public void after() {
  RxJavaPlugins.reset();
}
 
Example 10
Source File: RxJavaHooksUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
@After
public void reset() {
    initHookCalled = false;
    hookCalled = false;
    RxJavaPlugins.reset();
}
 
Example 11
Source File: CurrentTraceContextAssemblyTrackingMatrixTest.java    From brave with Apache License 2.0 4 votes vote down vote up
@Before public void setup() {
  RxJavaPlugins.reset();
  CurrentTraceContextAssemblyTracking.create(currentTraceContext).enable();
}
 
Example 12
Source File: CurrentTraceContextAssemblyTrackingTest.java    From brave with Apache License 2.0 4 votes vote down vote up
@Before public void setup() {
  RxJavaPlugins.reset();
  CurrentTraceContextAssemblyTracking.create(currentTraceContext).enable();
}
 
Example 13
Source File: RxJavaSchedulersTestRule.java    From RxBus with Apache License 2.0 4 votes vote down vote up
private void resetPlugins() {
    RxJavaPlugins.reset();
    RxAndroidPlugins.reset();
}
 
Example 14
Source File: HookThrowing.java    From akarnokd-misc with Apache License 2.0 4 votes vote down vote up
@After
public void after() {
    RxJavaPlugins.reset();
}
 
Example 15
Source File: WriteTest.java    From RxCentralBle with Apache License 2.0 4 votes vote down vote up
@After
public void after() {
  RxJavaPlugins.reset();
}
 
Example 16
Source File: RequestMtuTest.java    From RxCentralBle with Apache License 2.0 4 votes vote down vote up
@After
public void after() {
  RxJavaPlugins.reset();
}
 
Example 17
Source File: RegisterNotificationTest.java    From RxCentralBle with Apache License 2.0 4 votes vote down vote up
@After
public void after() {
  RxJavaPlugins.reset();
}
 
Example 18
Source File: ReadRssiTest.java    From RxCentralBle with Apache License 2.0 4 votes vote down vote up
@After
public void after() {
  RxJavaPlugins.reset();
}
 
Example 19
Source File: RssiScanMatcherTest.java    From RxCentralBle with Apache License 2.0 4 votes vote down vote up
@After
public void after() {
  RxJavaPlugins.reset();
}
 
Example 20
Source File: RxJavaRules.java    From Varis-Android with Apache License 2.0 4 votes vote down vote up
private void resetSchedulers() {
    RxAndroidPlugins.reset();
    RxJavaPlugins.reset();
}