@Override public Node apply(String s) { return XmlUtil.asXml(s); } });
/** * Converts the body of the given Response to an XML element. * * @param response The response to be converted * @return The converted element */ public static Element asXml(Response response) { return XmlUtil.asXml(response.getContent()); }
@Override public Element asXml() { return XmlUtil.asXml(this.getContent()); }
ClientDriverRequestResponsePair matchingPair = getMatchingRequestPair(request); ClientDriverResponse matchedResponse = matchingPair.getResponse(); response.setContentType(matchedResponse.getContentType()); response.setStatus(matchedResponse.getStatus()); response.setHeader("Server", "rest-client-driver(" + RestDriverProperties.getVersion() + ")"); for (Entry<String, String> thisHeader : matchedResponse.getHeaders().entrySet()) { response.setHeader(thisHeader.getKey(), thisHeader.getValue()); if (matchedResponse.hasBody()) { OutputStream output = response.getOutputStream(); output.write(matchedResponse.getContentAsBytes()); delayIfNecessary(matchingPair.getResponse()); } else { response.setStatus(404);
/** * Converts the given string to an XML element. * * @param xml The XML string to be converted * @return The converted element */ public static Element asXml(String xml) { try { return DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(xml.getBytes("UTF-8"))).getDocumentElement(); } catch (IOException e) { return throwRuntimeXmlParseException(xml, e); } catch (SAXException e) { return throwRuntimeXmlParseException(xml, e); } catch (ParserConfigurationException e) { return throwRuntimeXmlParseException(xml, e); } }
ClientDriverRequestResponsePair matchingPair = getMatchingRequestPair(request); ClientDriverResponse matchedResponse = matchingPair.getResponse(); response.setContentType(matchedResponse.getContentType()); response.setStatus(matchedResponse.getStatus()); response.setHeader("Server", "rest-client-driver(" + RestDriverProperties.getVersion() + ")"); for (Entry<String, String> thisHeader : matchedResponse.getHeaders().entrySet()) { response.setHeader(thisHeader.getKey(), thisHeader.getValue()); if (matchedResponse.hasBody()) { OutputStream output = response.getOutputStream(); output.write(matchedResponse.getContentAsBytes()); delayIfNecessary(matchingPair.getResponse()); } else { response.setStatus(404);
/** * Converts the body of the given Response to an XML element. * * @param response The response to be converted * @return The converted element */ public static Element asXml(Response response) { return XmlUtil.asXml(response.getContent()); }
@Override public Element asXml() { return XmlUtil.asXml(this.getContent()); }
@Override public Node apply(String s) { return XmlUtil.asXml(s); } });
/** * Converts the given string to an XML element. * * @param xml The XML string to be converted * @return The converted element */ public static Element asXml(String xml) { try { return DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(xml.getBytes("UTF-8"))).getDocumentElement(); } catch (IOException e) { return throwRuntimeXmlParseException(xml, e); } catch (SAXException e) { return throwRuntimeXmlParseException(xml, e); } catch (ParserConfigurationException e) { return throwRuntimeXmlParseException(xml, e); } }
/** * Converts a string to an XML element. * * @param content The content to be converted * @return The converted element * @deprecated Instead of doing asXml(response.getContent()) you can now do asXml(response). */ @Deprecated public static Element asXml(String content) { return XmlUtil.asXml(content); }
/** * Converts a string to an XML element. * * @param content The content to be converted * @return The converted element * @deprecated Instead of doing asXml(response.getContent()) you can now do asXml(response). */ @Deprecated public static Element asXml(String content) { return XmlUtil.asXml(content); }