Skip to content

Commit 5fce6e6

Browse files
authored
Add passing-in-2.x test or #5335 (#5360)
1 parent 793fcf9 commit 5fce6e6

File tree

1 file changed

+54
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)