use of org.springframework.boot.web.client.RestTemplateBuilder in project spring-boot by spring-projects.
the class TestRestTemplateTests method doNotReplaceCustomRequestFactory.
@Test
void doNotReplaceCustomRequestFactory() {
RestTemplateBuilder builder = new RestTemplateBuilder().requestFactory(OkHttp3ClientHttpRequestFactory.class);
TestRestTemplate testRestTemplate = new TestRestTemplate(builder);
assertThat(testRestTemplate.getRestTemplate().getRequestFactory()).isInstanceOf(OkHttp3ClientHttpRequestFactory.class);
}
use of org.springframework.boot.web.client.RestTemplateBuilder in project spring-boot by spring-projects.
the class TestRestTemplateTests method fromRestTemplateBuilder.
@Test
void fromRestTemplateBuilder() {
RestTemplateBuilder builder = mock(RestTemplateBuilder.class);
RestTemplate delegate = new RestTemplate();
given(builder.build()).willReturn(delegate);
assertThat(new TestRestTemplate(builder).getRestTemplate()).isEqualTo(delegate);
}
use of org.springframework.boot.web.client.RestTemplateBuilder in project spring-boot by spring-projects.
the class CloudFoundrySecurityServiceTests method doNotSkipSslValidationWhenFalse.
@Test
void doNotSkipSslValidationWhenFalse() {
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);
}
use of org.springframework.boot.web.client.RestTemplateBuilder in project tutorials by eugenp.
the class TestRestTemplateBasicLiveTest method givenRestTemplateBuilderWrapper_whenSendGetForEntity_thenStatusOk.
@Test
public void givenRestTemplateBuilderWrapper_whenSendGetForEntity_thenStatusOk() {
RestTemplateBuilder restTemplateBuilder = new RestTemplateBuilder();
restTemplateBuilder.build();
TestRestTemplate testRestTemplate = new TestRestTemplate(restTemplateBuilder);
ResponseEntity<String> response = testRestTemplate.getForEntity(FOO_RESOURCE_URL + "/1", String.class);
assertThat(response.getStatusCode(), equalTo(HttpStatus.OK));
}
use of org.springframework.boot.web.client.RestTemplateBuilder in project java-spring-web by opentracing-contrib.
the class MVCJettyITest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
jettyServer = new Server(0);
WebAppContext webApp = new WebAppContext();
webApp.setServer(jettyServer);
webApp.setContextPath(CONTEXT_PATH);
webApp.setWar("src/test/webapp");
jettyServer.setHandler(webApp);
jettyServer.start();
serverPort = ((ServerConnector) jettyServer.getConnectors()[0]).getLocalPort();
testRestTemplate = new TestRestTemplate(new RestTemplateBuilder().rootUri("http://localhost:" + serverPort + CONTEXT_PATH));
}
Aggregations