Dead End
I started by refactoring to create a dependency injection seam [63797de]. The idea was to inject an HttpClient mock that would allow me to inspect the resulting argument to its execute() method in retrieve-Response(). To that end, I elevated the HttpClient instance to a class field initialized in the default constructor, which I now needed to make explicit. I then factored out a constructor that took an HttpClient instance as an argument and reworked the default constructor to chain to the new one, passing a fresh instance.
In writing the test to exploit the seam, I discovered that many of the methods of DefaultHttpClient and AbstractHttpClient, including the single-argument version of execute() that the code uses, are final, preventing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access