Skip to content

Commit 28602ad

Browse files
izeyesdeleuze
authored andcommitted
Add MockMvc.multipart() Kotlin extensions with HttpMethod
See gh-28545 See gh-28631 Closes gh-28634
1 parent 8e9dc35 commit 28602ad

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

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

Lines changed: 25 additions & 1 deletion
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-2023 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.
@@ -224,6 +224,18 @@ fun MockMvc.multipart(urlTemplate: String, vararg vars: Any?, dsl: MockMultipart
224224
return MockMultipartHttpServletRequestDsl(requestBuilder).apply(dsl).perform(this)
225225
}
226226

227+
/**
228+
* [MockMvc] extension providing access to [MockMultipartHttpServletRequestDsl] Kotlin DSL.
229+
*
230+
* @see MockMvcRequestBuilders.multipart
231+
* @author Sebastien Deleuze
232+
* @since 5.3.26
233+
*/
234+
fun MockMvc.multipart(httpMethod: HttpMethod, urlTemplate: String, vararg vars: Any?, dsl: MockMultipartHttpServletRequestDsl.() -> Unit = {}): ResultActionsDsl {
235+
val requestBuilder = MockMvcRequestBuilders.multipart(httpMethod, urlTemplate, *vars)
236+
return MockMultipartHttpServletRequestDsl(requestBuilder).apply(dsl).perform(this)
237+
}
238+
227239
/**
228240
* [MockMvc] extension providing access to [MockMultipartHttpServletRequestDsl] Kotlin DSL.
229241
*
@@ -235,3 +247,15 @@ fun MockMvc.multipart(uri: URI, dsl: MockMultipartHttpServletRequestDsl.() -> Un
235247
val requestBuilder = MockMvcRequestBuilders.multipart(uri)
236248
return MockMultipartHttpServletRequestDsl(requestBuilder).apply(dsl).perform(this)
237249
}
250+
251+
/**
252+
* [MockMvc] extension providing access to [MockMultipartHttpServletRequestDsl] Kotlin DSL.
253+
*
254+
* @see MockMvcRequestBuilders.multipart
255+
* @author Sebastien Deleuze
256+
* @since 5.3.26
257+
*/
258+
fun MockMvc.multipart(httpMethod: HttpMethod, uri: URI, dsl: MockMultipartHttpServletRequestDsl.() -> Unit = {}): ResultActionsDsl {
259+
val requestBuilder = MockMvcRequestBuilders.multipart(httpMethod, uri)
260+
return MockMultipartHttpServletRequestDsl(requestBuilder).apply(dsl).perform(this)
261+
}

0 commit comments

Comments
 (0)