Example usage for org.springframework.web.client RestTemplate setUriTemplateHandler

List of usage examples for org.springframework.web.client RestTemplate setUriTemplateHandler

Introduction

In this page you can find the example usage for org.springframework.web.client RestTemplate setUriTemplateHandler.

Prototype

public void setUriTemplateHandler(UriTemplateHandler handler) 

Source Link

Document

Configure a strategy for expanding URI templates.

Usage

From source file:org.springframework.boot.test.web.client.TestRestTemplate.java

/**
 * Creates a new {@code TestRestTemplate} with the same configuration as this one,
 * except that it will send basic authorization headers using the given
 * {@code username} and {@code password}.
 * @param username the username/*w ww .  ja  v a2s. c  o  m*/
 * @param password the password
 * @return the new template
 * @since 1.4.1
 */
public TestRestTemplate withBasicAuth(String username, String password) {
    RestTemplate restTemplate = new RestTemplate();
    restTemplate.setMessageConverters(getRestTemplate().getMessageConverters());
    restTemplate.setInterceptors(getRestTemplate().getInterceptors());
    restTemplate.setRequestFactory(getRestTemplate().getRequestFactory());
    restTemplate.setUriTemplateHandler(getRestTemplate().getUriTemplateHandler());
    TestRestTemplate testRestTemplate = new TestRestTemplate(restTemplate, username, password,
            this.httpClientOptions);
    testRestTemplate.getRestTemplate().setErrorHandler(getRestTemplate().getErrorHandler());
    return testRestTemplate;
}