@Test public void testSettingRetryIntervalWillAffectRetryBehavior() throws Exception { ThreadPoolExecutor executorService = mock(ThreadPoolExecutor.class); AsyncHttpClientConfig clientConfig = mock(AsyncHttpClientConfig.class); when(clientConfig.executorService()).thenReturn(executorService); AsyncHttpClientConfig.Builder configBuilder = mock(AsyncHttpClientConfig.Builder.class); when(configBuilder.build()).thenReturn(clientConfig); client = new ParsecAsyncHttpClient.Builder(configBuilder) .setRetryIntervalInMilliSeconds(100) .build(); ParsecAsyncHttpRequest request = new ParsecAsyncHttpRequest.Builder() .setCriticalGet(true) .setUrl(baseUrl + "/sleep/25") .addRetryException(TimeoutException.class) .setRequestTimeout(10) .setMaxRetries(2) .build(); CompletableFuture completableFuture = client.execute(request); assertNotNull(completableFuture); assertTrue(completableFuture instanceof ParsecCompletableFuture); ArgumentCaptor<ParsecHttpRequestRetryCallable> argumentCaptor = ArgumentCaptor.forClass(ParsecHttpRequestRetryCallable.class); verify(executorService, times(1)).submit(argumentCaptor.capture()); ParsecHttpRequestRetryCallable retryCallable = argumentCaptor.getValue(); assertEquals(100, retryCallable.getRetryDelayer().getRetryIntervalMillis()); }
public List<CompletableFuture<Response>> execute( final List<ParsecAsyncHttpRequest> requests ) throws ExecutionException { List<CompletableFuture<Response>> futures = new ArrayList<>(); for (ParsecAsyncHttpRequest request : requests) { futures.add(execute(request)); } return futures; }
ParsecAsyncHttpClient { public List<CompletableFuture<Response>> execute( final List<ParsecAsyncHttpRequest> requests ) throws ExecutionException { List<CompletableFuture<Response>> futures = new ArrayList<>(); for (ParsecAsyncHttpRequest request : requests) { futures.add(execute(request)); } return futures; } }
ParsecAsyncHttpClient { public List<CompletableFuture<Response>> execute( final List<ParsecAsyncHttpRequest> requests ) throws ExecutionException { List<CompletableFuture<Response>> futures = new ArrayList<>(); for (ParsecAsyncHttpRequest request : requests) { futures.add(execute(request)); } return futures; } ParsecAsyncHttpClient(); private  ParsecAsyncHttpClient(final Builder builder); private  ParsecAsyncHttpClient(
        final AsyncHttpClientConfig.Builder ningClientConfigBuilder,
        int cacheRefreshAfterWrite,
        int cacheExpireAfterWrite,
        int cacheMaximumSize,
        boolean enableProfilingFilter,
        boolean recordCacheStats,
        Optional<Long> retryIntervalMillisOpt
    ); }
ParsecAsyncHttpClient { public List<CompletableFuture<Response>> execute( final List<ParsecAsyncHttpRequest> requests ) throws ExecutionException { List<CompletableFuture<Response>> futures = new ArrayList<>(); for (ParsecAsyncHttpRequest request : requests) { futures.add(execute(request)); } return futures; } ParsecAsyncHttpClient(); private  ParsecAsyncHttpClient(final Builder builder); private  ParsecAsyncHttpClient(
        final AsyncHttpClientConfig.Builder ningClientConfigBuilder,
        int cacheRefreshAfterWrite,
        int cacheExpireAfterWrite,
        int cacheMaximumSize,
        boolean enableProfilingFilter,
        boolean recordCacheStats,
        Optional<Long> retryIntervalMillisOpt
    ); void close(); List<CompletableFuture<Response>> criticalExecute(
        final List<ParsecAsyncHttpRequest> requests); CompletableFuture<Response> criticalExecute(final ParsecAsyncHttpRequest request); CompletableFuture<T> criticalExecute(
        final ParsecAsyncHttpRequest request,
        AsyncHandler<T> asyncHandler
    ); List<CompletableFuture<Response>> execute(
        final List<ParsecAsyncHttpRequest> requests
    ); CompletableFuture<Response> execute(final ParsecAsyncHttpRequest request); CacheStats getCacheStats(); int getConnectTimeout(); int getConnectionTTL(); List<IOExceptionFilter> getIOExceptionFilters(); int getMaxConnections(); int getMaxConnectionsPerHost(); int getMaxRedirects(); int getMaxRequestRetry(); int getPooledConnectionIdleTimeout(); int getReadTimeout(); List<RequestFilter> getRequestFilters(); int getRequestTimeout(); List<ResponseFilter> getResponseFilters(); String getUserAgent(); SSLContext getSSLContext(); boolean isAcceptAnyCertificate(); boolean isAllowPoolingConnections(); boolean isAllowPoolingSslConnections(); boolean isClosed(); boolean isCompressionEnforced(); boolean isFollowRedirect(); }
ParsecAsyncHttpClient { public List<CompletableFuture<Response>> execute( final List<ParsecAsyncHttpRequest> requests ) throws ExecutionException { List<CompletableFuture<Response>> futures = new ArrayList<>(); for (ParsecAsyncHttpRequest request : requests) { futures.add(execute(request)); } return futures; } ParsecAsyncHttpClient(); private  ParsecAsyncHttpClient(final Builder builder); private  ParsecAsyncHttpClient(
        final AsyncHttpClientConfig.Builder ningClientConfigBuilder,
        int cacheRefreshAfterWrite,
        int cacheExpireAfterWrite,
        int cacheMaximumSize,
        boolean enableProfilingFilter,
        boolean recordCacheStats,
        Optional<Long> retryIntervalMillisOpt
    ); void close(); List<CompletableFuture<Response>> criticalExecute(
        final List<ParsecAsyncHttpRequest> requests); CompletableFuture<Response> criticalExecute(final ParsecAsyncHttpRequest request); CompletableFuture<T> criticalExecute(
        final ParsecAsyncHttpRequest request,
        AsyncHandler<T> asyncHandler
    ); List<CompletableFuture<Response>> execute(
        final List<ParsecAsyncHttpRequest> requests
    ); CompletableFuture<Response> execute(final ParsecAsyncHttpRequest request); CacheStats getCacheStats(); int getConnectTimeout(); int getConnectionTTL(); List<IOExceptionFilter> getIOExceptionFilters(); int getMaxConnections(); int getMaxConnectionsPerHost(); int getMaxRedirects(); int getMaxRequestRetry(); int getPooledConnectionIdleTimeout(); int getReadTimeout(); List<RequestFilter> getRequestFilters(); int getRequestTimeout(); List<ResponseFilter> getResponseFilters(); String getUserAgent(); SSLContext getSSLContext(); boolean isAcceptAnyCertificate(); boolean isAllowPoolingConnections(); boolean isAllowPoolingSslConnections(); boolean isClosed(); boolean isCompressionEnforced(); boolean isFollowRedirect();  }