rest-assured / rest-assured

Java DSL for easy testing of REST services

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not able to define a retry strategy when test returns http 503

rejish83 opened this issue · comments

Hi,
We are currently using rest assured version 5.3.1. for our API testing.
We would like to define a retry strategy for our rest-assured calls when test returns http 503 status code.

Did below changes

HttpClientConfig httpClientConfig = HttpClientConfig.httpClientConfig()
                                                            .setParam("http.connection.timeout",
                                                                      Duration.ofSeconds(30)
                                                                              .toMillis())
                                                            .setParam("http.socket.timeout",
                                                                      Duration.ofSeconds(30)
                                                                              .toMillis())
                                                            .setParam("http.connection-manager.timeout",
                                                                      Duration.ofSeconds(30)
                                                                              .toMillis())
                                                            .httpClientFactory(() -> HttpClientBuilder
                                                                    .create()
                                                                    .setServiceUnavailableRetryStrategy(
                                                                            new DefaultServiceUnavailableRetryStrategy())
                                                                    .build());

         config = RestAssured.config().httpClient(httpClientConfig);

Observed below error:

org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'org.apache.http.impl.client.InternalHttpClient@af9a89f' with class 'org.apache.http.impl.client.InternalHttpClient' to class 'org.apache.http.impl.client.AbstractHttpClient'

PS: Observed similar issue being reported in older post #497. but still would like to know, if we already have a fix or any work around is possible.

Thanks in advance.