use of org.springframework.web.testfixture.xml.Pojo in project spring-framework by spring-projects.
the class Jackson2JsonEncoderTests method encodeAsStreamWithCustomStreamingType.
// SPR-15727
@Test
public void encodeAsStreamWithCustomStreamingType() {
MediaType fooMediaType = new MediaType("application", "foo");
MediaType barMediaType = new MediaType("application", "bar");
this.encoder.setStreamingMediaTypes(Arrays.asList(fooMediaType, barMediaType));
Flux<Pojo> input = Flux.just(new Pojo("foo", "bar"), new Pojo("foofoo", "barbar"), new Pojo("foofoofoo", "barbarbar"));
testEncode(input, ResolvableType.forClass(Pojo.class), step -> step.consumeNextWith(expectString("{\"foo\":\"foo\",\"bar\":\"bar\"}\n").andThen(DataBufferUtils::release)).consumeNextWith(expectString("{\"foo\":\"foofoo\",\"bar\":\"barbar\"}\n").andThen(DataBufferUtils::release)).consumeNextWith(expectString("{\"foo\":\"foofoofoo\",\"bar\":\"barbarbar\"}\n").andThen(DataBufferUtils::release)).verifyComplete(), barMediaType, null);
}
use of org.springframework.web.testfixture.xml.Pojo in project spring-framework by spring-projects.
the class Jackson2JsonEncoderTests method encode.
@Override
@Test
@SuppressWarnings("deprecation")
public void encode() throws Exception {
Flux<Object> input = Flux.just(new Pojo("foo", "bar"), new Pojo("foofoo", "barbar"), new Pojo("foofoofoo", "barbarbar"));
testEncodeAll(input, ResolvableType.forClass(Pojo.class), step -> step.consumeNextWith(expectString("{\"foo\":\"foo\",\"bar\":\"bar\"}\n")).consumeNextWith(expectString("{\"foo\":\"foofoo\",\"bar\":\"barbar\"}\n")).consumeNextWith(expectString("{\"foo\":\"foofoofoo\",\"bar\":\"barbarbar\"}\n")).verifyComplete(), APPLICATION_STREAM_JSON, null);
}
use of org.springframework.web.testfixture.xml.Pojo in project spring-framework by spring-projects.
the class Jackson2JsonEncoderTests method encodeAscii.
@Test
public void encodeAscii() {
Mono<Object> input = Mono.just(new Pojo("foo", "bar"));
testEncode(input, ResolvableType.forClass(Pojo.class), step -> step.consumeNextWith(expectString("{\"foo\":\"foo\",\"bar\":\"bar\"}")).verifyComplete(), new MimeType("application", "json", StandardCharsets.US_ASCII), null);
}
use of org.springframework.web.testfixture.xml.Pojo in project spring-framework by spring-projects.
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.forClass(Pojo.class), MimeTypeUtils.APPLICATION_JSON, Collections.emptyMap());
StepVerifier.create(result).consumeNextWith(expectString("[{\"foo\":\"foo\",\"bar\":\"bar\"}]")).expectComplete().verify(Duration.ofSeconds(5));
}
use of org.springframework.web.testfixture.xml.Pojo in project spring-framework by spring-projects.
the class Jaxb2XmlEncoderTests method encode.
@Override
@Test
public void encode() {
Mono<Pojo> input = Mono.just(new Pojo("foofoo", "barbar"));
testEncode(input, Pojo.class, step -> step.consumeNextWith(expectXml("<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" + "<pojo><bar>barbar</bar><foo>foofoo</foo></pojo>")).verifyComplete());
}
Aggregations