Skip to content

Commit 472b7a0

Browse files
committed
Merge branch '2.x' into 3.x
2 parents 995b6a8 + 5fce6e6 commit 472b7a0

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package tools.jackson.databind.misc;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
7+
8+
import tools.jackson.databind.DeserializationFeature;
9+
import tools.jackson.databind.MapperFeature;
10+
import tools.jackson.databind.ObjectMapper;
11+
import tools.jackson.databind.json.JsonMapper;
12+
import tools.jackson.databind.testutil.DatabindTestUtil;
13+
14+
import static org.junit.jupiter.api.Assertions.assertEquals;
15+
16+
// [databind#5335], due to [databind#2882]
17+
public class IPhoneStyleProperty5335Test
18+
extends DatabindTestUtil
19+
{
20+
@JsonPropertyOrder({ "aProp" })
21+
static class TestPojo {
22+
private String aProp;
23+
private String anotherProp;
24+
25+
// Needed in 3.0 due to incompatible naming
26+
@JsonProperty("aProp")
27+
public String getaProp() {
28+
return aProp;
29+
}
30+
31+
// Needed in 3.0 due to incompatible naming
32+
@JsonProperty("aProp")
33+
public void setaProp(String aProp) {
34+
this.aProp = aProp;
35+
}
36+
37+
public String getAnotherProp() {
38+
return anotherProp;
39+
}
40+
41+
public void setAnotherProp(String anotherProp) {
42+
this.anotherProp = anotherProp;
43+
}
44+
}
45+
46+
@Test
47+
public void featureEnabledTest()
48+
{
49+
ObjectMapper mapper = JsonMapper.builder()
50+
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
51+
.enable(MapperFeature.FIX_FIELD_NAME_UPPER_CASE_PREFIX)
52+
.build();
53+
54+
String json = "{\"aProp\":\"aPropValue\",\"prop1\":\"prop1Value\"}";
55+
TestPojo result = mapper.readValue(json, TestPojo.class);
56+
assertEquals("aPropValue", result.getaProp());
57+
String serialized = mapper.writeValueAsString(result);
58+
assertEquals("{\"aProp\":\"aPropValue\",\"anotherProp\":null}",
59+
serialized);
60+
}
61+
}

0 commit comments

Comments
 (0)