Search in sources :

Example 1 with Jackson2SmileEncoder

use of cn.taketoday.http.codec.json.Jackson2SmileEncoder 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 2 with Jackson2SmileEncoder

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

the class CodecConfigurerTests method encoderDecoderOverrides.

@Test
void encoderDecoderOverrides() {
    Jackson2JsonDecoder jacksonDecoder = new Jackson2JsonDecoder();
    Jackson2JsonEncoder jacksonEncoder = new Jackson2JsonEncoder();
    Jackson2SmileDecoder smileDecoder = new Jackson2SmileDecoder();
    Jackson2SmileEncoder smileEncoder = new Jackson2SmileEncoder();
    ProtobufDecoder protobufDecoder = new ProtobufDecoder(ExtensionRegistry.newInstance());
    ProtobufEncoder protobufEncoder = new ProtobufEncoder();
    this.configurer.defaultCodecs().jackson2JsonDecoder(jacksonDecoder);
    this.configurer.defaultCodecs().jackson2JsonEncoder(jacksonEncoder);
    this.configurer.defaultCodecs().jackson2SmileDecoder(smileDecoder);
    this.configurer.defaultCodecs().jackson2SmileEncoder(smileEncoder);
    this.configurer.defaultCodecs().protobufDecoder(protobufDecoder);
    this.configurer.defaultCodecs().protobufEncoder(protobufEncoder);
    assertDecoderInstance(jacksonDecoder);
    assertDecoderInstance(smileDecoder);
    assertDecoderInstance(protobufDecoder);
    assertEncoderInstance(jacksonEncoder);
    assertEncoderInstance(smileEncoder);
    assertEncoderInstance(protobufEncoder);
}
Also used : ProtobufEncoder(cn.taketoday.http.codec.protobuf.ProtobufEncoder) Jackson2JsonDecoder(cn.taketoday.http.codec.json.Jackson2JsonDecoder) Jackson2SmileEncoder(cn.taketoday.http.codec.json.Jackson2SmileEncoder) ProtobufDecoder(cn.taketoday.http.codec.protobuf.ProtobufDecoder) Jackson2JsonEncoder(cn.taketoday.http.codec.json.Jackson2JsonEncoder) Jackson2SmileDecoder(cn.taketoday.http.codec.json.Jackson2SmileDecoder) Test(org.junit.jupiter.api.Test)

Example 3 with Jackson2SmileEncoder

use of cn.taketoday.http.codec.json.Jackson2SmileEncoder 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 4 with Jackson2SmileEncoder

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

the class CodecConfigurerTests method encoderDecoderOverrides.

@Test
void encoderDecoderOverrides() {
    Jackson2JsonDecoder jacksonDecoder = new Jackson2JsonDecoder();
    Jackson2JsonEncoder jacksonEncoder = new Jackson2JsonEncoder();
    Jackson2SmileDecoder smileDecoder = new Jackson2SmileDecoder();
    Jackson2SmileEncoder smileEncoder = new Jackson2SmileEncoder();
    ProtobufDecoder protobufDecoder = new ProtobufDecoder(ExtensionRegistry.newInstance());
    ProtobufEncoder protobufEncoder = new ProtobufEncoder();
    this.configurer.defaultCodecs().jackson2JsonDecoder(jacksonDecoder);
    this.configurer.defaultCodecs().jackson2JsonEncoder(jacksonEncoder);
    this.configurer.defaultCodecs().jackson2SmileDecoder(smileDecoder);
    this.configurer.defaultCodecs().jackson2SmileEncoder(smileEncoder);
    this.configurer.defaultCodecs().protobufDecoder(protobufDecoder);
    this.configurer.defaultCodecs().protobufEncoder(protobufEncoder);
    assertDecoderInstance(jacksonDecoder);
    assertDecoderInstance(smileDecoder);
    assertDecoderInstance(protobufDecoder);
    assertEncoderInstance(jacksonEncoder);
    assertEncoderInstance(smileEncoder);
    assertEncoderInstance(protobufEncoder);
}
Also used : ProtobufEncoder(cn.taketoday.http.codec.protobuf.ProtobufEncoder) Jackson2JsonDecoder(cn.taketoday.http.codec.json.Jackson2JsonDecoder) Jackson2SmileEncoder(cn.taketoday.http.codec.json.Jackson2SmileEncoder) ProtobufDecoder(cn.taketoday.http.codec.protobuf.ProtobufDecoder) Jackson2JsonEncoder(cn.taketoday.http.codec.json.Jackson2JsonEncoder) Jackson2SmileDecoder(cn.taketoday.http.codec.json.Jackson2SmileDecoder) Test(org.junit.jupiter.api.Test)

Aggregations

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