Search code examples
timeoutlarge-datarest-assuredweb-api-testing

How to add wait-time to complete a request and get the response in Rest-Assured


I am trying to do an upload via api, when the data is small eg:100 rows the upload works fine and I get the response as expected but when the upload is large, eg:1M rows, the test fails with Time-out-exception. How can I handle this? Is Thread.sleep() a recommended method?


Solution

  • You can use like this. if it is not working, please provide code.

    RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(5000).setConnectionRequestTimeout(5000)
                    .setSocketTimeout(5000).build();
    
            HttpClientConfig httpClientFactory = HttpClientConfig.httpClientConfig()
                    .httpClientFactory(() -> HttpClientBuilder.create().setDefaultRequestConfig(requestConfig).build());
    
            RestAssured.config = RestAssured.config().httpClient(httpClientFactory);