title: RxJava 2 overriding IO scheduler in unit test
body: <p>I'm trying to test the following RxKotlin/RxJava 2 code:</p>
  
  <pre class="lang-java prettyprint-override"><code>validate(data)
      .subscribeOn(Schedulers.io())
      .observeOn(AndroidSchedulers.mainThread())
      .flatMap { ... }
  </code></pre>
  
  <p>I'm attempting to override the schedulers as follows:</p>
  
  <pre class="lang-java prettyprint-override"><code>// Runs before each test suite
  RxJavaPlugins.setInitIoSchedulerHandler { Schedulers.trampoline() }
  RxAndroidPlugins.setInitMainThreadSchedulerHandler { Schedulers.trampoline() }
  </code></pre>
  
  <p>However, I get the following error when running the test:</p>
  
  <pre class="lang-java prettyprint-override"><code>java.lang.ExceptionInInitializerError
  ...
  Caused by: java.lang.NullPointerException: Scheduler Callable result can't be null
      at io.reactivex.internal.functions.ObjectHelper.requireNonNull(ObjectHelper.java:39)
      at io.reactivex.plugins.RxJavaPlugins.applyRequireNonNull(RxJavaPlugins.java:1317)
      at io.reactivex.plugins.RxJavaPlugins.initIoScheduler(RxJavaPlugins.java:306)
      at io.reactivex.schedulers.Schedulers.&lt;clinit&gt;(Schedulers.java:84)
  </code></pre>
  
  <p>Has anyone experienced this problem? </p>
  
  <hr>
  
  <p>The test worked fine when using RxKotlin/RxJava 1 and the following scheduler overrides:</p>
  
  <pre class="lang-java prettyprint-override"><code>RxAndroidPlugins.getInstance().registerSchedulersHook(object : RxAndroidSchedulersHook() {
      override fun getMainThreadScheduler() = Schedulers.immediate()
  })
  
  RxJavaPlugins.getInstance().registerSchedulersHook(object : RxJavaSchedulersHook() {
      override fun getIOScheduler() = Schedulers.immediate()
  })
  </code></pre>