Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Kotlin example for WebTestClient setup docs #11610

Merged
merged 1 commit into from
Jul 22, 2022
Merged
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
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
@@ -2,7 +2,9 @@

The basic setup looks like this:

[source,java]
====
.Java
[source,java,role="primary"]
----
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = HelloWebfluxMethodApplication.class)
@@ -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()
}
// ...
}
----
====