JAXBUtils { public static <T> T unmarshalFromXml(Class<T> clazz, String xml) throws JAXBException, UnsupportedEncodingException { final JAXBContext context = JAXBContext.newInstance(clazz); return unmarshalFromXml(context, clazz, xml); }  static String marshal(Object obj); @SuppressWarnings("unchecked") static String marshalWithoutRootElement(T obj); static T unmarshalFromXml(Class<T> clazz, String xml);  }
@Test public void testUnmarshalFromXml() throws UnsupportedEncodingException, JAXBException { final JAXBTestElement e = JAXBUtils.unmarshalFromXml( JAXBTestElement.class, XML); assertNotNull(e); assertEquals(FIELD1_VALUE, e.getField1()); assertEquals(FIELD2_VALUE, e.getField2()); }