[url]http://hc.apache.org/httpcomponents-client-4.5.x/examples.html[/url]
@Test
public void test_login(){
CloseableHttpClient httpclient = HttpClients.createDefault();
CloseableHttpResponse response = null;
try{
HttpUriRequest login = RequestBuilder.post()
.setUri(new URI(path+"/api/login"))
.addParameter("mobile", "15311111111")
.addParameter("password", "123456")
.build();
response = httpclient.execute(login);
HttpEntity entity = response.getEntity();
System.out.println("TEST Login form get: " + response.getStatusLine());
String jsonstr = EntityUtils.toString(entity);
logger.info("TEST response:"+response.getStatusLine());
logger.info("TEST output: response:"+jsonstr);
response.close();
httpclient.close();
}catch (Exception e){
e.printStackTrace();
}
}