|
|
|
|
@ -14,7 +14,7 @@
@@ -14,7 +14,7 @@
|
|
|
|
|
* limitations under the License. |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
package org.springframework.boot.autoconfigure.http.codec; |
|
|
|
|
package org.springframework.boot.http.codec.autoconfigure; |
|
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
@ -22,8 +22,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@@ -22,8 +22,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigurations; |
|
|
|
|
import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext; |
|
|
|
|
import org.springframework.boot.test.context.runner.WebApplicationContextRunner; |
|
|
|
|
import org.springframework.boot.test.context.assertj.AssertableApplicationContext; |
|
|
|
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner; |
|
|
|
|
import org.springframework.boot.web.codec.CodecCustomizer; |
|
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
|
@ -42,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@@ -42,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
*/ |
|
|
|
|
class CodecsAutoConfigurationTests { |
|
|
|
|
|
|
|
|
|
private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() |
|
|
|
|
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() |
|
|
|
|
.withConfiguration(AutoConfigurations.of(CodecsAutoConfiguration.class)); |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@ -51,13 +51,6 @@ class CodecsAutoConfigurationTests {
@@ -51,13 +51,6 @@ class CodecsAutoConfigurationTests {
|
|
|
|
|
.hasFieldOrPropertyWithValue("enableLoggingRequestDetails", false)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void loggingRequestDetailsCustomizerShouldUseCodecProperties() { |
|
|
|
|
this.contextRunner.withPropertyValues("spring.codec.log-request-details=true") |
|
|
|
|
.run((context) -> assertThat(defaultCodecs(context)) |
|
|
|
|
.hasFieldOrPropertyWithValue("enableLoggingRequestDetails", true)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void loggingRequestDetailsCustomizerShouldUseHttpCodecsProperties() { |
|
|
|
|
this.contextRunner.withPropertyValues("spring.http.codecs.log-request-details=true") |
|
|
|
|
@ -65,21 +58,6 @@ class CodecsAutoConfigurationTests {
@@ -65,21 +58,6 @@ class CodecsAutoConfigurationTests {
|
|
|
|
|
.hasFieldOrPropertyWithValue("enableLoggingRequestDetails", true)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void logRequestDetailsShouldGivePriorityToHttpCodecProperty() { |
|
|
|
|
this.contextRunner |
|
|
|
|
.withPropertyValues("spring.http.codecs.log-request-details=true", "spring.codec.log-request-details=false") |
|
|
|
|
.run((context) -> assertThat(defaultCodecs(context)) |
|
|
|
|
.hasFieldOrPropertyWithValue("enableLoggingRequestDetails", true)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void maxInMemorySizeShouldUseCodecProperties() { |
|
|
|
|
this.contextRunner.withPropertyValues("spring.codec.max-in-memory-size=64KB") |
|
|
|
|
.run((context) -> assertThat(defaultCodecs(context)).hasFieldOrPropertyWithValue("maxInMemorySize", |
|
|
|
|
64 * 1024)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void maxInMemorySizeShouldUseHttpCodecProperties() { |
|
|
|
|
this.contextRunner.withPropertyValues("spring.http.codecs.max-in-memory-size=64KB") |
|
|
|
|
@ -87,14 +65,6 @@ class CodecsAutoConfigurationTests {
@@ -87,14 +65,6 @@ class CodecsAutoConfigurationTests {
|
|
|
|
|
64 * 1024)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void maxInMemorySizeShouldGivePriorityToHttpCodecProperty() { |
|
|
|
|
this.contextRunner |
|
|
|
|
.withPropertyValues("spring.http.codecs.max-in-memory-size=64KB", "spring.codec.max-in-memory-size=32KB") |
|
|
|
|
.run((context) -> assertThat(defaultCodecs(context)).hasFieldOrPropertyWithValue("maxInMemorySize", |
|
|
|
|
64 * 1024)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void defaultCodecCustomizerBeanShouldHaveOrderZero() { |
|
|
|
|
this.contextRunner |
|
|
|
|
@ -124,12 +94,12 @@ class CodecsAutoConfigurationTests {
@@ -124,12 +94,12 @@ class CodecsAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void maxInMemorySizeEnforcedInDefaultCodecs() { |
|
|
|
|
this.contextRunner.withPropertyValues("spring.codec.max-in-memory-size=1MB") |
|
|
|
|
this.contextRunner.withPropertyValues("spring.http.codecs.max-in-memory-size=1MB") |
|
|
|
|
.run((context) -> assertThat(defaultCodecs(context)).hasFieldOrPropertyWithValue("maxInMemorySize", |
|
|
|
|
1048576)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private DefaultCodecs defaultCodecs(AssertableWebApplicationContext context) { |
|
|
|
|
private DefaultCodecs defaultCodecs(AssertableApplicationContext context) { |
|
|
|
|
CodecCustomizer customizer = context.getBean(CodecCustomizer.class); |
|
|
|
|
CodecConfigurer configurer = new DefaultClientCodecConfigurer(); |
|
|
|
|
customizer.customize(configurer); |