/** * Assert that the upstream is a fuseable source. * <p>Package-private: avoid leaking the now internal fusion properties into the public API. * Use ObserverFusion to work with such tests. * @return this */ final TestObserver<T> assertFuseable() { if (qd == null) { throw new AssertionError("Upstream is not fuseable."); } return this; }
/** * Assert that the upstream is not a fuseable source. * <p>Package-private: avoid leaking the now internal fusion properties into the public API. * Use ObserverFusion to work with such tests. * @return this */ final TestObserver<T> assertNotFuseable() { if (qd != null) { throw new AssertionError("Upstream is fuseable."); } return this; }
/** * Assert that the upstream is a fuseable source. * <p>Package-private: avoid leaking the now internal fusion properties into the public API. * Use SubscriberFusion to work with such tests. * @return this */ final TestSubscriber<T> assertFuseable() { if (qs == null) { throw new AssertionError("Upstream is not fuseable."); } return this; }
/** * Assert that the upstream is not a fuseable source. * <p>Package-private: avoid leaking the now internal fusion properties into the public API. * Use SubscriberFusion to work with such tests. * @return this */ final TestSubscriber<T> assertNotFuseable() { if (qs != null) { throw new AssertionError("Upstream is fuseable."); } return this; }
FakeCall(@Nullable Response<T> response, @Nullable Throwable error) { if ((response == null) == (error == null)) { throw new AssertionError("Only one of response or error can be set."); } this.response = response; this.error = error; }
@Override public Scheduler call() throws Exception { throw new AssertionError("Default Scheduler instance should not have been evaluated"); } };
@Override public void run() throws Exception { throw new AssertionError(); } }));
@Override List<? extends CallAdapter.Factory> defaultCallAdapterFactories( @Nullable Executor callbackExecutor) { if (callbackExecutor == null) throw new AssertionError(); ExecutorCallAdapterFactory executorFactory = new ExecutorCallAdapterFactory(callbackExecutor); return Build.VERSION.SDK_INT >= 24 ? asList(CompletableFutureCallAdapterFactory.INSTANCE, executorFactory) : singletonList(executorFactory); }
private <T> void finished(Deque<T> calls, T call) { Runnable idleCallback; synchronized (this) { if (!calls.remove(call)) throw new AssertionError("Call wasn't in-flight!"); idleCallback = this.idleCallback; } boolean isRunning = promoteAndExecute(); if (!isRunning && idleCallback != null) { idleCallback.run(); } }
private static SSLSocketFactory createInsecureSslSocketFactory(TrustManager trustManager) { try { SSLContext context = Platform.get().getSSLContext(); context.init(null, new TrustManager[] {trustManager}, null); return context.getSocketFactory(); } catch (Exception e) { throw new AssertionError(e); } }
private static SSLSocketFactory newSslSocketFactory(X509TrustManager trustManager) { try { SSLContext sslContext = Platform.get().getSSLContext(); sslContext.init(null, new TrustManager[] { trustManager }, null); return sslContext.getSocketFactory(); } catch (GeneralSecurityException e) { throw new AssertionError("No System TLS", e); // The system has no TLS. Just give up. } }
public CrashDummy assertError(Class<? extends Throwable> clazz) { if (!clazz.isInstance(error)) { throw new AssertionError("Different error: " + error); } return this; }
public CrashDummy assertError(Class<? extends Throwable> clazz) { if (!clazz.isInstance(error)) { throw new AssertionError("Different error: " + error); } return this; }
ParamOverride(Class<?> clazz, int index, ParamMode mode, String name, Class<?>... arguments) { this.clazz = clazz; this.index = index; this.mode = mode; this.name = name; this.arguments = arguments; try { clazz.getMethod(name, arguments); } catch (Exception ex) { throw new AssertionError(ex); } }
public static void assertError(List<Throwable> list, int index, Class<? extends Throwable> clazz) { Throwable ex = list.get(index); if (!clazz.isInstance(ex)) { AssertionError err = new AssertionError(clazz + " expected but got " + list.get(index)); err.initCause(list.get(index)); throw err; } }
@Override public void onError(Throwable throwable) { if (!subscriberTerminated) { subscriber.onError(throwable); } else { // This should never happen! onNext handles and forwards errors automatically. Throwable broken = new AssertionError( "This should never happen! Report as a Retrofit bug with the full stacktrace."); //noinspection UnnecessaryInitCause Two-arg AssertionError constructor is 1.7+ only. broken.initCause(throwable); RxJavaPlugins.getInstance().getErrorHandler().handleError(broken); } }
private ByteString pkcs1Bytes() { try { PrivateKeyInfo privateKeyInfo = PrivateKeyInfo.getInstance(keyPair.getPrivate().getEncoded()); return ByteString.of(privateKeyInfo.parsePrivateKey().toASN1Primitive().getEncoded()); } catch (IOException e) { throw new AssertionError(e); } }
@Test//(timeout = 20000) public void testSimpleAsyncLoop() { IoScheduler ios = (IoScheduler)Schedulers.io(); int c = ios.size(); for (int i = 0; i < 200; i++) { testSimpleAsync(); int c1 = ios.size(); if (c + 60 < c1) { throw new AssertionError("Worker leak: " + c + " - " + c1); } } }
@Test//(timeout = 20000) public void testSimpleAsyncLoop() { IoScheduler ios = (IoScheduler)Schedulers.io(); int c = ios.size(); for (int i = 0; i < 200; i++) { testSimpleAsync(); int c1 = ios.size(); if (c + 60 < c1) { throw new AssertionError("Worker leak: " + c + " - " + c1); } } }
@Test public void onExceptionResumeNextPassthrough() { Maybe.error(new AssertionError()) .onExceptionResumeNext(Maybe.just(1)) .test() .assertFailure(AssertionError.class); }