1515//
1616package org .msgpack .jackson .dataformat ;
1717
18- import com .fasterxml .jackson .core .JsonGenerator ;
1918import com .fasterxml .jackson .core .JsonParser ;
2019import com .fasterxml .jackson .core .JsonProcessingException ;
2120import com .fasterxml .jackson .core .JsonToken ;
2221import com .fasterxml .jackson .core .io .JsonEOFException ;
2322import com .fasterxml .jackson .core .type .TypeReference ;
2423import com .fasterxml .jackson .databind .DeserializationContext ;
2524import com .fasterxml .jackson .databind .DeserializationFeature ;
26- import com .fasterxml .jackson .databind .JsonDeserializer ;
2725import com .fasterxml .jackson .databind .JsonMappingException ;
2826import com .fasterxml .jackson .databind .KeyDeserializer ;
2927import com .fasterxml .jackson .databind .ObjectMapper ;
30- import com .fasterxml .jackson .databind .SerializerProvider ;
3128import com .fasterxml .jackson .databind .module .SimpleModule ;
32- import com .fasterxml .jackson .databind .ser .std .StdSerializer ;
3329import org .junit .Test ;
3430import org .msgpack .core .MessagePack ;
3531import org .msgpack .core .MessagePacker ;
@@ -783,41 +779,6 @@ public Object deserialize(byte[] data)
783779 assertThat ((String ) values .get (4 ), is ("Java" ));
784780 }
785781
786-
787- static class UUIDSerializer
788- extends StdSerializer <UUID >
789- {
790- private final byte code ;
791-
792- UUIDSerializer (byte code )
793- {
794- super (UUID .class );
795- this .code = code ;
796- }
797-
798- public void serialize (UUID value , JsonGenerator jsonGenerator , SerializerProvider provider )
799- throws IOException
800- {
801- if (jsonGenerator instanceof MessagePackGenerator ) {
802- MessagePackGenerator messagePackGenerator = (MessagePackGenerator ) jsonGenerator ;
803- messagePackGenerator .writeExtensionType (new MessagePackExtensionType (code , toBytes (value )));
804- } else {
805- throw new RuntimeException ("Something went wrong with the serialization" );
806- }
807- }
808-
809- @ SuppressWarnings ("WeakerAccess" )
810- static byte [] toBytes (UUID value )
811- {
812- return value .toString ().getBytes ();
813- }
814-
815- static UUID fromBytes (byte [] value )
816- {
817- return UUID .fromString (new String (value ));
818- }
819- }
820-
821782 @ Test
822783 public void extensionTypeInMap ()
823784 throws IOException
@@ -828,29 +789,16 @@ public void extensionTypeInMap()
828789 extTypeCustomDesers .addCustomDeser (uuidTypeCode , new ExtensionTypeCustomDeserializers .Deser ()
829790 {
830791 @ Override
831- public Object deserialize (byte [] value1 )
792+ public Object deserialize (byte [] value )
832793 throws IOException
833794 {
834- return UUIDSerializer . fromBytes ( value1 );
795+ return UUID . fromString ( new String ( value ) );
835796 }
836797 });
837798
838799 ObjectMapper objectMapper = new ObjectMapper (
839800 new MessagePackFactory ().setExtTypeCustomDesers (extTypeCustomDesers ));
840801
841- SimpleModule simpleModule = new SimpleModule ();
842- simpleModule .addDeserializer (UUID .class ,
843- new JsonDeserializer <UUID >()
844- {
845- @ Override
846- public UUID deserialize (JsonParser p , DeserializationContext ctxt )
847- throws IOException , JsonProcessingException
848- {
849- return UUID .fromString (p .readValueAs (String .class ));
850- }
851- });
852- objectMapper .registerModule (simpleModule );
853-
854802 // Prepare serialized data
855803 Map <UUID , UUID > originalMap = new HashMap <>();
856804 byte [] serializedData ;
0 commit comments