use of com.axway.ats.action.http.HttpClient in project ats-framework by Axway.
the class HttpOperationTests method delete_usingPathParam.
/**
* A DELETE using path parameters.
*
* In this case all needed is to point to the resource to be deleted.
*
* Our server expects the the first name of the person to be deleted.
*/
@Test
public void delete_usingPathParam() {
createPersonToManipulateInTheTest();
final String firstNameParam = "Chuck";
HttpClient client = new HttpClient(BASE_URI + "peoplepage/delete");
client.addResourcePath("Chuck");
HttpResponse response = client.delete();
assertEquals(response.getStatusCode(), 200);
assertTrue(response.getBodyAsString().startsWith("Deleted person with first name " + firstNameParam));
}
use of com.axway.ats.action.http.HttpClient 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"));
}
use of com.axway.ats.action.http.HttpClient in project ats-framework by Axway.
the class FileTransferTests method beforeClass.
@BeforeClass
public void beforeClass() {
// This step is needed for the HTTP tests only.
// We tell the remote HTTP server the folder to store to and read files from.
// Of course, you can find a nicer way to do that.
HttpClient httpClient = new HttpClient("http://" + configuration.getServerIp() + ":" + configuration.getHttpServerPort() + "/" + configuration.getHttpServerWebappWar() + "/transfers/");
httpClient.addRequestHeader("repository", UPLOADS_DIR);
httpClient.put();
httpClient.close();
}
Aggregations