public HeldCertificate(KeyPair keyPair, X509Certificate certificate) { if (keyPair == null) throw new NullPointerException("keyPair == null"); if (certificate == null) throw new NullPointerException("certificate == null"); this.certificate = certificate; this.keyPair = keyPair; }
/** * Creates a NullPointerException instance and sets the given Throwable as its initial cause. * @param ex the Throwable instance to use as cause, not null (not verified) * @return the created NullPointerException */ private static NullPointerException toNpe(Throwable ex) { NullPointerException npe = new NullPointerException("Actually not, but can't pass out an exception otherwise..."); npe.initCause(ex); return npe; }
@Test public void schedulePeriodicallyDirectNullRunnable() { try { getScheduler().schedulePeriodicallyDirect(null, 5, 10, TimeUnit.MILLISECONDS); fail(); } catch (NullPointerException npe) { assertEquals("run is null", npe.getMessage()); } } }
@Test public void scheduleDirectNullRunnable() { try { getScheduler().scheduleDirect(null); fail(); } catch (NullPointerException npe) { assertEquals("run is null", npe.getMessage()); } }
/** * Sets the handler that can accept cookies from incoming HTTP responses and provides cookies to * outgoing HTTP requests. * * <p>If unset, {@linkplain CookieJar#NO_COOKIES no cookies} will be accepted nor provided. */ public Builder cookieJar(CookieJar cookieJar) { if (cookieJar == null) throw new NullPointerException("cookieJar == null"); this.cookieJar = cookieJar; return this; }
@Test public void scheduleDirectWithDelayNullRunnable() { try { getScheduler().scheduleDirect(null, 10, TimeUnit.MILLISECONDS); fail(); } catch (NullPointerException npe) { assertEquals("run is null", npe.getMessage()); } }
/** * Sets the authenticator used to respond to challenges from proxy servers. Use {@link * #authenticator} to set the authenticator for origin servers. * * <p>If unset, the {@linkplain Authenticator#NONE no authentication will be attempted}. */ public Builder proxyAuthenticator(Authenticator proxyAuthenticator) { if (proxyAuthenticator == null) throw new NullPointerException("proxyAuthenticator == null"); this.proxyAuthenticator = proxyAuthenticator; return this; }
@Test public void nullActionShouldBeCheckedInConstructor() { try { Flowable.empty().doAfterTerminate(null); fail("Should have thrown NullPointerException"); } catch (NullPointerException expected) { assertEquals("onAfterTerminate is null", expected.getMessage()); } }
private CipherSuite(String javaName) { if (javaName == null) { throw new NullPointerException(); } this.javaName = javaName; }
@Test public void nullThrowable() { SingleSubject<Integer> ss = SingleSubject.create(); try { ss.onError(null); fail("No NullPointerException thrown"); } catch (NullPointerException ex) { assertEquals("onError called with null. Null values are generally not allowed in 2.x operators and sources.", ex.getMessage()); } ss.test().assertEmpty().cancel(); }
/** Change the level at which this interceptor logs. */ public HttpLoggingInterceptor setLevel(Level level) { if (level == null) throw new NullPointerException("level == null. Use Level.NONE instead."); this.level = level; return this; }
@Test public void onErrorNull() { FlowableProcessor<T> p = create(); try { p.onError(null); fail("No NullPointerException thrown"); } catch (NullPointerException ex) { assertEquals("onError called with null. Null values are generally not allowed in 2.x operators and sources.", ex.getMessage()); } p.test().assertEmpty().cancel(); } }
/** * Set the error response factory to be used when an error is triggered. This factory may only * return responses for which {@link Response#isSuccessful()} returns false. */ @SuppressWarnings("ConstantConditions") // Guarding public API nullability. public void setErrorFactory(Callable<Response<?>> errorFactory) { if (errorFactory == null) { throw new NullPointerException("errorFactory == null"); } this.errorFactory = errorFactory; }
@Test public void onNextNull() { FlowableProcessor<T> p = create(); try { p.onNext(null); fail("No NullPointerException thrown"); } catch (NullPointerException ex) { assertEquals("onNext called with null. Null values are generally not allowed in 2.x operators and sources.", ex.getMessage()); } p.test().assertEmpty().cancel(); }
@SuppressWarnings("ConstantConditions") // Guarding public API nullability. public Builder backgroundExecutor(ExecutorService executor) { if (executor == null) throw new NullPointerException("executor == null"); this.executor = executor; return this; }
@Test public void onErrorNull() { Subject<T> p = create(); try { p.onError(null); fail("No NullPointerException thrown"); } catch (NullPointerException ex) { assertEquals("onError called with null. Null values are generally not allowed in 2.x operators and sources.", ex.getMessage()); } p.test().assertEmpty().cancel(); } }
/** * Sets the dispatcher used to match incoming requests to mock responses. The default dispatcher * simply serves a fixed sequence of responses from a {@link #enqueue(MockResponse) queue}; custom * dispatchers can vary the response based on timing or the content of the request. */ public void setDispatcher(Dispatcher dispatcher) { if (dispatcher == null) throw new NullPointerException(); this.dispatcher = dispatcher; }
@Test public void nullValue() { SingleSubject<Integer> ss = SingleSubject.create(); try { ss.onSuccess(null); fail("No NullPointerException thrown"); } catch (NullPointerException ex) { assertEquals("onSuccess called with null. Null values are generally not allowed in 2.x operators and sources.", ex.getMessage()); } ss.test().assertEmpty().cancel(); }
public Builder url(HttpUrl url) { if (url == null) throw new NullPointerException("url == null"); this.url = url; return this; }
@Test public void nullThrowable() { CompletableSubject cs = CompletableSubject.create(); try { cs.onError(null); fail("No NullPointerException thrown"); } catch (NullPointerException ex) { assertEquals("onError called with null. Null values are generally not allowed in 2.x operators and sources.", ex.getMessage()); } cs.test().assertEmpty().cancel();; }