Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to configure read/connect timeouts for TestRestTemplate [SPR-17112] #21649

Closed
spring-projects-issues opened this issue Aug 1, 2018 · 4 comments
Labels
in: test status: invalid

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Aug 1, 2018

Igor Manushin opened SPR-17112 and commented

This jira is for TestRestTemplate class.

It is unable to simple set readTimeout/connectTimeout of it, so it is not simple to verify long-running rest services.

Possible solutions:

  • Add new property into configuration (for example - org.spring.boot.test.rest.template.default.read.timeout = ...)
  • Add ability to specify read timeout for calls (for example - add ability to override getForEntity)
  • Add ability to specify read/connect timeouts for the RestTemplate

Matched question on the stackoverflow (for rest template): https://stackoverflow.com/questions/13837012/spring-resttemplate-timeout


Affects: 5.0.8

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Aug 2, 2018

Stéphane Nicoll commented

TestRestTemplate is part of Spring Boot and this tracker doesn't manage Spring Boot issues as it has a dedicated issue tracker.

That said, there is already support for this in the very question you've linked. If you configure a RestTemplateBuilder, it will be used to build the TestRestTemplate. If you have more questions, please ask on StackOverflow.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Aug 2, 2018

Rossen Stoyanchev commented

The capability exists:

RestTemplateBuilder builder = new RestTemplateBuilder().setReadTimeout(Duration.ofSeconds(5));
TestRestTemplate testRestTemplate = new TestRestTemplate(builder);

I presume you are aware of this since there are many answers in the SO thread. So you need to explain better what you mean by not simple. The above is reasonably simple.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Aug 2, 2018

Rossen Stoyanchev commented

What Stéphane Nicoll said :)

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Aug 3, 2018

Igor Manushin commented

Agree

@spring-projects-issues spring-projects-issues added status: invalid in: test type: enhancement and removed type: enhancement labels Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test status: invalid
Projects
None yet
Development

No branches or pull requests

1 participant