Skip to content

Commit

Permalink
Add Kotlin example for WebTestClient setup docs
Browse files Browse the repository at this point in the history
Closes gh-9998
  • Loading branch information
ysavchen authored and marcusdacoregio committed Jul 22, 2022
1 parent 56a6133 commit 0f64d4c
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions docs/modules/ROOT/pages/reactive/test/web/setup.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

The basic setup looks like this:

[source,java]
====
.Java
[source,java,role="primary"]
----
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = HelloWebfluxMethodApplication.class)
Expand All @@ -19,9 +21,35 @@ public class HelloWebfluxMethodApplicationTests {
// add Spring Security test Support
.apply(springSecurity())
.configureClient()
.filter(basicAuthentication())
.filter(basicAuthentication("user", "password"))
.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()
}
// ...
}
----
====

0 comments on commit 0f64d4c

Please sign in to comment.