1
1
/*
2
- * Copyright 2002-2024 the original author or authors.
2
+ * Copyright 2002-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
23
23
import org .springframework .util .ObjectUtils ;
24
24
import org .springframework .web .bind .annotation .RequestHeader ;
25
25
import org .springframework .web .service .annotation .GetExchange ;
26
+ import org .springframework .web .service .annotation .HttpExchange ;
26
27
27
28
import static org .assertj .core .api .Assertions .assertThat ;
28
29
32
33
*
33
34
* @author Olga Maciaszek-Sharma
34
35
* @author Rossen Stoyanchev
36
+ * @author Yanming Zhou
35
37
*/
36
38
class RequestHeaderArgumentResolverTests {
37
39
@@ -49,6 +51,12 @@ void header() {
49
51
assertRequestHeaders ("id" , "test" );
50
52
}
51
53
54
+ @ Test
55
+ void doesNotOverrideAnnotationHeaders () {
56
+ this .service .executeWithAnnotationHeaders ("test" );
57
+ assertRequestHeaders ("id" , "default" , "test" );
58
+ }
59
+
52
60
private void assertRequestHeaders (String key , String ... values ) {
53
61
List <String > actualValues = this .client .getRequestValues ().getHeaders ().get (key );
54
62
if (ObjectUtils .isEmpty (values )) {
@@ -65,6 +73,9 @@ private interface Service {
65
73
@ GetExchange
66
74
void execute (@ RequestHeader String id );
67
75
76
+ @ HttpExchange (method = "GET" , headers = "id=default" )
77
+ void executeWithAnnotationHeaders (@ RequestHeader String id );
78
+
68
79
}
69
80
70
81
}
0 commit comments