|
24 | 24 | import reactor.test.StepVerifier;
|
25 | 25 |
|
26 | 26 | import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTestCase;
|
| 27 | +import org.springframework.core.io.buffer.DataBuffer; |
27 | 28 |
|
28 |
| -import static org.junit.Assert.assertEquals; |
29 |
| -import static org.junit.Assert.assertTrue; |
| 29 | +import static org.junit.Assert.*; |
30 | 30 |
|
31 | 31 | /**
|
32 | 32 | * @author Arjen Poutsma
|
@@ -83,6 +83,36 @@ public void toXMLEventsNonAalto() {
|
83 | 83 | .verify();
|
84 | 84 | }
|
85 | 85 |
|
| 86 | + @Test |
| 87 | + public void decodeErrorAalto() { |
| 88 | + Flux<DataBuffer> source = Flux.just(stringBuffer("<pojo>")) |
| 89 | + .concatWith(Flux.error(new RuntimeException())); |
| 90 | + |
| 91 | + Flux<XMLEvent> events = |
| 92 | + this.decoder.decode(source, null, null, Collections.emptyMap()); |
| 93 | + |
| 94 | + StepVerifier.create(events) |
| 95 | + .consumeNextWith(e -> assertTrue(e.isStartDocument())) |
| 96 | + .consumeNextWith(e -> assertStartElement(e, "pojo")) |
| 97 | + .expectError(RuntimeException.class) |
| 98 | + .verify(); |
| 99 | + } |
| 100 | + |
| 101 | + @Test |
| 102 | + public void decodeErrorNonAalto() { |
| 103 | + decoder.useAalto = false; |
| 104 | + |
| 105 | + Flux<DataBuffer> source = Flux.just(stringBuffer("<pojo>")) |
| 106 | + .concatWith(Flux.error(new RuntimeException())); |
| 107 | + |
| 108 | + Flux<XMLEvent> events = |
| 109 | + this.decoder.decode(source, null, null, Collections.emptyMap()); |
| 110 | + |
| 111 | + StepVerifier.create(events) |
| 112 | + .expectError(RuntimeException.class) |
| 113 | + .verify(); |
| 114 | + } |
| 115 | + |
86 | 116 | private static void assertStartElement(XMLEvent event, String expectedLocalName) {
|
87 | 117 | assertTrue(event.isStartElement());
|
88 | 118 | assertEquals(expectedLocalName, event.asStartElement().getName().getLocalPart());
|
|
0 commit comments