Skip to content

Commit 02dedd0

Browse files
authored
Merge pull request #401 from FasterXML/github-396-missing-xml-constructor
Missing constructor when parsing XML into data class
2 parents ac91202 + de5855b commit 02dedd0

File tree

1 file changed

+29
-0
lines changed
  • src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/failing

1 file changed

+29
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.fasterxml.jackson.module.kotlin.test.failing
2+
3+
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule
4+
import com.fasterxml.jackson.dataformat.xml.XmlFactory
5+
import com.fasterxml.jackson.dataformat.xml.XmlMapper
6+
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
7+
import javax.xml.stream.XMLInputFactory
8+
import kotlin.test.Test
9+
import kotlin.test.assertEquals
10+
11+
class TestGithub396 {
12+
/**
13+
* Succeeds in Jackson 2.11.x, but fails in Jackson 2.12.0
14+
* See https://github.com/FasterXML/jackson-module-kotlin/issues/396
15+
*/
16+
@Test
17+
fun testMissingConstructor() {
18+
val factory = XmlFactory(XMLInputFactory.newInstance())
19+
val mapper = XmlMapper(factory, JacksonXmlModule()).registerKotlinModule()
20+
21+
val xml = "<product><stuff></stuff></product>"
22+
val product: Product = mapper.readValue(xml, Product::class.java)
23+
24+
assertEquals(Product(null), product)
25+
}
26+
27+
private data class Stuff(val str: String?)
28+
private data class Product(val stuff: Stuff?)
29+
}

0 commit comments

Comments
 (0)