Support JAXBElement in Jaxb2XmlEncoder

This commit introduces support for JAXBElements in the Jaxb2XmlEncoder.

Closes gh-30552
This commit is contained in:
Arjen Poutsma
2023-06-08 15:29:56 +02:00
parent 2f78b42133
commit d7970e4ab8
2 changed files with 27 additions and 2 deletions

View File

@@ -20,6 +20,9 @@ import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import javax.xml.namespace.QName;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElements;
import jakarta.xml.bind.annotation.XmlRootElement;
@@ -76,6 +79,18 @@ public class Jaxb2XmlEncoderTests extends AbstractEncoderTests<Jaxb2XmlEncoder>
.verifyComplete());
}
@Test
public void encodeJaxbElement() {
Mono<JAXBElement<Pojo>> input = Mono.just(new JAXBElement<>(new QName("baz"), Pojo.class,
new Pojo("foofoo", "barbar")));
testEncode(input, Pojo.class, step -> step
.consumeNextWith(expectXml(
"<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" +
"<baz><bar>barbar</bar><foo>foofoo</foo></baz>"))
.verifyComplete());
}
@Test
public void encodeError() {
Flux<Pojo> input = Flux.error(RuntimeException::new);