|
13 | 13 | * See the License for the specific language governing permissions and
|
14 | 14 | * limitations under the License.
|
15 | 15 | */
|
| 16 | + |
16 | 17 | package org.springframework.web.client;
|
17 | 18 |
|
| 19 | +import java.io.ByteArrayInputStream; |
| 20 | +import java.io.InputStream; |
| 21 | + |
18 | 22 | import org.junit.jupiter.api.Test;
|
19 |
| -import org.springframework.http.HttpHeaders; |
20 |
| -import org.springframework.http.HttpStatus; |
| 23 | + |
21 | 24 | import org.springframework.http.client.ClientHttpResponse;
|
22 | 25 |
|
23 | 26 | import static org.assertj.core.api.Assertions.assertThat;
|
24 | 27 | import static org.mockito.BDDMockito.given;
|
25 | 28 | import static org.mockito.Mockito.mock;
|
26 | 29 |
|
27 |
| -import java.io.ByteArrayInputStream; |
28 |
| -import java.io.IOException; |
29 |
| -import java.io.InputStream; |
30 |
| - |
31 | 30 | /**
|
32 |
| - * Unit tests for {MessageBodyClientHttpResponseWrapper}. |
| 31 | + * Unit tests for {@link MessageBodyClientHttpResponseWrapper}. |
33 | 32 | *
|
| 33 | + * @since 5.3.10 |
34 | 34 | * @author Yin-Jui Liao
|
35 | 35 | */
|
36 | 36 | class MessageBodyClientHttpResponseWrapperTests {
|
37 | 37 |
|
38 | 38 | private final ClientHttpResponse response = mock(ClientHttpResponse.class);
|
39 | 39 |
|
| 40 | + private final MessageBodyClientHttpResponseWrapper responseWrapper = new MessageBodyClientHttpResponseWrapper(response); |
| 41 | + |
| 42 | + |
40 | 43 | @Test
|
41 |
| - void testMessageBodyNotExist() throws IOException { |
| 44 | + void messageBodyDoesNotExist() throws Exception { |
42 | 45 | given(response.getBody()).willReturn(null);
|
43 |
| - MessageBodyClientHttpResponseWrapper responseWrapper = new MessageBodyClientHttpResponseWrapper(response); |
44 | 46 | assertThat(responseWrapper.hasEmptyMessageBody()).isTrue();
|
45 | 47 | }
|
46 | 48 |
|
47 | 49 | @Test
|
48 |
| - void testMessageBodyExist() throws IOException { |
49 |
| - String body = "Accepted request"; |
50 |
| - InputStream stream = new ByteArrayInputStream(body.getBytes()); |
| 50 | + void messageBodyExists() throws Exception { |
| 51 | + InputStream stream = new ByteArrayInputStream("content".getBytes()); |
51 | 52 | given(response.getBody()).willReturn(stream);
|
52 |
| - MessageBodyClientHttpResponseWrapper responseWrapper = new MessageBodyClientHttpResponseWrapper(response); |
53 | 53 | assertThat(responseWrapper.hasEmptyMessageBody()).isFalse();
|
54 | 54 | }
|
| 55 | + |
55 | 56 | }
|
0 commit comments