-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create JsonUnwrappedInconsistentSerialization4697Test.java
- Loading branch information
1 parent
567e089
commit 0a04c40
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
.../com/fasterxml/jackson/databind/tofix/JsonUnwrappedInconsistentSerialization4697Test.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.databind.tofix; | ||
|
||
import com.fasterxml.jackson.annotation.JsonUnwrapped; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil; | ||
import com.fasterxml.jackson.databind.testutil.failure.JacksonTestFailureExpected; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
// [databind#4697] Inconsistent Serialization with Jackson’s @JsonUnwrapped Annotation | ||
// Using Shared vs. New ObjectMapper Instances #4697 | ||
public class JsonUnwrappedInconsistentSerialization4697Test | ||
extends DatabindTestUtil | ||
{ | ||
public static class First { | ||
@JsonUnwrapped(prefix = "") | ||
public Thrid thrid = new Thrid(); | ||
} | ||
|
||
public static class Second { | ||
@JsonUnwrapped(prefix = "fromSecond") | ||
public Thrid thrid = new Thrid(); | ||
} | ||
|
||
public static class Thrid { | ||
@JsonUnwrapped(prefix = "fromThird") | ||
public Common common = new Common(); | ||
|
||
public Thrid() { | ||
this.common.a = "a"; | ||
this.common.b = "b"; | ||
} | ||
} | ||
|
||
public static class Common { | ||
public String a; | ||
public String b; | ||
public Common() {} | ||
} | ||
|
||
@JacksonTestFailureExpected | ||
@Test | ||
public void testInconsistentSer() throws Exception { | ||
First first = new First(); | ||
Second second = new Second(); | ||
|
||
ObjectMapper firstMapper = newJsonMapper(); | ||
ObjectMapper secondMapper = newJsonMapper(); | ||
|
||
firstMapper.writeValueAsString(first); | ||
assertEquals( | ||
firstMapper.writeValueAsString(second), | ||
secondMapper.writeValueAsString(second)); | ||
} | ||
} |