Search in sources :

Example 6 with RestTemplateBuilder

use of org.springframework.boot.web.client.RestTemplateBuilder in project spring-boot by spring-projects.

the class CloudFoundrySecurityServiceTests method setup.

@Before
public void setup() throws Exception {
    MockServerRestTemplateCustomizer mockServerCustomizer = new MockServerRestTemplateCustomizer();
    RestTemplateBuilder builder = new RestTemplateBuilder(mockServerCustomizer);
    this.securityService = new CloudFoundrySecurityService(builder, CLOUD_CONTROLLER, false);
    this.server = mockServerCustomizer.getServer();
}
Also used : RestTemplateBuilder(org.springframework.boot.web.client.RestTemplateBuilder) MockServerRestTemplateCustomizer(org.springframework.boot.test.web.client.MockServerRestTemplateCustomizer) Before(org.junit.Before)

Example 7 with RestTemplateBuilder

use of org.springframework.boot.web.client.RestTemplateBuilder in project spring-boot by spring-projects.

the class CloudFoundrySecurityServiceTests method skipSslValidationWhenTrue.

@Test
public void skipSslValidationWhenTrue() throws Exception {
    RestTemplateBuilder builder = new RestTemplateBuilder();
    this.securityService = new CloudFoundrySecurityService(builder, CLOUD_CONTROLLER, true);
    RestTemplate restTemplate = (RestTemplate) ReflectionTestUtils.getField(this.securityService, "restTemplate");
    assertThat(restTemplate.getRequestFactory()).isInstanceOf(SkipSslVerificationHttpRequestFactory.class);
}
Also used : RestTemplateBuilder(org.springframework.boot.web.client.RestTemplateBuilder) RestTemplate(org.springframework.web.client.RestTemplate) Test(org.junit.Test)

Example 8 with RestTemplateBuilder

use of org.springframework.boot.web.client.RestTemplateBuilder in project spring-boot by spring-projects.

the class CloudFoundrySecurityServiceTests method doNotskipSslValidationWhenFalse.

@Test
public void doNotskipSslValidationWhenFalse() throws Exception {
    RestTemplateBuilder builder = new RestTemplateBuilder();
    this.securityService = new CloudFoundrySecurityService(builder, CLOUD_CONTROLLER, false);
    RestTemplate restTemplate = (RestTemplate) ReflectionTestUtils.getField(this.securityService, "restTemplate");
    assertThat(restTemplate.getRequestFactory()).isNotInstanceOf(SkipSslVerificationHttpRequestFactory.class);
}
Also used : RestTemplateBuilder(org.springframework.boot.web.client.RestTemplateBuilder) RestTemplate(org.springframework.web.client.RestTemplate) Test(org.junit.Test)

Example 9 with RestTemplateBuilder

use of org.springframework.boot.web.client.RestTemplateBuilder in project spring-boot by spring-projects.

the class RootUriRequestExpectationManagerTests method bindToShouldReturnMockRestServiceServer.

@Test
public void bindToShouldReturnMockRestServiceServer() throws Exception {
    RestTemplate restTemplate = new RestTemplateBuilder().build();
    MockRestServiceServer bound = RootUriRequestExpectationManager.bindTo(restTemplate);
    assertThat(bound).isNotNull();
}
Also used : RestTemplateBuilder(org.springframework.boot.web.client.RestTemplateBuilder) RestTemplate(org.springframework.web.client.RestTemplate) MockRestServiceServer(org.springframework.test.web.client.MockRestServiceServer) Test(org.junit.Test)

Example 10 with RestTemplateBuilder

use of org.springframework.boot.web.client.RestTemplateBuilder in project spring-boot by spring-projects.

the class TestRestTemplateTests method fromRestTemplateBuilder.

@Test
public void fromRestTemplateBuilder() {
    RestTemplateBuilder builder = mock(RestTemplateBuilder.class);
    RestTemplate delegate = new RestTemplate();
    given(builder.build()).willReturn(delegate);
    assertThat(new TestRestTemplate(builder).getRestTemplate()).isEqualTo(delegate);
}
Also used : RestTemplateBuilder(org.springframework.boot.web.client.RestTemplateBuilder) RestTemplate(org.springframework.web.client.RestTemplate) Test(org.junit.Test)

Aggregations

RestTemplateBuilder (org.springframework.boot.web.client.RestTemplateBuilder)14 Test (org.junit.Test)12 RestTemplate (org.springframework.web.client.RestTemplate)10 MockRestServiceServer (org.springframework.test.web.client.MockRestServiceServer)4 RequestExpectationManager (org.springframework.test.web.client.RequestExpectationManager)2 Before (org.junit.Before)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 HttpMessageConverters (org.springframework.boot.autoconfigure.http.HttpMessageConverters)1 MockServerRestTemplateCustomizer (org.springframework.boot.test.web.client.MockServerRestTemplateCustomizer)1 RestTemplateCustomizer (org.springframework.boot.web.client.RestTemplateCustomizer)1 Bean (org.springframework.context.annotation.Bean)1