List of usage examples for org.springframework.boot.test.web.client TestRestTemplate postForEntity
public <T> ResponseEntity<T> postForEntity(URI url, Object request, Class<T> responseType) throws RestClientException
From source file:org.springframework.cloud.netflix.zuul.filters.route.support.ZuulProxyTestBase.java
@SuppressWarnings("deprecation") @Test/*from w w w. j a v a2s . com*/ public void javascriptEncodedFormParams() { TestRestTemplate testRestTemplate = new TestRestTemplate(); ArrayList<HttpMessageConverter<?>> converters = new ArrayList<>(); converters .addAll(Arrays.asList(new StringHttpMessageConverter(), new NoEncodingFormHttpMessageConverter())); testRestTemplate.getRestTemplate().setMessageConverters(converters); MultiValueMap<String, String> map = new LinkedMultiValueMap<>(); map.add("foo", "(bar)"); ResponseEntity<String> result = testRestTemplate .postForEntity("http://localhost:" + this.port + "/simple/local", map, String.class); assertEquals(HttpStatus.OK, result.getStatusCode()); assertEquals("Posted [(bar)] and Content-Length was: 13!", result.getBody()); }