diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilderClientHttpRequestInitializer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilderClientHttpRequestInitializer.java index 596c2fab4ba..3d61be72a34 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilderClientHttpRequestInitializer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilderClientHttpRequestInitializer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,11 +23,10 @@ import java.util.Set; import org.springframework.boot.util.LambdaSafe; import org.springframework.http.HttpHeaders; import org.springframework.http.client.ClientHttpRequest; -import org.springframework.http.client.ClientHttpRequestFactory; import org.springframework.http.client.ClientHttpRequestInitializer; /** - * {@link ClientHttpRequestFactory} to apply customizations from the + * {@link ClientHttpRequestInitializer} to apply customizations from the * {@link RestTemplateBuilder}. * * @author Dmytro Nosan diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-ui/src/test/java/smoketest/actuator/ui/SampleActuatorUiApplicationPortTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-ui/src/test/java/smoketest/actuator/ui/SampleActuatorUiApplicationPortTests.java index d2bd9e6593d..80730806649 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-ui/src/test/java/smoketest/actuator/ui/SampleActuatorUiApplicationPortTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-ui/src/test/java/smoketest/actuator/ui/SampleActuatorUiApplicationPortTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import java.util.Map; import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.client.TestRestTemplate; @@ -44,9 +45,12 @@ class SampleActuatorUiApplicationPortTests { @LocalManagementPort private int managementPort; + @Autowired + private TestRestTemplate testRestTemplate; + @Test void testHome() { - ResponseEntity entity = new TestRestTemplate().getForEntity("http://localhost:" + this.port, + ResponseEntity entity = this.testRestTemplate.getForEntity("http://localhost:" + this.port, String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); } @@ -54,14 +58,14 @@ class SampleActuatorUiApplicationPortTests { @Test void testMetrics() { @SuppressWarnings("rawtypes") - ResponseEntity entity = new TestRestTemplate() + ResponseEntity entity = this.testRestTemplate .getForEntity("http://localhost:" + this.managementPort + "/actuator/metrics", Map.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED); } @Test void testHealth() { - ResponseEntity entity = new TestRestTemplate().withBasicAuth("user", getPassword()) + ResponseEntity entity = this.testRestTemplate.withBasicAuth("user", getPassword()) .getForEntity("http://localhost:" + this.managementPort + "/actuator/health", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()).contains("\"status\":\"UP\""); diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-method-security/src/test/java/smoketest/security/method/SampleMethodSecurityApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-method-security/src/test/java/smoketest/security/method/SampleMethodSecurityApplicationTests.java index c84ea18c934..48309081eb5 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-method-security/src/test/java/smoketest/security/method/SampleMethodSecurityApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-method-security/src/test/java/smoketest/security/method/SampleMethodSecurityApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,7 +56,7 @@ class SampleMethodSecurityApplicationTests { void testHome() { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Collections.singletonList(MediaType.TEXT_HTML)); - ResponseEntity entity = this.restTemplate.exchange("/", HttpMethod.GET, new HttpEntity(headers), + ResponseEntity entity = this.restTemplate.exchange("/", HttpMethod.GET, new HttpEntity<>(headers), String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); } @@ -87,7 +87,7 @@ class SampleMethodSecurityApplicationTests { String cookie = entity.getHeaders().getFirst("Set-Cookie"); headers.set("Cookie", cookie); ResponseEntity page = this.restTemplate.exchange(entity.getHeaders().getLocation(), HttpMethod.GET, - new HttpEntity(headers), String.class); + new HttpEntity<>(headers), String.class); assertThat(page.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN); assertThat(page.getBody()).contains("Access denied"); } @@ -97,7 +97,7 @@ class SampleMethodSecurityApplicationTests { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); ResponseEntity entity = this.restTemplate.exchange("/actuator/beans", HttpMethod.GET, - new HttpEntity(headers), String.class); + new HttpEntity<>(headers), String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED); }