@Test public void testRestTemplateClient() throws Exception { String[] uriVariables = {"aaaa签名", "001"}; ResponseEntity<String> exchange = restTemplate.exchange(TEST_URL_ONE, HttpMethod.POST, null, String.class, uriVariables); log.info(exchange.getBody()); assertEquals(exchange.getStatusCode(), HttpStatus.OK); }
/** * 测试一次捕获 * * @throws Exception */ @Test public void testTestException() throws Exception { Map<String, String> uriVariables = new HashMap<String, String>(); uriVariables.put("type", "1"); ResponseEntity<String> responseEntity = restTemplate.getForEntity(TEST_URL_TWO, String.class, uriVariables); log.info(responseEntity.getBody()); assertEquals(responseEntity.getBody(), "{\"code\":\"-1\",\"msg\":\"system bus\"}"); }