@ -237,14 +237,15 @@ public class TestRestTemplateTests {
}
}
@Test
@Test
public void withBasicAuth DoesNotResetErrorHandler( ) {
public void withBasicAuth ShouldUseNoOpErrorHandler( ) throws Exception {
TestRestTemplate originalTemplate = new TestRestTemplate ( "foo" , "bar" ) ;
TestRestTemplate originalTemplate = new TestRestTemplate ( "foo" , "bar" ) ;
ResponseErrorHandler errorHandler = mock ( ResponseErrorHandler . class ) ;
ResponseErrorHandler errorHandler = mock ( ResponseErrorHandler . class ) ;
originalTemplate . getRestTemplate ( ) . setErrorHandler ( errorHandler ) ;
originalTemplate . getRestTemplate ( ) . setErrorHandler ( errorHandler ) ;
TestRestTemplate basicAuthTemplate = originalTemplate . withBasicAuth ( "user" ,
TestRestTemplate basicAuthTemplate = originalTemplate . withBasicAuth ( "user" ,
"password" ) ;
"password" ) ;
assertThat ( basicAuthTemplate . getRestTemplate ( ) . getErrorHandler ( ) )
assertThat ( basicAuthTemplate . getRestTemplate ( ) . getErrorHandler ( ) )
. isSameAs ( errorHandler ) ;
. isInstanceOf ( Class . forName (
"org.springframework.boot.test.web.client.TestRestTemplate$NoOpResponseErrorHandler" ) ) ;
}
}
@Test
@Test