question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TestRestTemplate replaces custom HttpClients

See original GitHub issue

Spring-Boot version 1.5.2.RELEASE

Problem: When apache httpclient jar is in the classpath, TestRestTemplate replaces any HttpClient set by the user in a RestTemplate. Alseo, since the field is final there’s no way to change that, even with reflection. See this https://github.com/spring-projects/spring-boot/blob/master/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java#L127-L130.

In my case, I am building a client for mutual authentication and some headers. However, the same applications uses httpclient for other integrations, not only that, previous tests were written in RestAssured which also includes that dependency.

Is it possible to remove that validation, make it optional or just apply it if there’s no requestFactory set?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
philwebbcommented, May 14, 2018

@bvulaj Unfortunately we needed to introduce a breaking change so 2.0 was the only option.

0reactions
bvulajcommented, May 15, 2018

@philwebb Understood. Will use the workaround for now. Thanks for the response.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TestRestTemplate replaces custom HttpClients - Bountysource
Problem: When apache httpclient jar is in the classpath, TestRestTemplate replaces any HttpClient set by the user in a RestTemplate. Alseo, ...
Read more >
Using RestTemplate with Apaches HttpClient
Summary. In this blog post, we have looked at how we can easily replace the HTTP client API used by Springs. RestTemplate.
Read more >
Getting TestRestTemplate to work with https - Stack Overflow
Writing JUnit Integrtaion tests for a REST endpoint which sets secure cookies, can't get past the ResourceAccessException error. Requirement is ...
Read more >
Exploring the Spring Boot TestRestTemplate - Baeldung
Learn how to use the new TestRestTemplate in Spring Boot to test a simple ... TestRestTemplate also enables us to customize the underlying ......
Read more >
Spring RestTemplate (with Examples) - HowToDoInJava
Learn to create Spring REST client using Spring RestTemplate class ... and use a custom parser or use a string replacement function to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found