Skip to content

Commit 4400590

Browse files
committed
Add kotlin/xml related test that breaks Jackson 2.12.0
See FasterXML/jackson-module-kotlin#396
1 parent e37c67e commit 4400590

File tree

1 file changed

+27
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)