forked from FasterXML/jackson-databind
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add failing test for an issue FasterXML#1421
- Loading branch information
1 parent
0c8642c
commit 18eee34
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
src/test/java/com/fasterxml/jackson/failing/SingleValueAsArray1421Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.fasterxml.jackson.failing; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.DeserializationFeature; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class SingleValueAsArray1421Test | ||
{ | ||
private static final String JSON = "[{\"message\":\"messageHere\"}]"; | ||
|
||
static class A | ||
{ | ||
List<B> bs = Collections.emptyList(); | ||
|
||
@JsonCreator | ||
A(final List<B> bs) | ||
{ | ||
this.bs = bs; | ||
} | ||
} | ||
|
||
static class B | ||
{ | ||
List<C> cs = Collections.emptyList(); | ||
|
||
@JsonCreator | ||
B(final List<C> cs) | ||
{ | ||
this.cs = cs; | ||
} | ||
} | ||
|
||
public static class C | ||
{ | ||
String message; | ||
|
||
@JsonCreator | ||
C(@JsonProperty("message") String message) | ||
{ | ||
this.message = message; | ||
} | ||
} | ||
|
||
@Test | ||
public void testSuccessfulDeserializationOfObjectWithChainedArrayCreators() throws IOException | ||
{ | ||
ObjectMapper om = new ObjectMapper(); | ||
om.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); | ||
om.readValue(JSON, A.class); | ||
} | ||
} |