Skip to content

Commit cfd0aee

Browse files
committed
Polish and add MockMvcExtensionsTests.queryParameter
Closes gh-32371
1 parent 132fbe2 commit cfd0aee

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

spring-test/src/main/kotlin/org/springframework/test/web/servlet/MockHttpServletRequestDsl.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-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.
@@ -116,6 +116,7 @@ open class MockHttpServletRequestDsl internal constructor (private val builder:
116116
var params: MultiValueMap<String, String>? = null
117117

118118
/**
119+
* @since 6.1.5
119120
* @see [MockHttpServletRequestBuilder.queryParam]
120121
*/
121122
fun queryParam(name: String, vararg values: String) {

spring-test/src/test/kotlin/org/springframework/test/web/servlet/MockMvcExtensionsTests.kt

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-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.
@@ -219,6 +219,16 @@ class MockMvcExtensionsTests {
219219
"Content type expected:<text/plain> but was:<application/json>")
220220
}
221221

222+
@Test
223+
fun queryParameter() {
224+
val result = mockMvc.get("/") {
225+
queryParam("foo", "bar")
226+
queryParam("foo", "baz")
227+
}.andReturn()
228+
assertThat(result.request.parameterMap["foo"]).containsExactly("bar", "baz")
229+
assertThat(result.request.queryString).isEqualTo("foo=bar&foo=baz")
230+
}
231+
222232

223233
@RestController
224234
private class PersonController {

0 commit comments

Comments
 (0)