Map<String, Object> params=new HashMap<>();
params.put("name", "admin");
params.put("password", "admin");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.parseMediaType("application/json; charset=UTF-8"));
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
HttpEntity<String> httpEntity = new HttpEntity<>(JSONObject.toJSONString(params), headers);
RestTemplate rst = new RestTemplate();
String url = "http://localhost:8001/login";
ResponseEntity<String> stringResponseEntity = rst.postForEntity(url, httpEntity, String.class);
//返回状态
Assert.assertEquals(200,stringResponseEntity.getStatusCodeValue());
JSONObject repJson = JSONObject.parseObject(stringResponseEntity.getBody());
//解析json
Assert.assertTrue(repJson.getBoolean("success"));
token = repJson.getString("token");