Package org.codehaus.jackson.jaxb

Source Code of org.codehaus.jackson.jaxb.TestAdaptedMapType

package org.codehaus.jackson.jaxb;

import junit.framework.TestCase;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.xc.JaxbAnnotationIntrospector;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.HashMap;

/**
* @author Ryan Heaton
*/
public class TestAdaptedMapType extends TestCase {

  public void testJacksonAdaptedMapType() throws Exception {
    ObjectContainingAMap obj = new ObjectContainingAMap();
    obj.setMyMap(new HashMap<String, String>());
    obj.getMyMap().put("this", "that");
    obj.getMyMap().put("how", "here");

    ObjectMapper mapper = new ObjectMapper();
    mapper.getDeserializationConfig().withAnnotationIntrospector(new JaxbAnnotationIntrospector());
    mapper.getSerializationConfig().withAnnotationIntrospector(new JaxbAnnotationIntrospector());
    ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
    mapper.writeValue(bytesOut, obj);
    obj = mapper.readValue(new ByteArrayInputStream(bytesOut.toByteArray()), ObjectContainingAMap.class);
    assertNotNull(obj.getMyMap());
  }
}
TOP

Related Classes of org.codehaus.jackson.jaxb.TestAdaptedMapType

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.