PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/src/test/java/HttpClientPut.java

https://gitlab.com/GavinGJ/MATIRX
Java | 50 lines | 25 code | 13 blank | 12 comment | 0 complexity | 76e0a3e5ef3faecccae406cda5a3489e MD5 | raw file
  1. import org.apache.http.HttpResponse;
  2. import org.apache.http.client.HttpClient;
  3. import org.apache.http.client.methods.HttpPut;
  4. import org.apache.http.entity.StringEntity;
  5. import org.apache.http.impl.client.HttpClientBuilder;
  6. import org.junit.Test;
  7. import com.alibaba.fastjson.JSONObject;
  8. import com.danlu.matrix.model.issue;
  9. public class HttpClientPut {
  10. @Test
  11. public void testUpdate() throws Exception {
  12. /**
  13. * 1.谁执行的操作
  14. * 2.在[?]环境[?]微服务[?]版本
  15. * 3.执行了什么操�?
  16. *
  17. * admin (update/delete/add) ed (some.properties) in (env,app,version) at (sometime)
  18. *
  19. * updateRedmine(key,operation,properties,env,app,version,time);
  20. *
  21. */
  22. JSONObject jo = new JSONObject();
  23. issue issue = new issue();
  24. issue.setNotes("哎,中文终于可以了~~~~~~");
  25. // issue.setNotes("admin (update/delete/add) ed (some.properties) in (env,app,version) at (sometime)");
  26. //修改主题 issue.setSubject("yike test");
  27. jo.put("issue", issue);
  28. String url = "http://182.92.230.201:3000/issues/6186.json?key=1d893519a4674aa4644704c3f8c86003249db597";
  29. HttpClient client = HttpClientBuilder.create().build();
  30. HttpPut put = new HttpPut(url);
  31. put.setHeader("Content-type","application/json;charset=utf-8");
  32. StringEntity params = new StringEntity(jo.toString(),"utf-8");
  33. put.setEntity(params);
  34. HttpResponse response = client.execute(put);
  35. System.out.println("Response Code:" + response.getStatusLine().getStatusCode());
  36. }
  37. }