Search in sources :

Example 1 with DefaultServerCodecConfigurer

use of org.springframework.http.codec.support.DefaultServerCodecConfigurer 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());
    });
}
Also used : DefaultPartHttpMessageReader(org.springframework.http.codec.multipart.DefaultPartHttpMessageReader) CodecCustomizer(org.springframework.boot.web.codec.CodecCustomizer) DefaultServerCodecConfigurer(org.springframework.http.codec.support.DefaultServerCodecConfigurer) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 CodecCustomizer (org.springframework.boot.web.codec.CodecCustomizer)1 DefaultPartHttpMessageReader (org.springframework.http.codec.multipart.DefaultPartHttpMessageReader)1 DefaultServerCodecConfigurer (org.springframework.http.codec.support.DefaultServerCodecConfigurer)1