use of com.axway.ats.action.xml.XmlText in project ats-framework by Axway.
the class RestOperationTests method get_xml.
/**
* A GET which returns some XML body.
*
* We read the response body as XmlText and use its common methods to retrieve the needed data
*/
@Test
public void get_xml() {
createPersonToManipulateInTheTest();
RestClient client = new RestClient(BASE_URI + "peoplepage/get_xmlBean");
client.addResourcePath("Chuck");
client.addResourcePath("Norris");
client.setResponseMediaType(RestMediaType.APPLICATION_XML);
RestResponse response = client.get();
// get the body as XmlText
XmlText xmlResponse = response.getBodyAsXml();
// now call the different getter methods to retrieve the needed data
String firstName = xmlResponse.getString("firstName");
String lastName = xmlResponse.getString("lastName");
int age = xmlResponse.getInt("age");
log.info("Got back a XML body saying that " + firstName + " " + lastName + " is " + age + " old");
log.info("A XML body looks like that:\n" + xmlResponse.toString());
log.info("A well formatter XML body looks like that:\n" + xmlResponse.toFormattedString());
}
use of com.axway.ats.action.xml.XmlText in project ats-framework by Axway.
the class HttpOperationTests method get_xml.
/**
* A GET which returns some XML body.
*
* We read the response body as XmlText and use its common methods to retrieve the needed data
*/
@Test
public void get_xml() {
createPersonToManipulateInTheTest();
HttpClient client = new HttpClient(BASE_URI + "peoplepage/get_xmlBean");
client.addResourcePath("Chuck");
client.addResourcePath("Norris");
HttpResponse response = client.get();
// get the body as XmlText
XmlText xmlResponse = response.getBodyAsXmlText();
// now call the different getter methods to retrieve the needed data
String firstName = xmlResponse.getString("firstName");
String lastName = xmlResponse.getString("lastName");
int age = xmlResponse.getInt("age");
log.info("Got back a XML body saying that " + firstName + " " + lastName + " is " + age + " old");
log.info("A XML body looks like that:\n" + xmlResponse.toString());
log.info("A well formatter XML body looks like that:\n" + xmlResponse.toFormattedString());
}
Aggregations