|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2022 the original author or authors. |
|
|
|
* Copyright 2002-2023 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -32,11 +32,13 @@ public class ByteArrayHttpMessageConverterTests { |
|
|
|
|
|
|
|
|
|
|
|
private ByteArrayHttpMessageConverter converter; |
|
|
|
private ByteArrayHttpMessageConverter converter; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@BeforeEach |
|
|
|
@BeforeEach |
|
|
|
public void setUp() { |
|
|
|
public void setUp() { |
|
|
|
converter = new ByteArrayHttpMessageConverter(); |
|
|
|
converter = new ByteArrayHttpMessageConverter(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void canRead() { |
|
|
|
public void canRead() { |
|
|
|
assertThat(converter.canRead(byte[].class, new MediaType("application", "octet-stream"))).isTrue(); |
|
|
|
assertThat(converter.canRead(byte[].class, new MediaType("application", "octet-stream"))).isTrue(); |
|
|
|
@ -73,10 +75,8 @@ public class ByteArrayHttpMessageConverterTests { |
|
|
|
byte[] body = new byte[]{0x1, 0x2}; |
|
|
|
byte[] body = new byte[]{0x1, 0x2}; |
|
|
|
converter.write(body, null, outputMessage); |
|
|
|
converter.write(body, null, outputMessage); |
|
|
|
assertThat(outputMessage.getBodyAsBytes()).as("Invalid result").isEqualTo(body); |
|
|
|
assertThat(outputMessage.getBodyAsBytes()).as("Invalid result").isEqualTo(body); |
|
|
|
assertThat(outputMessage.getHeaders().getContentType()) |
|
|
|
assertThat(outputMessage.getHeaders().getContentType()).isEqualTo(MediaType.APPLICATION_OCTET_STREAM); |
|
|
|
.as("Invalid content-type").isEqualTo(MediaType.APPLICATION_OCTET_STREAM); |
|
|
|
assertThat(outputMessage.getHeaders().getContentLength()).isEqualTo(2); |
|
|
|
assertThat(outputMessage.getHeaders().getContentLength()) |
|
|
|
|
|
|
|
.as("Invalid content-length").isEqualTo(2); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|