XMLUtils { public static Document parseMessagePayload(String messagePayload) { LSParser parser = configurer.createLSParser(); LSInput receivedInput = configurer.createLSInput(); try { Charset charset = getTargetCharset(messagePayload); receivedInput.setByteStream(new ByteArrayInputStream(messagePayload.trim().getBytes(charset))); receivedInput.setEncoding(charset.displayName()); } catch(UnsupportedEncodingException e) { throw new CitrusRuntimeException(e); } return parser.parse(receivedInput); } private  XMLUtils(); static void initialize(XmlConfigurer xmlConfigurer); static LSParser createLSParser(); static LSSerializer createLSSerializer(); static LSInput createLSInput(); static LSOutput createLSOutput(); static Node findNodeByName(Document doc, String pathExpression); static void stripWhitespaceNodes(Node element); static String getNodesPathName(Node node); static String serialize(Document doc); static String prettyPrint(String xml); static Map<String, String> lookupNamespaces(Node referenceNode); static Document parseMessagePayload(String messagePayload); static Charset getTargetCharset(Document doc); static String omitXmlDeclaration(String xml); static boolean hasXmlPayload(Message message);  }
@Test public void testParseEncodingCharset() { Document doc = XMLUtils.parseMessagePayload("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<testRequest xmlns=\"http: Assert.assertNotNull(doc); doc = XMLUtils.parseMessagePayload("<?xml version='1.0' encoding='UTF-8'?>" + "<testRequest xmlns='http: Assert.assertNotNull(doc); doc = XMLUtils.parseMessagePayload("<?xml version='1.0' encoding = 'ISO-8859-1' standalone=\"yes\"?>" + "<testRequest xmlns='http: Assert.assertNotNull(doc); doc = XMLUtils.parseMessagePayload("<?xml version='1.0'?>" + "<testRequest xmlns='http: Assert.assertNotNull(doc); doc = XMLUtils.parseMessagePayload("<?xml version='1.0'?>" + "<testRequest xmlns='http: Assert.assertNotNull(doc); doc = XMLUtils.parseMessagePayload("<?xml version='1.0' encoding='UTF-8'?>" + "<testRequest xmlns='http: Assert.assertNotNull(doc); doc = XMLUtils.parseMessagePayload("<?xml version='1.0'?>" + "<testRequest xmlns='http: Assert.assertNotNull(doc); }