Apache-cxf, trying to unmarshal xml, that has some namespaces, so @XmlRootElement contains name and namespace attrs.
The question is: How to make this test work?
@XmlRootElement(name = "MyClass", namespace = "http://foo_url")
class MyClass {
@XmlElement(name = "version")
var version: String = _
}
class SimpleTest {
@Test
def test(): Unit = {
// given
val xmlString =
"""<MyClass xmlns="http://foo_url"> <version>10</version></MyClass> """
val xmlSource = new XMLSource(new ByteArrayInputStream(xmlString.getBytes("UTF-8")))
// when
val node: MyClass = xmlSource.getNode(
"MyClass",
Collections.singletonMap(
"ns1",
"http://foo_url"
),
classOf[MyClass])
// then
assertThat(node, is( not( nullValue() ) )) //null
assertThat(node.version, is("10")) /// null !
}
I guess it is all about namespacing? Basically I want to leave XmlRootElement as it is now.