use of org.apache.http.client.HttpClient in project eap-additional-testsuite by jboss-set.
the class UndertowSslSecurityDomainTestCase method testForbidden.
/**
* Tests access to resource that requires authentication and authorization. Principal has not required role.
*/
@Test
public void testForbidden() {
HttpClient client = SSLTruststoreUtil.getHttpClientWithSSL(CLIENT_KEYSTORE_FILE, PASSWORD, CLIENT_TRUSTSTORE_FILE, PASSWORD);
assertAccessForbidden(client);
closeClient(client);
}
use of org.apache.http.client.HttpClient in project eap-additional-testsuite by jboss-set.
the class UndertowTwoWaySslNeedClientAuthTestCase method testSendingTrustedClientCertificate.
@Test
public void testSendingTrustedClientCertificate() {
HttpClient client = SSLTruststoreUtil.getHttpClientWithSSL(CLIENT_KEYSTORE_FILE, PASSWORD, CLIENT_TRUSTSTORE_FILE, PASSWORD);
assertConnectionToServer(client, SC_OK);
closeClient(client);
}
use of org.apache.http.client.HttpClient in project eap-additional-testsuite by jboss-set.
the class UndertowTwoWaySslNeedClientAuthTestCase method testSendingNonTrustedClientCertificateFails.
@Test
public void testSendingNonTrustedClientCertificateFails() {
HttpClient client = SSLTruststoreUtil.getHttpClientWithSSL(UNTRUSTED_STORE_FILE, PASSWORD, CLIENT_TRUSTSTORE_FILE, PASSWORD);
assertSslHandshakeFails(client);
closeClient(client);
}
use of org.apache.http.client.HttpClient in project uavstack by uavorg.
the class DoTestOpenTSDBQuery method main.
@SuppressWarnings("resource")
public static void main(String[] args) throws ClientProtocolException, IOException {
String queryurl = "http://localhost:8765/hm/query";
HttpPost post = new HttpPost(queryurl);
HttpClient client = new DefaultHttpClient();
UAVHttpMessage request = new UAVHttpMessage();
request.putRequest("start", "146234606");
request.putRequest("end", "1462346020");
request.putRequest("metric", "urlResp.tmax");
request.putRequest("aggregator", "sum");
request.putRequest("downsample", "1ms-avg");
LinkedHashMap<String, String> tags = new LinkedHashMap<String, String>();
tags.put("ip", "127.0.0.1");
request.putRequest("tags", JSONHelper.toString(tags));
request.putRequest(DataStoreProtocol.DATASTORE_NAME, HealthManagerConstants.DataStore_Monitor);
String queryJson = JSONHelper.toString(request);
// String queryJson = "{\"request\":"
// +"{\"start\":\"1461908927\",\"end\":\"1461908932\","
// +"\"datastore.name\":\"monitorDataStore\","
// +"\"queries\":[{"
// +"\"aggregator\":\"sum\","
// +"\"metric\":\"urlResp.tmax\","
// +"\"downsample\":\"1ms-avg\","
// +"\"tags\":{\"ip\":\"127.0.0.1\"}"
// +"}]"
// +"},"
// +"\"responseAsJsonString\":\"{}\"}";
StringEntity entity = new StringEntity(queryJson);
post.setEntity(entity);
HttpResponse response = client.execute(post);
if (response != null) {
HttpEntity resEntity = response.getEntity();
if (resEntity != null) {
String result = EntityUtils.toString(resEntity);
LOG.info(result);
}
}
}
use of org.apache.http.client.HttpClient in project summer-bean by cn-cerc.
the class RemoteService method postData.
private String postData(String url, String params) throws ClientProtocolException, IOException {
HttpPost httpPost = new HttpPost(url);
StringEntity entity = new StringEntity(params.toString(), "UTF-8");
entity.setContentType("application/json");
httpPost.setEntity(entity);
log.debug("post: " + url);
HttpClient client = HttpClientBuilder.create().build();
HttpResponse response = client.execute(httpPost);
// 如果请求成功
if (response.getStatusLine().getStatusCode() != 200) {
this.setMessage("请求服务器失败,错误代码为:" + response.getStatusLine().getStatusCode());
return null;
}
// 获取响应实体
HttpEntity entity2 = response.getEntity();
return EntityUtils.toString(entity2, "UTF-8");
}
Aggregations