Add error stream tests for XmlEventDecoder
Issue: SPR-17418
This commit is contained in:
parent
f738273486
commit
a37efc9881
|
@ -24,9 +24,9 @@ import reactor.core.publisher.Flux;
|
|||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTestCase;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
|
@ -83,6 +83,36 @@ public class XmlEventDecoderTests extends AbstractDataBufferAllocatingTestCase {
|
|||
.verify();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeErrorAalto() {
|
||||
Flux<DataBuffer> source = Flux.just(stringBuffer("<pojo>"))
|
||||
.concatWith(Flux.error(new RuntimeException()));
|
||||
|
||||
Flux<XMLEvent> events =
|
||||
this.decoder.decode(source, null, null, Collections.emptyMap());
|
||||
|
||||
StepVerifier.create(events)
|
||||
.consumeNextWith(e -> assertTrue(e.isStartDocument()))
|
||||
.consumeNextWith(e -> assertStartElement(e, "pojo"))
|
||||
.expectError(RuntimeException.class)
|
||||
.verify();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeErrorNonAalto() {
|
||||
decoder.useAalto = false;
|
||||
|
||||
Flux<DataBuffer> source = Flux.just(stringBuffer("<pojo>"))
|
||||
.concatWith(Flux.error(new RuntimeException()));
|
||||
|
||||
Flux<XMLEvent> events =
|
||||
this.decoder.decode(source, null, null, Collections.emptyMap());
|
||||
|
||||
StepVerifier.create(events)
|
||||
.expectError(RuntimeException.class)
|
||||
.verify();
|
||||
}
|
||||
|
||||
private static void assertStartElement(XMLEvent event, String expectedLocalName) {
|
||||
assertTrue(event.isStartElement());
|
||||
assertEquals(expectedLocalName, event.asStartElement().getName().getLocalPart());
|
||||
|
|
Loading…
Reference in New Issue