Skip to content

Commit 8feba56

Browse files
committed
Polish
1 parent 575dae7 commit 8feba56

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilderClientHttpRequestInitializer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,11 +23,10 @@
2323
import org.springframework.boot.util.LambdaSafe;
2424
import org.springframework.http.HttpHeaders;
2525
import org.springframework.http.client.ClientHttpRequest;
26-
import org.springframework.http.client.ClientHttpRequestFactory;
2726
import org.springframework.http.client.ClientHttpRequestInitializer;
2827

2928
/**
30-
* {@link ClientHttpRequestFactory} to apply customizations from the
29+
* {@link ClientHttpRequestInitializer} to apply customizations from the
3130
* {@link RestTemplateBuilder}.
3231
*
3332
* @author Dmytro Nosan

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-ui/src/test/java/smoketest/actuator/ui/SampleActuatorUiApplicationPortTests.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
2020

2121
import org.junit.jupiter.api.Test;
2222

23+
import org.springframework.beans.factory.annotation.Autowired;
2324
import org.springframework.boot.test.context.SpringBootTest;
2425
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
2526
import org.springframework.boot.test.web.client.TestRestTemplate;
@@ -44,24 +45,27 @@ class SampleActuatorUiApplicationPortTests {
4445
@LocalManagementPort
4546
private int managementPort;
4647

48+
@Autowired
49+
private TestRestTemplate testRestTemplate;
50+
4751
@Test
4852
void testHome() {
49-
ResponseEntity<String> entity = new TestRestTemplate().getForEntity("http://localhost:" + this.port,
53+
ResponseEntity<String> entity = this.testRestTemplate.getForEntity("http://localhost:" + this.port,
5054
String.class);
5155
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
5256
}
5357

5458
@Test
5559
void testMetrics() {
5660
@SuppressWarnings("rawtypes")
57-
ResponseEntity<Map> entity = new TestRestTemplate()
61+
ResponseEntity<Map> entity = this.testRestTemplate
5862
.getForEntity("http://localhost:" + this.managementPort + "/actuator/metrics", Map.class);
5963
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
6064
}
6165

6266
@Test
6367
void testHealth() {
64-
ResponseEntity<String> entity = new TestRestTemplate().withBasicAuth("user", getPassword())
68+
ResponseEntity<String> entity = this.testRestTemplate.withBasicAuth("user", getPassword())
6569
.getForEntity("http://localhost:" + this.managementPort + "/actuator/health", String.class);
6670
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
6771
assertThat(entity.getBody()).contains("\"status\":\"UP\"");

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-method-security/src/test/java/smoketest/security/method/SampleMethodSecurityApplicationTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -56,7 +56,7 @@ class SampleMethodSecurityApplicationTests {
5656
void testHome() {
5757
HttpHeaders headers = new HttpHeaders();
5858
headers.setAccept(Collections.singletonList(MediaType.TEXT_HTML));
59-
ResponseEntity<String> entity = this.restTemplate.exchange("/", HttpMethod.GET, new HttpEntity<Void>(headers),
59+
ResponseEntity<String> entity = this.restTemplate.exchange("/", HttpMethod.GET, new HttpEntity<>(headers),
6060
String.class);
6161
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
6262
}
@@ -87,7 +87,7 @@ void testDenied() {
8787
String cookie = entity.getHeaders().getFirst("Set-Cookie");
8888
headers.set("Cookie", cookie);
8989
ResponseEntity<String> page = this.restTemplate.exchange(entity.getHeaders().getLocation(), HttpMethod.GET,
90-
new HttpEntity<Void>(headers), String.class);
90+
new HttpEntity<>(headers), String.class);
9191
assertThat(page.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN);
9292
assertThat(page.getBody()).contains("Access denied");
9393
}
@@ -97,7 +97,7 @@ void testManagementProtected() {
9797
HttpHeaders headers = new HttpHeaders();
9898
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
9999
ResponseEntity<String> entity = this.restTemplate.exchange("/actuator/beans", HttpMethod.GET,
100-
new HttpEntity<Void>(headers), String.class);
100+
new HttpEntity<>(headers), String.class);
101101
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
102102
}
103103

0 commit comments

Comments
 (0)