use of org.springframework.boot.web.codec.CodecCustomizer in project spring-boot by spring-projects.
the class WebFluxAutoConfigurationTests method shouldCustomizeCodecs.
@Test
void shouldCustomizeCodecs() {
this.contextRunner.withUserConfiguration(CustomCodecCustomizers.class).run((context) -> {
CodecCustomizer codecCustomizer = context.getBean("firstCodecCustomizer", CodecCustomizer.class);
assertThat(codecCustomizer).isNotNull();
then(codecCustomizer).should().customize(any(ServerCodecConfigurer.class));
});
}
use of org.springframework.boot.web.codec.CodecCustomizer in project spring-boot by spring-projects.
the class WebClientAutoConfigurationTests method shouldCustomizeClientCodecs.
@Test
void shouldCustomizeClientCodecs() {
this.contextRunner.withUserConfiguration(CodecConfiguration.class).run((context) -> {
WebClient.Builder builder = context.getBean(WebClient.Builder.class);
CodecCustomizer codecCustomizer = context.getBean(CodecCustomizer.class);
WebClientCodecCustomizer clientCustomizer = context.getBean(WebClientCodecCustomizer.class);
builder.build();
assertThat(clientCustomizer).isNotNull();
then(codecCustomizer).should().customize(any(CodecConfigurer.class));
});
}
use of org.springframework.boot.web.codec.CodecCustomizer in project spring-boot by spring-projects.
the class ReactiveMultipartAutoConfigurationTests method shouldConfigureMultipartProperties.
@Test
void shouldConfigureMultipartProperties() {
this.contextRunner.withPropertyValues("spring.webflux.multipart.streaming:true", "spring.webflux.multipart.max-in-memory-size=1GB", "spring.webflux.multipart.max-headers-size=16KB", "spring.webflux.multipart.max-disk-usage-per-part=100MB", "spring.webflux.multipart.max-parts=7", "spring.webflux.multipart.headers-charset:UTF_16").run((context) -> {
CodecCustomizer customizer = context.getBean(CodecCustomizer.class);
DefaultServerCodecConfigurer configurer = new DefaultServerCodecConfigurer();
customizer.customize(configurer);
DefaultPartHttpMessageReader partReader = getPartReader(configurer);
assertThat(partReader).hasFieldOrPropertyWithValue("streaming", true);
assertThat(partReader).hasFieldOrPropertyWithValue("maxParts", 7);
assertThat(partReader).hasFieldOrPropertyWithValue("maxHeadersSize", Math.toIntExact(DataSize.ofKilobytes(16).toBytes()));
assertThat(partReader).hasFieldOrPropertyWithValue("headersCharset", StandardCharsets.UTF_16);
assertThat(partReader).hasFieldOrPropertyWithValue("maxInMemorySize", Math.toIntExact(DataSize.ofGigabytes(1).toBytes()));
assertThat(partReader).hasFieldOrPropertyWithValue("maxDiskUsagePerPart", DataSize.ofMegabytes(100).toBytes());
});
}
use of org.springframework.boot.web.codec.CodecCustomizer in project spring-boot by spring-projects.
the class CodecsAutoConfigurationTests method loggingRequestDetailsCustomizerShouldUseHttpProperties.
@Test
void loggingRequestDetailsCustomizerShouldUseHttpProperties() {
this.contextRunner.withPropertyValues("spring.codec.log-request-details=true").run((context) -> {
CodecCustomizer customizer = context.getBean(CodecCustomizer.class);
CodecConfigurer configurer = new DefaultClientCodecConfigurer();
customizer.customize(configurer);
assertThat(configurer.defaultCodecs()).hasFieldOrPropertyWithValue("enableLoggingRequestDetails", true);
});
}
use of org.springframework.boot.web.codec.CodecCustomizer in project spring-boot by spring-projects.
the class CodecsAutoConfigurationTests method maxInMemorySizeEnforcedInDefaultCodecs.
@Test
void maxInMemorySizeEnforcedInDefaultCodecs() {
this.contextRunner.withPropertyValues("spring.codec.max-in-memory-size=1MB").run((context) -> {
CodecCustomizer customizer = context.getBean(CodecCustomizer.class);
CodecConfigurer configurer = new DefaultClientCodecConfigurer();
customizer.customize(configurer);
assertThat(configurer.defaultCodecs()).hasFieldOrPropertyWithValue("maxInMemorySize", 1048576);
});
}
Aggregations