Skip to content

Commit

Permalink
Add kotlin/xml related test that breaks Jackson 2.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
henrik242 committed Dec 11, 2020
1 parent e37c67e commit 0acb852
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-base</artifactId>
Expand Down Expand Up @@ -199,7 +199,7 @@
<exclude>com/fasterxml/jackson/failing/*.java</exclude>
</excludes>
</configuration>
</plugin>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
Expand Down Expand Up @@ -228,7 +228,9 @@
<executions>
<execution>
<id>test-compile</id>
<goals> <goal>test-compile</goal> </goals>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule
import com.fasterxml.jackson.dataformat.xml.XmlFactory
import com.fasterxml.jackson.dataformat.xml.XmlMapper
import com.fasterxml.jackson.integtest.BaseTest
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
import javax.xml.stream.XMLInputFactory

class Jackson212MissingConstructorTest : BaseTest()
{
/**
* Succeeds in Jackson 2.11.x, but fails in Jackson 2.12.0
* See https://github.com/FasterXML/jackson-module-kotlin/issues/396
*/
fun testMissingConstructor()
{
val factory = XmlFactory(XMLInputFactory.newInstance())
val mapper = XmlMapper(factory, JacksonXmlModule()).registerKotlinModule()

val xml = "<product><stuff></stuff></product>"
val product: Product = mapper.readValue(xml, Product::class.java)

assertEquals(Product(null), product)
}

private data class Stuff(val str: String?)
private data class Product(val stuff: Stuff?)
}

0 comments on commit 0acb852

Please sign in to comment.