JerseyClientBuilder extends ClientBuilder { @Override public ClientBuilder connectTimeout(long timeout, TimeUnit unit) { if (timeout < 0) { throw new IllegalArgumentException("Negative timeout."); } this.property(ClientProperties.CONNECT_TIMEOUT, Math.toIntExact(unit.toMillis(timeout))); return this; } JerseyClientBuilder(); static JerseyClient createClient(); static JerseyClient createClient(Configuration configuration); @Override JerseyClientBuilder sslContext(SSLContext sslContext); @Override JerseyClientBuilder keyStore(KeyStore keyStore, char[] password); @Override JerseyClientBuilder trustStore(KeyStore trustStore); @Override JerseyClientBuilder hostnameVerifier(HostnameVerifier hostnameVerifier); @Override ClientBuilder executorService(ExecutorService executorService); @Override ClientBuilder scheduledExecutorService(ScheduledExecutorService scheduledExecutorService); @Override ClientBuilder connectTimeout(long timeout, TimeUnit unit); @Override ClientBuilder readTimeout(long timeout, TimeUnit unit); @Override JerseyClient build(); @Override ClientConfig getConfiguration(); @Override JerseyClientBuilder property(String name, Object value); @Override JerseyClientBuilder register(Class<?> componentClass); @Override JerseyClientBuilder register(Class<?> componentClass, int priority); @Override JerseyClientBuilder register(Class<?> componentClass, Class<?>... contracts); @Override JerseyClientBuilder register(Class<?> componentClass, Map<Class<?>, Integer> contracts); @Override JerseyClientBuilder register(Object component); @Override JerseyClientBuilder register(Object component, int priority); @Override JerseyClientBuilder register(Object component, Class<?>... contracts); @Override JerseyClientBuilder register(Object component, Map<Class<?>, Integer> contracts); @Override JerseyClientBuilder withConfig(Configuration config);  }
@Test public void testNegativeConnectTimeout() { ClientBuilder clientBuilder = ClientBuilder.newBuilder(); exception.expect(IllegalArgumentException.class); clientBuilder.connectTimeout(-1, TimeUnit.SECONDS); }