Merge branch '3.3.x' into 3.4.x
Closes gh-44630
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,6 +57,7 @@ import static org.mockito.BDDMockito.then;
|
||||
* @author Phillip Webb
|
||||
* @author Mike Smithson
|
||||
* @author Scott Frederick
|
||||
* @author Moritz Halbritter
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class HttpClientTransportTests {
|
||||
@@ -309,6 +310,18 @@ class HttpClientTransportTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldReturnErrorsAndMessage() throws IOException {
|
||||
givenClientWillReturnResponse();
|
||||
given(this.entity.getContent()).willReturn(getClass().getResourceAsStream("message-and-errors.json"));
|
||||
given(this.response.getCode()).willReturn(404);
|
||||
assertThatExceptionOfType(DockerEngineException.class).isThrownBy(() -> this.http.get(this.uri))
|
||||
.satisfies((ex) -> {
|
||||
assertThat(ex.getErrors()).hasSize(2);
|
||||
assertThat(ex.getResponseMessage().getMessage()).contains("test message");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void executeWhenClientThrowsIOExceptionRethrowsAsDockerException() throws IOException {
|
||||
given(this.client.executeOpen(any(HttpHost.class), any(HttpUriRequest.class), isNull()))
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"message": "test message",
|
||||
"errors": [
|
||||
{
|
||||
"code": "TEST1",
|
||||
"message": "Test One",
|
||||
"detail": 123
|
||||
},
|
||||
{
|
||||
"code": "TEST2",
|
||||
"message": "Test Two",
|
||||
"detail": "fail"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user