Tools { @SuppressWarnings("unchecked") public static <T> T unmarshalFromXml(String xml, Class<T> targetClass) { Jaxb2Marshaller jaxb2 = new Jaxb2Marshaller(); jaxb2.setContextPath(targetClass.getPackage().getName()); return (T) jaxb2.unmarshal(new StreamSource(new StringReader(xml))); } private  Tools(); static String toString(Object value); static String joinNonEmpty(String[] array, char separator); static String marshalToXml(Object obj, Class sourceClass); @SuppressWarnings("unchecked") static String marshalToXml(T obj, QName qName); @SuppressWarnings("unchecked") static T unmarshalFromXml(String xml, Class<T> targetClass); static OffsetDateTime toUTC(OffsetDateTime localDateTime); static OffsetDateTime fromUTC(OffsetDateTime utcTime); static OffsetDateTime fromUTC(long utcMillis); static Set<String> getAllKnownPropertyNames(ConfigurableEnvironment env); static Properties getPropertiesWithPrefix(ConfigurableEnvironment env, String propertyNamePrefix); static String fm(String message, Object... values);  }
@Test public void testUnmarshalFromXml() { String xml = "<helloRequest>" + " <name>Mr. Parker</name>" + "</helloRequest>"; HelloRequest req = Tools.unmarshalFromXml(xml, HelloRequest.class); assertThat(req.getName(), is("Mr. Parker")); }