Add Kotlin example for WebTestClient setup docs
Closes gh-9998
This commit is contained in:
parent
e092ec780f
commit
db9d60e82d
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
The basic setup looks like this:
|
The basic setup looks like this:
|
||||||
|
|
||||||
[source,java]
|
====
|
||||||
|
.Java
|
||||||
|
[source,java,role="primary"]
|
||||||
----
|
----
|
||||||
@ExtendWith(SpringExtension.class)
|
@ExtendWith(SpringExtension.class)
|
||||||
@ContextConfiguration(classes = HelloWebfluxMethodApplication.class)
|
@ContextConfiguration(classes = HelloWebfluxMethodApplication.class)
|
||||||
|
@ -19,9 +21,35 @@ public class HelloWebfluxMethodApplicationTests {
|
||||||
// add Spring Security test Support
|
// add Spring Security test Support
|
||||||
.apply(springSecurity())
|
.apply(springSecurity())
|
||||||
.configureClient()
|
.configureClient()
|
||||||
.filter(basicAuthentication())
|
.filter(basicAuthentication("user", "password"))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
|
.Kotlin
|
||||||
|
[source,kotlin,role="secondary"]
|
||||||
|
----
|
||||||
|
@ExtendWith(SpringExtension::class)
|
||||||
|
@ContextConfiguration(classes = [HelloWebfluxMethodApplication::class])
|
||||||
|
class HelloWebfluxMethodApplicationTests {
|
||||||
|
@Autowired
|
||||||
|
lateinit var context: ApplicationContext
|
||||||
|
|
||||||
|
lateinit var rest: WebTestClient
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
fun setup() {
|
||||||
|
this.rest = WebTestClient
|
||||||
|
.bindToApplicationContext(this.context)
|
||||||
|
// add Spring Security test Support
|
||||||
|
.apply(springSecurity())
|
||||||
|
.configureClient()
|
||||||
|
.filter(basicAuthentication("user", "password"))
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
----
|
||||||
|
====
|
||||||
|
|
Loading…
Reference in New Issue