Skip to content

Commit db9d60e

Browse files
ysavchenmarcusdacoregio
authored andcommitted
Add Kotlin example for WebTestClient setup docs
Closes gh-9998
1 parent e092ec7 commit db9d60e

File tree

1 file changed

+30
-2
lines changed
  • docs/modules/ROOT/pages/reactive/test/web

1 file changed

+30
-2
lines changed

docs/modules/ROOT/pages/reactive/test/web/setup.adoc

+30-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
The basic setup looks like this:
44

5-
[source,java]
5+
====
6+
.Java
7+
[source,java,role="primary"]
68
----
79
@ExtendWith(SpringExtension.class)
810
@ContextConfiguration(classes = HelloWebfluxMethodApplication.class)
@@ -19,9 +21,35 @@ public class HelloWebfluxMethodApplicationTests {
1921
// add Spring Security test Support
2022
.apply(springSecurity())
2123
.configureClient()
22-
.filter(basicAuthentication())
24+
.filter(basicAuthentication("user", "password"))
2325
.build();
2426
}
2527
// ...
2628
}
2729
----
30+
31+
.Kotlin
32+
[source,kotlin,role="secondary"]
33+
----
34+
@ExtendWith(SpringExtension::class)
35+
@ContextConfiguration(classes = [HelloWebfluxMethodApplication::class])
36+
class HelloWebfluxMethodApplicationTests {
37+
@Autowired
38+
lateinit var context: ApplicationContext
39+
40+
lateinit var rest: WebTestClient
41+
42+
@BeforeEach
43+
fun setup() {
44+
this.rest = WebTestClient
45+
.bindToApplicationContext(this.context)
46+
// add Spring Security test Support
47+
.apply(springSecurity())
48+
.configureClient()
49+
.filter(basicAuthentication("user", "password"))
50+
.build()
51+
}
52+
// ...
53+
}
54+
----
55+
====

0 commit comments

Comments
 (0)