use of cn.taketoday.http.codec.ServerCodecConfigurer in project today-framework by TAKETODAY.
the class ServerCodecConfigurerTests method cloneConfigurer.
@Test
public void cloneConfigurer() {
ServerCodecConfigurer clone = this.configurer.clone();
MultipartHttpMessageReader reader = new MultipartHttpMessageReader(new DefaultPartHttpMessageReader());
Jackson2JsonEncoder encoder = new Jackson2JsonEncoder();
clone.defaultCodecs().multipartReader(reader);
clone.defaultCodecs().serverSentEventEncoder(encoder);
// Clone has the customizations
HttpMessageReader<?> actualReader = findCodec(clone.getReaders(), MultipartHttpMessageReader.class);
ServerSentEventHttpMessageWriter actualWriter = findCodec(clone.getWriters(), ServerSentEventHttpMessageWriter.class);
assertThat(actualReader).isSameAs(reader);
assertThat(actualWriter.getEncoder()).isSameAs(encoder);
// Original does not have the customizations
actualReader = findCodec(this.configurer.getReaders(), MultipartHttpMessageReader.class);
actualWriter = findCodec(this.configurer.getWriters(), ServerSentEventHttpMessageWriter.class);
assertThat(actualReader).isNotSameAs(reader);
assertThat(actualWriter.getEncoder()).isNotSameAs(encoder);
}
use of cn.taketoday.http.codec.ServerCodecConfigurer in project today-infrastructure by TAKETODAY.
the class ServerCodecConfigurerTests method cloneConfigurer.
@Test
public void cloneConfigurer() {
ServerCodecConfigurer clone = this.configurer.clone();
MultipartHttpMessageReader reader = new MultipartHttpMessageReader(new DefaultPartHttpMessageReader());
Jackson2JsonEncoder encoder = new Jackson2JsonEncoder();
clone.defaultCodecs().multipartReader(reader);
clone.defaultCodecs().serverSentEventEncoder(encoder);
// Clone has the customizations
HttpMessageReader<?> actualReader = findCodec(clone.getReaders(), MultipartHttpMessageReader.class);
ServerSentEventHttpMessageWriter actualWriter = findCodec(clone.getWriters(), ServerSentEventHttpMessageWriter.class);
assertThat(actualReader).isSameAs(reader);
assertThat(actualWriter.getEncoder()).isSameAs(encoder);
// Original does not have the customizations
actualReader = findCodec(this.configurer.getReaders(), MultipartHttpMessageReader.class);
actualWriter = findCodec(this.configurer.getWriters(), ServerSentEventHttpMessageWriter.class);
assertThat(actualReader).isNotSameAs(reader);
assertThat(actualWriter.getEncoder()).isNotSameAs(encoder);
}
Aggregations