@Test public void nullThrowable() { NonoProcessor ms = NonoProcessor.create(); TestSubscriber<Void> ts = ms.test(); ms.onError(null); ts.assertFailure(NullPointerException.class); }
@Test public void once() { NonoProcessor ms = NonoProcessor.create(); TestSubscriber<Void> ts = ms.test(); ms.onComplete(); List<Throwable> errors = TestHelper.trackPluginErrors(); try { ms.onError(new IOException()); TestHelper.assertUndeliverable(errors, 0, IOException.class); } finally { RxJavaPlugins.reset(); } ms.onComplete(); ts.assertResult(); }
@Test public void crossCancelError() { final TestSubscriber<Void> ts1 = new TestSubscriber<Void>(); TestSubscriber<Void> ts2 = new TestSubscriber<Void>() { @Override public void onError(Throwable t) { super.onError(t); ts1.cancel(); } }; NonoProcessor np = NonoProcessor.create(); np.subscribe(ts2); np.subscribe(ts1); np.onError(new IOException()); ts1.assertEmpty(); ts2.assertFailure(IOException.class); } }
@Test public void error() { NonoProcessor ms = NonoProcessor.create(); assertFalse(ms.hasComplete()); assertFalse(ms.hasThrowable()); assertNull(ms.getThrowable()); assertFalse(ms.hasSubscribers()); assertEquals(0, ms.subscriberCount()); TestSubscriber<Void> ts = ms.test(); ts.assertEmpty(); assertTrue(ms.hasSubscribers()); assertEquals(1, ms.subscriberCount()); ms.onError(new IOException()); assertFalse(ms.hasComplete()); assertTrue(ms.hasThrowable()); assertTrue(ms.getThrowable().toString(), ms.getThrowable() instanceof IOException); assertFalse(ms.hasSubscribers()); assertEquals(0, ms.subscriberCount()); ts.assertFailure(IOException.class); ms.test().assertFailure(IOException.class); assertFalse(ms.hasComplete()); assertTrue(ms.hasThrowable()); assertTrue(ms.getThrowable().toString(), ms.getThrowable() instanceof IOException); assertFalse(ms.hasSubscribers()); assertEquals(0, ms.subscriberCount()); }