use of com.axway.ats.action.http.HttpResponse in project ats-framework by Axway.
the class HttpOperationTests method post_usingFormParameters.
/**
* A POST which sends form parameters.
*
* In the particular case on the server side a new person will be added to the list
* of known persons.
* It returns info about the newly added person.
*/
@Test
public void post_usingFormParameters() {
HttpClient client = new HttpClient(BASE_URI + "peoplepage/post");
client.setRequestMediaType("application/x-www-form-urlencoded");
// add parameters' info
client.addRequestParameter("firstName", "Chuck");
client.addRequestParameter("lastName", "Norris");
client.addRequestParameter("age", "70");
// send the data
HttpResponse response = client.post();
// check the status code is "201 CREATED"
response.verifyStatusCode(201);
// check the returned result to make sure the server accepted the data we sent
assertTrue(response.getBodyAsString().startsWith("Saved Person with name Chuck Norris at 70 years"));
}
Aggregations