1
+ package com .fasterxml .jackson .databind .tofix ;
2
+
3
+ import org .junit .jupiter .api .Test ;
4
+
5
+ import com .fasterxml .jackson .annotation .JsonPropertyOrder ;
6
+ import com .fasterxml .jackson .databind .*;
7
+ import com .fasterxml .jackson .databind .testutil .DatabindTestUtil ;
8
+ import com .fasterxml .jackson .databind .testutil .failure .JacksonTestFailureExpected ;
9
+
10
+ import static org .junit .jupiter .api .Assertions .*;
11
+
12
+ // [databind#5152] Support "iPhone" style capitalized properties
13
+ public class IPhoneStyleProperty5152Test
14
+ extends DatabindTestUtil
15
+ {
16
+ static class IPhoneBean {
17
+ private String iPhone ;
18
+
19
+ public String getIPhone () {
20
+ return iPhone ;
21
+ }
22
+
23
+ public void setIPhone (String value ) {
24
+ iPhone = value ;
25
+ }
26
+ }
27
+
28
+ static class RegularBean {
29
+ private String phoneNumber ;
30
+
31
+ public String getPhoneNumber () {
32
+ return phoneNumber ;
33
+ }
34
+
35
+ public void setPhoneNumber (String value ) {
36
+ phoneNumber = value ;
37
+ }
38
+ }
39
+
40
+ // [databind#2835]: "dLogHeader" property
41
+ static class DLogHeaderBean {
42
+ private String DLogHeader ;
43
+
44
+ public String getDLogHeader () {
45
+ return DLogHeader ;
46
+ }
47
+
48
+ public void setDLogHeader (String value ) {
49
+ DLogHeader = value ;
50
+ }
51
+ }
52
+
53
+ static class KBSBroadCastingBean {
54
+ private String KBSBroadCasting ;
55
+
56
+ public String getKBSBroadCasting () {
57
+ return KBSBroadCasting ;
58
+ }
59
+
60
+ public void setKBSBroadCasting (String value ) {
61
+ KBSBroadCasting = value ;
62
+ }
63
+ }
64
+
65
+ static class PhoneBean {
66
+ private String Phone ;
67
+
68
+ public String getPhone () {
69
+ return Phone ;
70
+ }
71
+ public void setPhone (String value ) {
72
+ Phone = value ;
73
+ }
74
+ }
75
+
76
+ private final ObjectMapper MAPPER = jsonMapperBuilder ()
77
+ .build ();
78
+
79
+ @ JacksonTestFailureExpected
80
+ @ Test
81
+ public void testIPhoneStyleProperty () throws Exception {
82
+ // Test with iPhone style property
83
+ String json = "{\" iPhone\" :\" iPhone 15\" }" ;
84
+ IPhoneBean result = MAPPER .readValue (json , IPhoneBean .class );
85
+ assertNotNull (result );
86
+ assertEquals ("iPhone 15" , result .getIPhone ());
87
+
88
+ // Test serialization
89
+ String serialized = MAPPER .writeValueAsString (result );
90
+ assertEquals ("{\" iPhone\" :\" iPhone 15\" }" , serialized );
91
+ }
92
+
93
+ @ Test
94
+ public void testRegularPojoProperty () throws Exception {
95
+ // Test with regular POJO property
96
+ String json = "{\" phoneNumber\" :\" 123-456-7890\" }" ;
97
+ RegularBean result = MAPPER .readValue (json , RegularBean .class );
98
+ assertNotNull (result );
99
+ assertEquals ("123-456-7890" , result .getPhoneNumber ());
100
+
101
+ // Test serialization
102
+ String serialized = MAPPER .writeValueAsString (result );
103
+ assertEquals ("{\" phoneNumber\" :\" 123-456-7890\" }" , serialized );
104
+ }
105
+
106
+ // [databind#2835]: "dLogHeader" property
107
+ @ JacksonTestFailureExpected
108
+ @ Test
109
+ public void testDLogHeaderStyleProperty () throws Exception {
110
+ // Test with DLogHeader style property
111
+ String json = "{\" dLogHeader\" :\" Debug Log Header\" }" ;
112
+ DLogHeaderBean result = MAPPER .readValue (json , DLogHeaderBean .class );
113
+ assertNotNull (result );
114
+ assertEquals ("Debug Log Header" , result .getDLogHeader ());
115
+
116
+ // Test serialization
117
+ String serialized = MAPPER .writeValueAsString (result );
118
+ assertEquals ("{\" dLogHeader\" :\" Debug Log Header\" }" , serialized );
119
+ }
120
+
121
+ @ JacksonTestFailureExpected
122
+ @ Test
123
+ public void testKBSBroadCastingStyleProperty () throws Exception {
124
+ // Test with KBSBroadCasting style property
125
+ String json = "{\" KBSBroadCasting\" :\" Korean Broadcasting System\" }" ;
126
+ KBSBroadCastingBean result = MAPPER .readValue (json , KBSBroadCastingBean .class );
127
+ assertNotNull (result );
128
+ assertEquals ("Korean Broadcasting System" , result .getKBSBroadCasting ());
129
+
130
+ // Test serialization
131
+ String serialized = MAPPER .writeValueAsString (result );
132
+ assertEquals ("{\" KBSBroadCasting\" :\" Korean Broadcasting System\" }" , serialized );
133
+ }
134
+
135
+ @ JacksonTestFailureExpected
136
+ @ Test
137
+ public void testPhoneStyleProperty () throws Exception {
138
+ // Test with Phone style property
139
+ String json = "{\" Phone\" :\" iPhone 15\" }" ;
140
+ PhoneBean result = MAPPER .readValue (json , PhoneBean .class );
141
+ assertNotNull (result );
142
+ assertEquals ("iPhone 15" , result .getPhone ());
143
+
144
+ // Test serialization
145
+ String serialized = MAPPER .writeValueAsString (result );
146
+ assertEquals ("{\" Phone\" :\" iPhone 15\" }" , serialized );
147
+ }
148
+
149
+ }
0 commit comments