use of org.springframework.http.codec.ClientCodecConfigurer in project spring-framework by spring-projects.
the class ClientCodecConfigurerTests method cloneShouldNotBeImpactedByChangesToOriginal.
@Test
public void cloneShouldNotBeImpactedByChangesToOriginal() {
ClientCodecConfigurer clone = this.configurer.clone();
this.configurer.registerDefaults(false);
this.configurer.customCodecs().register(new Jackson2JsonEncoder());
List<HttpMessageWriter<?>> writers = findCodec(clone.getWriters(), MultipartHttpMessageWriter.class).getPartWriters();
assertThat(writers).hasSize(12);
}
use of org.springframework.http.codec.ClientCodecConfigurer in project spring-framework by spring-projects.
the class ClientCodecConfigurerTests method cloneShouldNotDropMultipartCodecs.
// gh-24194
@Test
public void cloneShouldNotDropMultipartCodecs() {
ClientCodecConfigurer clone = this.configurer.clone();
List<HttpMessageWriter<?>> writers = findCodec(clone.getWriters(), MultipartHttpMessageWriter.class).getPartWriters();
assertThat(writers).hasSize(12);
}
use of org.springframework.http.codec.ClientCodecConfigurer in project spring-framework by spring-projects.
the class ClientCodecConfigurerTests method clonedConfigurer.
@Test
public void clonedConfigurer() {
ClientCodecConfigurer clone = this.configurer.clone();
Jackson2JsonDecoder jackson2Decoder = new Jackson2JsonDecoder();
clone.defaultCodecs().serverSentEventDecoder(jackson2Decoder);
clone.defaultCodecs().multipartCodecs().encoder(new Jackson2SmileEncoder());
clone.defaultCodecs().multipartCodecs().writer(new ResourceHttpMessageWriter());
// Clone has the customizations
Decoder<?> sseDecoder = findCodec(clone.getReaders(), ServerSentEventHttpMessageReader.class).getDecoder();
List<HttpMessageWriter<?>> writers = findCodec(clone.getWriters(), MultipartHttpMessageWriter.class).getPartWriters();
assertThat(sseDecoder).isSameAs(jackson2Decoder);
assertThat(writers).hasSize(2);
// Original does not have the customizations
sseDecoder = findCodec(this.configurer.getReaders(), ServerSentEventHttpMessageReader.class).getDecoder();
writers = findCodec(this.configurer.getWriters(), MultipartHttpMessageWriter.class).getPartWriters();
assertThat(sseDecoder).isNotSameAs(jackson2Decoder);
assertThat(writers).hasSize(12);
}
Aggregations