Make TestRestTemplate withBasicAuth fault tolerant
It's part of TestRestTemplate's contract that it's fault tolerant. This commit aligns the behavior of `withBasicAuth` with that expectation. Closes gh-15780
This commit is contained in:
@@ -237,14 +237,15 @@ public class TestRestTemplateTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withBasicAuthDoesNotResetErrorHandler() {
|
||||
public void withBasicAuthShouldUseNoOpErrorHandler() throws Exception {
|
||||
TestRestTemplate originalTemplate = new TestRestTemplate("foo", "bar");
|
||||
ResponseErrorHandler errorHandler = mock(ResponseErrorHandler.class);
|
||||
originalTemplate.getRestTemplate().setErrorHandler(errorHandler);
|
||||
TestRestTemplate basicAuthTemplate = originalTemplate.withBasicAuth("user",
|
||||
"password");
|
||||
assertThat(basicAuthTemplate.getRestTemplate().getErrorHandler())
|
||||
.isSameAs(errorHandler);
|
||||
.isInstanceOf(Class.forName(
|
||||
"org.springframework.boot.test.web.client.TestRestTemplate$NoOpResponseErrorHandler"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user