File tree 1 file changed +31
-0
lines changed
src/test/java/com/fasterxml/jackson/failing
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .failing ;
2
+
3
+ import java .util .Collections ;
4
+ import java .util .Set ;
5
+
6
+ import com .fasterxml .jackson .annotation .*;
7
+
8
+ import com .fasterxml .jackson .databind .*;
9
+
10
+ public class UnmodifiableSetTyping1392Test extends BaseMapTest
11
+ {
12
+ @ JsonTypeInfo (use = JsonTypeInfo .Id .CLASS , include = JsonTypeInfo .As .PROPERTY )
13
+ abstract static class UnmodifiableSetMixin {
14
+
15
+ @ JsonCreator
16
+ public UnmodifiableSetMixin (Set <?> s ) {}
17
+ }
18
+
19
+ public void testUnmodifiable () throws Exception
20
+ {
21
+ ObjectMapper mapper = new ObjectMapper ();
22
+ Class <?> unmodSetType = Collections .unmodifiableSet (Collections .<String >emptySet ()).getClass ();
23
+ mapper .addMixIn (unmodSetType , UnmodifiableSetMixin .class );
24
+ mapper .enableDefaultTyping (ObjectMapper .DefaultTyping .NON_FINAL , JsonTypeInfo .As .PROPERTY );
25
+
26
+ final String EXPECTED_JSON = "[\" " +unmodSetType .getName ()+"\" ,[]]" ;
27
+
28
+ Set <?> foo = mapper .readValue (EXPECTED_JSON , Set .class );
29
+ assertTrue (foo .isEmpty ());
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments