Search in sources :

Example 1 with ClientCodecConfigurer

use of cn.taketoday.http.codec.ClientCodecConfigurer in project today-framework by TAKETODAY.

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(10);
}
Also used : MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) FormHttpMessageWriter(cn.taketoday.http.codec.FormHttpMessageWriter) PartEventHttpMessageWriter(cn.taketoday.http.codec.multipart.PartEventHttpMessageWriter) EncoderHttpMessageWriter(cn.taketoday.http.codec.EncoderHttpMessageWriter) HttpMessageWriter(cn.taketoday.http.codec.HttpMessageWriter) ResourceHttpMessageWriter(cn.taketoday.http.codec.ResourceHttpMessageWriter) ProtobufHttpMessageWriter(cn.taketoday.http.codec.protobuf.ProtobufHttpMessageWriter) ClientCodecConfigurer(cn.taketoday.http.codec.ClientCodecConfigurer) MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) Jackson2JsonEncoder(cn.taketoday.http.codec.json.Jackson2JsonEncoder) Test(org.junit.jupiter.api.Test)

Example 2 with ClientCodecConfigurer

use of cn.taketoday.http.codec.ClientCodecConfigurer in project today-framework by TAKETODAY.

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(10);
}
Also used : ServerSentEventHttpMessageReader(cn.taketoday.http.codec.ServerSentEventHttpMessageReader) MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) FormHttpMessageWriter(cn.taketoday.http.codec.FormHttpMessageWriter) PartEventHttpMessageWriter(cn.taketoday.http.codec.multipart.PartEventHttpMessageWriter) EncoderHttpMessageWriter(cn.taketoday.http.codec.EncoderHttpMessageWriter) HttpMessageWriter(cn.taketoday.http.codec.HttpMessageWriter) ResourceHttpMessageWriter(cn.taketoday.http.codec.ResourceHttpMessageWriter) ProtobufHttpMessageWriter(cn.taketoday.http.codec.protobuf.ProtobufHttpMessageWriter) ClientCodecConfigurer(cn.taketoday.http.codec.ClientCodecConfigurer) Jackson2JsonDecoder(cn.taketoday.http.codec.json.Jackson2JsonDecoder) Jackson2SmileEncoder(cn.taketoday.http.codec.json.Jackson2SmileEncoder) ResourceHttpMessageWriter(cn.taketoday.http.codec.ResourceHttpMessageWriter) MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) Test(org.junit.jupiter.api.Test)

Example 3 with ClientCodecConfigurer

use of cn.taketoday.http.codec.ClientCodecConfigurer in project today-framework by TAKETODAY.

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(10);
}
Also used : MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) FormHttpMessageWriter(cn.taketoday.http.codec.FormHttpMessageWriter) PartEventHttpMessageWriter(cn.taketoday.http.codec.multipart.PartEventHttpMessageWriter) EncoderHttpMessageWriter(cn.taketoday.http.codec.EncoderHttpMessageWriter) HttpMessageWriter(cn.taketoday.http.codec.HttpMessageWriter) ResourceHttpMessageWriter(cn.taketoday.http.codec.ResourceHttpMessageWriter) ProtobufHttpMessageWriter(cn.taketoday.http.codec.protobuf.ProtobufHttpMessageWriter) ClientCodecConfigurer(cn.taketoday.http.codec.ClientCodecConfigurer) MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) Test(org.junit.jupiter.api.Test)

Example 4 with ClientCodecConfigurer

use of cn.taketoday.http.codec.ClientCodecConfigurer in project today-infrastructure by TAKETODAY.

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(10);
}
Also used : ServerSentEventHttpMessageReader(cn.taketoday.http.codec.ServerSentEventHttpMessageReader) MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) FormHttpMessageWriter(cn.taketoday.http.codec.FormHttpMessageWriter) PartEventHttpMessageWriter(cn.taketoday.http.codec.multipart.PartEventHttpMessageWriter) EncoderHttpMessageWriter(cn.taketoday.http.codec.EncoderHttpMessageWriter) HttpMessageWriter(cn.taketoday.http.codec.HttpMessageWriter) ResourceHttpMessageWriter(cn.taketoday.http.codec.ResourceHttpMessageWriter) ProtobufHttpMessageWriter(cn.taketoday.http.codec.protobuf.ProtobufHttpMessageWriter) ClientCodecConfigurer(cn.taketoday.http.codec.ClientCodecConfigurer) Jackson2JsonDecoder(cn.taketoday.http.codec.json.Jackson2JsonDecoder) Jackson2SmileEncoder(cn.taketoday.http.codec.json.Jackson2SmileEncoder) ResourceHttpMessageWriter(cn.taketoday.http.codec.ResourceHttpMessageWriter) MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) Test(org.junit.jupiter.api.Test)

Example 5 with ClientCodecConfigurer

use of cn.taketoday.http.codec.ClientCodecConfigurer in project today-infrastructure by TAKETODAY.

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(10);
}
Also used : MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) FormHttpMessageWriter(cn.taketoday.http.codec.FormHttpMessageWriter) PartEventHttpMessageWriter(cn.taketoday.http.codec.multipart.PartEventHttpMessageWriter) EncoderHttpMessageWriter(cn.taketoday.http.codec.EncoderHttpMessageWriter) HttpMessageWriter(cn.taketoday.http.codec.HttpMessageWriter) ResourceHttpMessageWriter(cn.taketoday.http.codec.ResourceHttpMessageWriter) ProtobufHttpMessageWriter(cn.taketoday.http.codec.protobuf.ProtobufHttpMessageWriter) ClientCodecConfigurer(cn.taketoday.http.codec.ClientCodecConfigurer) MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) Test(org.junit.jupiter.api.Test)

Aggregations

ClientCodecConfigurer (cn.taketoday.http.codec.ClientCodecConfigurer)6 EncoderHttpMessageWriter (cn.taketoday.http.codec.EncoderHttpMessageWriter)6 FormHttpMessageWriter (cn.taketoday.http.codec.FormHttpMessageWriter)6 HttpMessageWriter (cn.taketoday.http.codec.HttpMessageWriter)6 ResourceHttpMessageWriter (cn.taketoday.http.codec.ResourceHttpMessageWriter)6 MultipartHttpMessageWriter (cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter)6 PartEventHttpMessageWriter (cn.taketoday.http.codec.multipart.PartEventHttpMessageWriter)6 ProtobufHttpMessageWriter (cn.taketoday.http.codec.protobuf.ProtobufHttpMessageWriter)6 Test (org.junit.jupiter.api.Test)6 ServerSentEventHttpMessageReader (cn.taketoday.http.codec.ServerSentEventHttpMessageReader)2 Jackson2JsonDecoder (cn.taketoday.http.codec.json.Jackson2JsonDecoder)2 Jackson2JsonEncoder (cn.taketoday.http.codec.json.Jackson2JsonEncoder)2 Jackson2SmileEncoder (cn.taketoday.http.codec.json.Jackson2SmileEncoder)2