use of org.apache.http.client.methods.HttpPost in project camel by apache.
the class RestletContentTypeTest method postRequestMessage.
private void postRequestMessage(String message) throws Exception {
HttpPost post = new HttpPost("http://localhost:" + portNum + "/users/");
post.addHeader(Exchange.CONTENT_TYPE, "text/xml");
post.setEntity(new StringEntity(message));
HttpResponse response = doExecute(post);
assertHttpResponse(response, 200, "text/xml");
String s = context.getTypeConverter().convertTo(String.class, response.getEntity().getContent());
assertEquals("<status>OK</status>", s);
}
use of org.apache.http.client.methods.HttpPost in project camel by apache.
the class RestletMultiUriTemplatesEndpointTest method testPostUserUriPattern.
@Test
public void testPostUserUriPattern() throws Exception {
HttpResponse response = doExecute(new HttpPost("http://localhost:" + portNum + "/users/homer"));
assertHttpResponse(response, 200, "text/plain", "POST homer");
}
use of org.apache.http.client.methods.HttpPost in project camel by apache.
the class RestletPostFormTest method testPostBody.
@Test
public void testPostBody() throws Exception {
HttpUriRequest method = new HttpPost("http://localhost:" + portNum + "/users");
List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
urlParameters.add(new BasicNameValuePair("foo", "bar"));
((HttpEntityEnclosingRequestBase) method).setEntity(new UrlEncodedFormEntity(urlParameters));
HttpResponse response = doExecute(method);
assertHttpResponse(response, 200, "text/plain");
}
use of org.apache.http.client.methods.HttpPost in project camel by apache.
the class RestletPostXmlTest method postRequestMessage.
private void postRequestMessage(String message) throws Exception {
HttpPost post = new HttpPost("http://localhost:" + portNum + "/users/");
post.addHeader(Exchange.CONTENT_TYPE, "application/xml");
post.setEntity(new StringEntity(message));
HttpResponse response = doExecute(post);
assertHttpResponse(response, 200, "application/xml");
String s = context.getTypeConverter().convertTo(String.class, response.getEntity().getContent());
assertEquals("<status>OK</status>", s);
}
use of org.apache.http.client.methods.HttpPost in project camel by apache.
the class RestletResponseTest method getCustomResponse.
private void getCustomResponse(String address) throws Exception {
HttpResponse response = doExecute(new HttpPost("http://localhost:" + portNum + address));
assertHttpResponse(response, 417, "application/JSON");
String s = response.getFirstHeader(HeaderConstants.HEADER_CACHE_CONTROL).toString().toLowerCase(Locale.US);
assertEquals("Get a wrong http header", "cache-control: max-age=20", s);
}
Aggregations