提交 8670b1c3 编写于 作者: S Stephane Nicoll

Merge pull request #27238 from izeye

* pr/27238:
  Polish printMvcResultsToWriterWithFailingGlobalResultMatcher()

Closes gh-27238
...@@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.GetMapping; ...@@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
...@@ -70,6 +71,7 @@ class PrintingResultHandlerIntegrationTests { ...@@ -70,6 +71,7 @@ class PrintingResultHandlerIntegrationTests {
.alwaysExpect(content().string("Boom!")) .alwaysExpect(content().string("Boom!"))
.build() .build()
.perform(get("/").content("Hello Request".getBytes()).characterEncoding("ISO-8859-1")); .perform(get("/").content("Hello Request".getBytes()).characterEncoding("ISO-8859-1"));
fail("AssertionError is expected to be thrown.");
} }
catch (AssertionError error) { catch (AssertionError error) {
assertThat(error).hasMessageContaining("Boom!"); assertThat(error).hasMessageContaining("Boom!");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册