Skip to content

Commit 2730d77

Browse files
committed
Polishing contribution
Closes gh-34993
1 parent 4a64537 commit 2730d77

5 files changed

Lines changed: 10 additions & 21 deletions

File tree

spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
import jakarta.servlet.http.Cookie;
3232
import org.assertj.core.api.ThrowingConsumer;
3333
import org.junit.jupiter.api.Test;
34-
import org.junit.jupiter.params.ParameterizedTest;
35-
import org.junit.jupiter.params.provider.ValueSource;
3634

3735
import org.springframework.http.HttpHeaders;
3836
import org.springframework.http.HttpMethod;
@@ -420,21 +418,18 @@ void requestParameterFromMultiValueMap() {
420418
assertThat(request.getParameterMap().get("foo")).containsExactly("bar", "baz");
421419
}
422420

423-
@ValueSource(strings = {"POST", "QUERY"})
424-
@ParameterizedTest()
425-
void requestParameterFromRequestBodyFormData(String methodName) {
421+
@Test
422+
void requestParameterFromRequestBodyFormData() {
426423
String contentType = "application/x-www-form-urlencoded;charset=UTF-8";
427424
String body = "name+1=value+1&name+2=value+A&name+2=value+B&name+3";
428425

429-
HttpMethod method = HttpMethod.valueOf(methodName);
430-
MockHttpServletRequest request = new MockHttpServletRequestBuilder(method).uri("/foo")
426+
MockHttpServletRequest request = new MockHttpServletRequestBuilder(POST).uri("/foo")
431427
.contentType(contentType).content(body.getBytes(UTF_8))
432428
.buildRequest(this.servletContext);
433429

434430
assertThat(request.getParameterMap().get("name 1")).containsExactly("value 1");
435431
assertThat(request.getParameterMap().get("name 2")).containsExactly("value A", "value B");
436432
assertThat(request.getParameterMap().get("name 3")).containsExactly((String) null);
437-
438433
}
439434

440435
@Test

spring-web/src/main/java/org/springframework/http/HttpHeaders.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,17 @@ public class HttpHeaders implements Serializable {
124124
* @see <a href="https://tools.ietf.org/html/rfc5789#section-3.1">Section 3.1 of RFC 5789</a>
125125
*/
126126
public static final String ACCEPT_PATCH = "Accept-Patch";
127-
/**
128-
* The HTTP {@code Accept-Ranges} header field name.
129-
* @see <a href="https://tools.ietf.org/html/rfc7233#section-2.3">Section 5.3.5 of RFC 7233</a>
130-
*/
131-
public static final String ACCEPT_RANGES = "Accept-Ranges";
132-
133127
/**
134128
* The HTTP {@code Accept-Query} header field name.
135129
* @since 7.1
136130
* @see <a href="https://www.rfc-editor.org/rfc/rfc10008.html#section-3">Section 3 of RFC 10008</a>
137131
*/
138132
public static final String ACCEPT_QUERY = "Accept-Query";
133+
/**
134+
* The HTTP {@code Accept-Ranges} header field name.
135+
* @see <a href="https://tools.ietf.org/html/rfc7233#section-2.3">Section 5.3.5 of RFC 7233</a>
136+
*/
137+
public static final String ACCEPT_RANGES = "Accept-Ranges";
139138
/**
140139
* The CORS {@code Access-Control-Allow-Credentials} response header field name.
141140
* @see <a href="https://www.w3.org/TR/cors/">CORS W3C recommendation</a>

spring-web/src/main/java/org/springframework/web/HttpMediaTypeNotSupportedException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public HttpHeaders getHeaders() {
132132
if (HttpMethod.PATCH.equals(this.httpMethod)) {
133133
headers.setAcceptPatch(getSupportedMediaTypes());
134134
}
135-
if (HttpMethod.QUERY.equals(this.httpMethod)) {
135+
else if (HttpMethod.QUERY.equals(this.httpMethod)) {
136136
headers.setAcceptQuery(getSupportedMediaTypes());
137137
}
138138
return headers;

spring-web/src/main/java/org/springframework/web/server/UnsupportedMediaTypeStatusException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public HttpHeaders getHeaders() {
161161
if (this.method == HttpMethod.PATCH) {
162162
headers.setAcceptPatch(this.supportedMediaTypes);
163163
}
164-
if (this.method == HttpMethod.QUERY) {
164+
else if (this.method == HttpMethod.QUERY) {
165165
headers.setAcceptQuery(this.supportedMediaTypes);
166166
}
167167
return headers;

spring-web/src/testFixtures/java/org/springframework/web/testfixture/method/MvcAnnotationPredicates.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,6 @@ public static RequestMappingPredicate headMapping(String... path) {
113113
return new RequestMappingPredicate(path).method(RequestMethod.HEAD);
114114
}
115115

116-
public static RequestMappingPredicate queryMapping(String... path) {
117-
return new RequestMappingPredicate(path).method(RequestMethod.QUERY);
118-
}
119-
120-
121116

122117
public static class ModelAttributePredicate implements Predicate<MethodParameter> {
123118

0 commit comments

Comments
 (0)