From b93a4f01509d173ec4a1a35cc50e634fe7404a0a Mon Sep 17 00:00:00 2001 From: Tran Ngoc Nhan Date: Fri, 14 Nov 2025 22:44:10 +0700 Subject: [PATCH 1/3] Replace `kotlin-issues` attribute reference Signed-off-by: Tran Ngoc Nhan --- .../ROOT/pages/testing/mockmvc/hamcrest/expectations.adoc | 2 +- .../modules/ROOT/pages/testing/mockmvc/hamcrest/filters.adoc | 2 +- .../modules/ROOT/pages/testing/mockmvc/hamcrest/requests.adoc | 2 +- .../ROOT/pages/testing/mockmvc/hamcrest/setup-steps.adoc | 4 ++-- .../modules/ROOT/pages/testing/mockmvc/htmlunit/mah.adoc | 2 +- .../ROOT/pages/testing/mockmvc/htmlunit/webdriver.adoc | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/expectations.adoc b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/expectations.adoc index 5206b34d97f..087db9af183 100644 --- a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/expectations.adoc +++ b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/expectations.adoc @@ -182,7 +182,7 @@ Java:: Kotlin:: + -[source,kotlin,indent=0,subs="verbatim,quotes"] +[source,kotlin,indent=0,subs="verbatim,quotes,attributes"] ---- // Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed ---- diff --git a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/filters.adoc b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/filters.adoc index d61a9f1b174..0c0aec0b7de 100644 --- a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/filters.adoc +++ b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/filters.adoc @@ -16,7 +16,7 @@ Java:: Kotlin:: + -[source,kotlin,indent=0,subs="verbatim,quotes"] +[source,kotlin,indent=0,subs="verbatim,quotes,attributes"] ---- // Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed ---- diff --git a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/requests.adoc b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/requests.adoc index cc85e2846ad..cc82d6833a0 100644 --- a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/requests.adoc +++ b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/requests.adoc @@ -157,7 +157,7 @@ Java:: Kotlin:: + -[source,kotlin,indent=0,subs="verbatim,quotes"] +[source,kotlin,indent=0,subs="verbatim,quotes,attributes"] ---- // Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed ---- diff --git a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/setup-steps.adoc b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/setup-steps.adoc index 8cda0b66b03..3c87e8209b7 100644 --- a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/setup-steps.adoc +++ b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/setup-steps.adoc @@ -23,7 +23,7 @@ Java:: Kotlin:: + -[source,kotlin,indent=0,subs="verbatim,quotes"] +[source,kotlin,indent=0,subs="verbatim,quotes,attributes"] ---- // Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed ---- @@ -51,7 +51,7 @@ Java:: Kotlin:: + -[source,kotlin,indent=0,subs="verbatim,quotes"] +[source,kotlin,indent=0,subs="verbatim,quotes,attributes"] ---- // Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed ---- diff --git a/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/mah.adoc b/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/mah.adoc index 97dd4171b95..06fcd1b31c5 100644 --- a/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/mah.adoc +++ b/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/mah.adoc @@ -265,7 +265,7 @@ Java:: Kotlin:: + -[source,kotlin,indent=0,subs="verbatim,quotes"] +[source,kotlin,indent=0,subs="verbatim,quotes,attributes"] ---- // Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed ---- diff --git a/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/webdriver.adoc b/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/webdriver.adoc index a9e3533cac5..3d406fdb470 100644 --- a/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/webdriver.adoc +++ b/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/webdriver.adoc @@ -560,7 +560,7 @@ Java:: Kotlin:: + -[source,kotlin,indent=0,subs="verbatim,quotes"] +[source,kotlin,indent=0,subs="verbatim,quotes,attributes"] ---- // Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed ---- From 400ea804a1e735fda11c52f535068b1ba4af0bb2 Mon Sep 17 00:00:00 2001 From: Tran Ngoc Nhan Date: Sat, 15 Nov 2025 20:11:12 +0700 Subject: [PATCH 2/3] Add Kotlin code samples Signed-off-by: Tran Ngoc Nhan --- .../testing/mockmvc/hamcrest/expectations.adoc | 5 ++++- .../pages/testing/mockmvc/hamcrest/filters.adoc | 2 +- .../pages/testing/mockmvc/hamcrest/requests.adoc | 13 ++++++++++++- .../testing/mockmvc/hamcrest/setup-steps.adoc | 16 ++++++++++++++-- .../ROOT/pages/testing/mockmvc/htmlunit/mah.adoc | 14 +++++++++++++- .../testing/mockmvc/htmlunit/webdriver.adoc | 14 +++++++++++++- 6 files changed, 57 insertions(+), 7 deletions(-) diff --git a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/expectations.adoc b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/expectations.adoc index 087db9af183..9dc2d3e3bc8 100644 --- a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/expectations.adoc +++ b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/expectations.adoc @@ -184,7 +184,10 @@ Kotlin:: + [source,kotlin,indent=0,subs="verbatim,quotes,attributes"] ---- - // Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed + standaloneSetup(SimpleController()) + .alwaysExpect(MockMvcResultMatchers.status().isOk()) + .alwaysExpect(MockMvcResultMatchers.content().contentType("application/json;charset=UTF-8")) + .build() ---- ====== diff --git a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/filters.adoc b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/filters.adoc index 0c0aec0b7de..7fa66a1cc50 100644 --- a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/filters.adoc +++ b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/filters.adoc @@ -18,7 +18,7 @@ Kotlin:: + [source,kotlin,indent=0,subs="verbatim,quotes,attributes"] ---- - // Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed + mockMvc = standaloneSetup(PersonController()).addFilters(CharacterEncodingFilter()).build() ---- ====== diff --git a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/requests.adoc b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/requests.adoc index cc82d6833a0..ee3ad75fa9b 100644 --- a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/requests.adoc +++ b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/requests.adoc @@ -159,7 +159,18 @@ Kotlin:: + [source,kotlin,indent=0,subs="verbatim,quotes,attributes"] ---- - // 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(get("/") + .contextPath("/app").servletPath("/main") + .accept(MediaType.APPLICATION_JSON)).build() + } + } ---- ====== diff --git a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/setup-steps.adoc b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/setup-steps.adoc index 3c87e8209b7..9ec5ca43eff 100644 --- a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/setup-steps.adoc +++ b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/setup-steps.adoc @@ -25,7 +25,13 @@ Kotlin:: + [source,kotlin,indent=0,subs="verbatim,quotes,attributes"] ---- - // Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed + // static import of MockMvcBuilders.standaloneSetup + + val mockMvc = standaloneSetup(MusicController()) + .defaultRequest(get("/").accept(MediaType.APPLICATION_JSON)) + .alwaysExpect(status().isOk()) + .alwaysExpect(content().contentType("application/json;charset=UTF-8")) + .build() ---- ====== @@ -53,7 +59,13 @@ Kotlin:: + [source,kotlin,indent=0,subs="verbatim,quotes,attributes"] ---- - // Not possible in Kotlin until {kotlin-issues}/KT-22208 is fixed + // static import of SharedHttpSessionConfigurer.sharedHttpSession + + val mockMvc = MockMvcBuilders.standaloneSetup(TestController()) + .apply(sharedHttpSession()) + .build() + + // Use mockMvc to perform requests... ---- ====== diff --git a/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/mah.adoc b/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/mah.adoc index 06fcd1b31c5..81614351177 100644 --- a/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/mah.adoc +++ b/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/mah.adoc @@ -267,7 +267,19 @@ Kotlin:: + [source,kotlin,indent=0,subs="verbatim,quotes,attributes"] ---- - // 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() ---- ====== diff --git a/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/webdriver.adoc b/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/webdriver.adoc index 3d406fdb470..491b8e7f4aa 100644 --- a/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/webdriver.adoc +++ b/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/webdriver.adoc @@ -562,7 +562,19 @@ Kotlin:: + [source,kotlin,indent=0,subs="verbatim,quotes,attributes"] ---- - // 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() ---- ====== From 604b1bc50fded2fbd7b454284aafaa952c18ada6 Mon Sep 17 00:00:00 2001 From: Tran Ngoc Nhan Date: Sun, 16 Nov 2025 12:16:16 +0700 Subject: [PATCH 3/3] Revert attributes Signed-off-by: Tran Ngoc Nhan --- .../ROOT/pages/testing/mockmvc/hamcrest/expectations.adoc | 2 +- .../modules/ROOT/pages/testing/mockmvc/hamcrest/filters.adoc | 2 +- .../modules/ROOT/pages/testing/mockmvc/hamcrest/requests.adoc | 2 +- .../ROOT/pages/testing/mockmvc/hamcrest/setup-steps.adoc | 4 ++-- .../modules/ROOT/pages/testing/mockmvc/htmlunit/mah.adoc | 2 +- .../ROOT/pages/testing/mockmvc/htmlunit/webdriver.adoc | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/expectations.adoc b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/expectations.adoc index 9dc2d3e3bc8..e8a81fe2c61 100644 --- a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/expectations.adoc +++ b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/expectations.adoc @@ -182,7 +182,7 @@ Java:: Kotlin:: + -[source,kotlin,indent=0,subs="verbatim,quotes,attributes"] +[source,kotlin,indent=0,subs="verbatim,quotes"] ---- standaloneSetup(SimpleController()) .alwaysExpect(MockMvcResultMatchers.status().isOk()) diff --git a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/filters.adoc b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/filters.adoc index 7fa66a1cc50..ea625acabc5 100644 --- a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/filters.adoc +++ b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/filters.adoc @@ -16,7 +16,7 @@ Java:: Kotlin:: + -[source,kotlin,indent=0,subs="verbatim,quotes,attributes"] +[source,kotlin,indent=0,subs="verbatim,quotes"] ---- mockMvc = standaloneSetup(PersonController()).addFilters(CharacterEncodingFilter()).build() ---- diff --git a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/requests.adoc b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/requests.adoc index ee3ad75fa9b..5bc0f331d35 100644 --- a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/requests.adoc +++ b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/requests.adoc @@ -157,7 +157,7 @@ Java:: Kotlin:: + -[source,kotlin,indent=0,subs="verbatim,quotes,attributes"] +[source,kotlin,indent=0,subs="verbatim,quotes"] ---- class MyWebTests { diff --git a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/setup-steps.adoc b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/setup-steps.adoc index 9ec5ca43eff..9d895e9de9b 100644 --- a/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/setup-steps.adoc +++ b/framework-docs/modules/ROOT/pages/testing/mockmvc/hamcrest/setup-steps.adoc @@ -23,7 +23,7 @@ Java:: Kotlin:: + -[source,kotlin,indent=0,subs="verbatim,quotes,attributes"] +[source,kotlin,indent=0,subs="verbatim,quotes"] ---- // static import of MockMvcBuilders.standaloneSetup @@ -57,7 +57,7 @@ Java:: Kotlin:: + -[source,kotlin,indent=0,subs="verbatim,quotes,attributes"] +[source,kotlin,indent=0,subs="verbatim,quotes"] ---- // static import of SharedHttpSessionConfigurer.sharedHttpSession diff --git a/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/mah.adoc b/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/mah.adoc index 81614351177..e78e83787c8 100644 --- a/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/mah.adoc +++ b/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/mah.adoc @@ -265,7 +265,7 @@ Java:: Kotlin:: + -[source,kotlin,indent=0,subs="verbatim,quotes,attributes"] +[source,kotlin,indent=0,subs="verbatim,quotes"] ---- val mockMvc = MockMvcBuilders .webAppContextSetup(context) diff --git a/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/webdriver.adoc b/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/webdriver.adoc index 491b8e7f4aa..ea1575a9353 100644 --- a/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/webdriver.adoc +++ b/framework-docs/modules/ROOT/pages/testing/mockmvc/htmlunit/webdriver.adoc @@ -560,7 +560,7 @@ Java:: Kotlin:: + -[source,kotlin,indent=0,subs="verbatim,quotes,attributes"] +[source,kotlin,indent=0,subs="verbatim,quotes"] ---- val mockMvc: MockMvc = MockMvcBuilders .webAppContextSetup(context)