Skip to content

Commit 0acb852

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

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

pom.xml

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3-
<modelVersion>4.0.0</modelVersion>
3+
<modelVersion>4.0.0</modelVersion>
44
<parent>
55
<groupId>com.fasterxml.jackson</groupId>
66
<artifactId>jackson-base</artifactId>
@@ -199,7 +199,7 @@
199199
<exclude>com/fasterxml/jackson/failing/*.java</exclude>
200200
</excludes>
201201
</configuration>
202-
</plugin>
202+
</plugin>
203203
<plugin>
204204
<groupId>net.alchim31.maven</groupId>
205205
<artifactId>scala-maven-plugin</artifactId>
@@ -228,7 +228,9 @@
228228
<executions>
229229
<execution>
230230
<id>test-compile</id>
231-
<goals> <goal>test-compile</goal> </goals>
231+
<goals>
232+
<goal>test-compile</goal>
233+
</goals>
232234
<configuration>
233235
<sourceDirs>
234236
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
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)