List of usage examples for org.springframework.mock.http.client MockClientHttpRequest setResponse
public void setResponse(ClientHttpResponse clientHttpResponse)
From source file:org.springframework.boot.test.web.client.TestRestTemplateTests.java
private void verifyRelativeUriHandling(TestRestTemplateCallback callback) throws IOException { ClientHttpRequestFactory requestFactory = mock(ClientHttpRequestFactory.class); MockClientHttpRequest request = new MockClientHttpRequest(); request.setResponse(new MockClientHttpResponse(new byte[0], HttpStatus.OK)); URI absoluteUri = URI.create("http://localhost:8080/a/b/c.txt?param=%7Bsomething%7D"); given(requestFactory.createRequest(eq(absoluteUri), (HttpMethod) any())).willReturn(request); RestTemplate delegate = new RestTemplate(); TestRestTemplate template = new TestRestTemplate(delegate); delegate.setRequestFactory(requestFactory); LocalHostUriTemplateHandler uriTemplateHandler = new LocalHostUriTemplateHandler(new MockEnvironment()); template.setUriTemplateHandler(uriTemplateHandler); callback.doWithTestRestTemplate(template, URI.create("/a/b/c.txt?param=%7Bsomething%7D")); verify(requestFactory).createRequest(eq(absoluteUri), (HttpMethod) any()); }