use of cn.taketoday.http.codec.Pojo in project today-infrastructure by TAKETODAY.
the class Jackson2CborEncoderTests method encode.
@Test
public void encode() {
Pojo value = new Pojo("foo", "bar");
DataBuffer result = encoder.encodeValue(value, this.bufferFactory, ResolvableType.fromClass(Pojo.class), CBOR_MIME_TYPE, null);
pojoConsumer(value).accept(result);
}
use of cn.taketoday.http.codec.Pojo in project today-infrastructure by TAKETODAY.
the class Jackson2CborEncoderTests method encodeStream.
@Test
public void encodeStream() {
Pojo pojo1 = new Pojo("foo", "bar");
Pojo pojo2 = new Pojo("foofoo", "barbar");
Pojo pojo3 = new Pojo("foofoofoo", "barbarbar");
Flux<Pojo> input = Flux.just(pojo1, pojo2, pojo3);
ResolvableType type = ResolvableType.fromClass(Pojo.class);
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> encoder.encode(input, this.bufferFactory, type, CBOR_MIME_TYPE, null));
}
use of cn.taketoday.http.codec.Pojo in project today-infrastructure by TAKETODAY.
the class Jackson2JsonEncoderTests method encodeWithFlushAfterWriteOff.
// gh-22771
@Test
public void encodeWithFlushAfterWriteOff() {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.FLUSH_AFTER_WRITE_VALUE, false);
Jackson2JsonEncoder encoder = new Jackson2JsonEncoder(mapper);
Flux<DataBuffer> result = encoder.encode(Flux.just(new Pojo("foo", "bar")), this.bufferFactory, ResolvableType.fromClass(Pojo.class), MimeTypeUtils.APPLICATION_JSON, Collections.emptyMap());
StepVerifier.create(result).consumeNextWith(expectString("[{\"foo\":\"foo\",\"bar\":\"bar\"}]")).expectComplete().verify(Duration.ofSeconds(5));
}
use of cn.taketoday.http.codec.Pojo in project today-infrastructure by TAKETODAY.
the class Jackson2JsonEncoderTests method encodeAscii.
@Test
public void encodeAscii() {
Mono<Object> input = Mono.just(new Pojo("foo", "bar"));
testEncode(input, ResolvableType.fromClass(Pojo.class), step -> step.consumeNextWith(expectString("{\"foo\":\"foo\",\"bar\":\"bar\"}")).verifyComplete(), new MimeType("application", "json", StandardCharsets.US_ASCII), null);
}
use of cn.taketoday.http.codec.Pojo in project today-infrastructure by TAKETODAY.
the class Jackson2JsonEncoderTests method encodeNonStream.
@Test
public void encodeNonStream() {
Flux<Pojo> input = Flux.just(new Pojo("foo", "bar"), new Pojo("foofoo", "barbar"), new Pojo("foofoofoo", "barbarbar"));
testEncode(input, Pojo.class, step -> step.consumeNextWith(expectString("[" + "{\"foo\":\"foo\",\"bar\":\"bar\"}," + "{\"foo\":\"foofoo\",\"bar\":\"barbar\"}," + "{\"foo\":\"foofoofoo\",\"bar\":\"barbarbar\"}]").andThen(DataBufferUtils::release)).verifyComplete());
}
Aggregations