Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
// Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed
standaloneSetup(SimpleController())
.alwaysExpect<StandaloneMockMvcBuilder>(MockMvcResultMatchers.status().isOk())
.alwaysExpect<StandaloneMockMvcBuilder>(MockMvcResultMatchers.content().contentType("application/json;charset=UTF-8"))
.build()
----
======

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
// Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed
mockMvc = standaloneSetup(PersonController()).addFilters<StandaloneMockMvcBuilder>(CharacterEncodingFilter()).build()
----
======

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,18 @@ Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
// Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed
class MyWebTests {
lateinit var mockMvc: MockMvc
@BeforeEach
fun setup() {
mockMvc = MockMvcBuilders.standaloneSetup(AccountController())
.defaultRequest<StandaloneMockMvcBuilder>(get("/")
.contextPath("/app").servletPath("/main")
.accept(MediaType.APPLICATION_JSON)).build()
}
}
----
======

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
// Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed
// static import of MockMvcBuilders.standaloneSetup

val mockMvc = standaloneSetup(MusicController())
.defaultRequest<StandaloneMockMvcBuilder>(get("/").accept(MediaType.APPLICATION_JSON))
.alwaysExpect<StandaloneMockMvcBuilder>(status().isOk())
.alwaysExpect<StandaloneMockMvcBuilder>(content().contentType("application/json;charset=UTF-8"))
.build()
----
======

Expand Down Expand Up @@ -53,7 +59,13 @@ Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
// Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed
// static import of SharedHttpSessionConfigurer.sharedHttpSession

val mockMvc = MockMvcBuilders.standaloneSetup(TestController())
.apply<StandaloneMockMvcBuilder>(sharedHttpSession())
.build()

// Use mockMvc to perform requests...
----
======

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,19 @@ Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
// Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed
val mockMvc = MockMvcBuilders
.webAppContextSetup(context)
.apply(springSecurity())
.build()

webClient = MockMvcWebClientBuilder
.mockMvcSetup(mockMvc)
// for illustration only - defaults to ""
.contextPath("")
// By default MockMvc is used for localhost only;
// the following will use MockMvc for example.com and example.org as well
.useMockMvcForHosts("example.com", "example.org")
.build()
----
======

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,19 @@ Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
// Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed
val mockMvc: MockMvc = MockMvcBuilders
.webAppContextSetup(context)
.apply(springSecurity())
.build()
driver = MockMvcHtmlUnitDriverBuilder
.mockMvcSetup(mockMvc)
// for illustration only - defaults to ""
.contextPath("")
// By default MockMvc is used for localhost only;
// the following will use MockMvc for example.com and example.org as well
.useMockMvcForHosts("example.com", "example.org")
.build()
----
======

Expand Down