@SuppressWarnings("unchecked")
@Test
@org.junit.Ignore
public void testReadWriteComplexMap() throws Exception {
Map<AegisTestBean, String> map = new HashMap<AegisTestBean, String>();
AegisTestBean bean = new AegisTestBean();
bean.setBoolValue(Boolean.TRUE);
bean.setStrValue("hovercraft");
map.put(bean, "hovercraft");
MessageBodyWriter<Object> writer = new AegisElementProvider();
ByteArrayOutputStream os = new ByteArrayOutputStream();
writer.writeTo(bean, null, null, null, null, null, os);
byte[] bytes = os.toByteArray();
String xml = new String(bytes, "utf-8");
MessageBodyReader<Object> reader = new AegisElementProvider();
byte[] simpleBytes = xml.getBytes("utf-8");
Class<InterfaceWithMap> iwithMapClass = InterfaceWithMap.class;
Method method = iwithMapClass.getMethod("mapFunction");
Type mapType = method.getGenericReturnType();
Object beanObject = reader.readFrom((Class)Map.class, mapType, null,
null, null, new ByteArrayInputStream(simpleBytes));
Map<AegisTestBean, String> map2 = (Map)beanObject;
AegisTestBean bean2 = map2.keySet().iterator().next();
assertEquals("hovercraft", bean2.getStrValue());
assertEquals(Boolean.TRUE, bean2.getBoolValue());
}