Skip to content

Commit bedb6ea

Browse files
authored
Add failing testcase for #611 (#612)
1 parent 200f6fb commit bedb6ea

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/test/kotlin/com/fasterxml/jackson/module/kotlin/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fun serializeAndDeserializeTypeable() {
3333
val newEntity = mapper.readValue<MyEntity>(json)
3434

3535
expectFailure<AssertionError>("GitHub #335 has been fixed!") {
36-
// newEntity.type is hte string "null" instead of the null value
36+
// newEntity.type is the string "null" instead of the null value
3737
assertNull(newEntity.type)
3838
}
3939
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.fasterxml.jackson.module.kotlin.test.github.failing
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty
4+
import com.fasterxml.jackson.databind.JsonMappingException
5+
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
6+
import com.fasterxml.jackson.module.kotlin.readValue
7+
import com.fasterxml.jackson.module.kotlin.test.expectFailure
8+
import org.junit.Test
9+
10+
class TestGithub611 {
11+
12+
class TestClass(@JsonProperty("id") var id: UShort) {
13+
// Empty constructor
14+
constructor() : this(1u)
15+
}
16+
17+
// Value fits into UShort, but not (Java) Short
18+
private val jsonData = """
19+
{
20+
"id": 50000
21+
}
22+
"""
23+
24+
@Test
25+
fun testJsonParsing() {
26+
val mapper = jacksonObjectMapper()
27+
expectFailure<JsonMappingException>("GitHub #611 has been fixed!") {
28+
val dataClassInstance = mapper.readValue<TestClass>(jsonData)
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)