File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
spring-boot-modules/spring-boot-3-2
src/test/java/com/baeldung/restclient Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 15
15
</parent >
16
16
17
17
<dependencies >
18
+ <!-- https://mvnrepository.com/artifact/org.springframework/spring-web -->
19
+ <dependency >
20
+ <groupId >org.springframework</groupId >
21
+ <artifactId >spring-web</artifactId >
22
+ <version >6.2.3</version >
23
+ </dependency >
24
+ <dependency >
25
+ <groupId >org.springframework</groupId >
26
+ <artifactId >spring-core</artifactId >
27
+ <version >6.2.3</version >
28
+ </dependency >
18
29
<dependency >
19
30
<groupId >org.springframework.boot</groupId >
20
31
<artifactId >spring-boot-starter-web</artifactId >
32
+ <version >3.4.3</version >
21
33
</dependency >
22
34
<dependency >
23
35
<groupId >org.springframework.boot</groupId >
93
105
<dependency >
94
106
<groupId >org.springframework.boot</groupId >
95
107
<artifactId >spring-boot-starter-test</artifactId >
108
+ <version >3.4.3</version >
96
109
</dependency >
97
110
<dependency >
98
111
<groupId >org.postgresql</groupId >
Original file line number Diff line number Diff line change
1
+ package com .baeldung .restclient ;
2
+
3
+
4
+ import org .junit .jupiter .api .Test ;
5
+ import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
6
+
7
+ import org .springframework .http .HttpMethod ;
8
+ import org .springframework .http .HttpRequest ;
9
+ import org .springframework .http .client .ClientHttpRequestInterceptor ;
10
+ import org .springframework .http .client .ClientHttpResponse ;
11
+ import org .springframework .http .client .ClientHttpRequest ;
12
+ import org .springframework .http .client .support .HttpRequestWrapper ;
13
+
14
+
15
+ class InterceptingClientHttpRequestTest {
16
+
17
+ @ Test
18
+ void updateRequestAttribute () throws Exception {
19
+ String attrName = "attr1" ;
20
+ String attrValue = "value1" ;
21
+
22
+ assertDoesNotThrow (() -> {
23
+ ClientHttpRequestInterceptor interceptor = (request , body , execution ) -> {
24
+ request .getAttributes ().put (attrName , attrValue );
25
+ return execution .execute (request , body );
26
+ };
27
+ });
28
+ }
29
+ }
You can’t perform that action at this time.
0 commit comments