File tree 1 file changed +43
-0
lines changed
src/test/java/com/fasterxml/jackson/failing
1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .failing ;
2
+
3
+ import com .fasterxml .jackson .annotation .JsonAutoDetect .Visibility ;
4
+ import com .fasterxml .jackson .annotation .PropertyAccessor ;
5
+ import com .fasterxml .jackson .databind .*;
6
+
7
+ public class RequireSetterForGetter736Test extends BaseMapTest
8
+ {
9
+ public static class DataB {
10
+ private int readonly ;
11
+ private int readwrite ;
12
+
13
+ public DataB () {
14
+ readonly = 1 ;
15
+ readwrite = 2 ;
16
+ }
17
+
18
+ public int getReadwrite () {
19
+ return readwrite ;
20
+ }
21
+ public void setReadwrite (int readwrite ) {
22
+ this .readwrite = readwrite ;
23
+ }
24
+ public int getReadonly () {
25
+ return readonly ;
26
+ }
27
+ }
28
+
29
+ // for [databind#736]
30
+ public void testNeedForSetters () throws Exception
31
+ {
32
+ ObjectMapper mapper = new ObjectMapper ();
33
+ mapper .setVisibility (PropertyAccessor .ALL , Visibility .NONE );
34
+ mapper .setVisibility (PropertyAccessor .GETTER , Visibility .PUBLIC_ONLY );
35
+ mapper .setVisibility (PropertyAccessor .SETTER , Visibility .PUBLIC_ONLY );
36
+ mapper .enable (MapperFeature .REQUIRE_SETTERS_FOR_GETTERS );
37
+ DataB dataB = new DataB ();
38
+
39
+ String json = mapper .writeValueAsString (dataB );
40
+ assertEquals (aposToQuotes ("{'readwrite':2}" ), json );
41
+
42
+ }
43
+ }
You can’t perform that action at this time.
0 commit comments