use of groovy.xml.StreamingMarkupBuilder in project rest-assured by rest-assured.
the class EncoderRegistry method encodeXML.
/**
* Encode the content as XML. The argument may be either an object whose
* <code>toString</code> produces valid markup, or a Closure which will be
* interpreted as a builder definition.
*
* @param xml data that defines the XML structure
* @return an {@link HttpEntity} encapsulating this request data
* @throws UnsupportedEncodingException
*/
public HttpEntity encodeXML(Object contentType, Object xml) throws UnsupportedEncodingException {
String contentTypeAsString = contentTypeToString(contentType);
if (xml instanceof Closure) {
StreamingMarkupBuilder smb = new StreamingMarkupBuilder();
xml = smb.bind(xml);
} else if (xml instanceof File) {
xml = toString((File) xml, contentTypeAsString);
}
return createEntity(contentTypeAsString, xml);
}
Aggregations