I'm using RestAssured 2.4.1 to test a service stack whose first service is exposed via REST.
Now, I want to test the behaviour when the backend is not responding, a situation that the REST service is supposed to detect and handle. Unfortunately, RestAssured terminates the POST request before the REST service detects the backend timeout.
How can I increase the corresponding timeout of RestAssured? I'm trying the following without success
RestAssuredConfig config = RestAssured.config();
config.getHttpClientConfig()
.setParam(ClientPNames.CONN_MANAGER_TIMEOUT, 0) // HttpConnectionManager connection return time
.setParam(CoreConnectionPNames.CONNECTION_TIMEOUT, 0) // Remote host connection time
.setParam(CoreConnectionPNames.SO_TIMEOUT, 0) ; // Remote host response time
given()
.config(config)
. ...
What exactly is timing out?
If your test is using org.junit.Test then you can set the timeout explicitly. The following sets the timeout to 60 seconds (60000 milliseconds):
You can get the actual response time from rest-assured:
I'm using RestAssured 3.0.1, but this is how I fixed this - yet globally (I actually wanted to lower the default timeout). I also use the SystemDefaultHttpClient, as I want to reuse connections (HTTP keepalive). Thus it does not fit 100%, but might give pointers.