|
|
|
@ -39,10 +39,8 @@ public class MvcFailureAnalyzerApplicationTests {
@@ -39,10 +39,8 @@ public class MvcFailureAnalyzerApplicationTests {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void exceptionThrown(CapturedOutput output) { |
|
|
|
|
assertThatThrownBy( |
|
|
|
|
() -> new SpringApplication(MvcFailureAnalyzerApplication.class) |
|
|
|
|
.run("--server.port=0")).hasRootCauseInstanceOf( |
|
|
|
|
MvcFoundOnClasspathException.class); |
|
|
|
|
assertThatThrownBy(() -> new SpringApplication(MvcFailureAnalyzerApplication.class).run("--server.port=0")) |
|
|
|
|
.hasRootCauseInstanceOf(MvcFoundOnClasspathException.class); |
|
|
|
|
assertThat(output).contains(MvcFoundOnClasspathFailureAnalyzer.MESSAGE, |
|
|
|
|
MvcFoundOnClasspathFailureAnalyzer.ACTION); |
|
|
|
|
} |
|
|
|
@ -50,8 +48,7 @@ public class MvcFailureAnalyzerApplicationTests {
@@ -50,8 +48,7 @@ public class MvcFailureAnalyzerApplicationTests {
|
|
|
|
|
@Test |
|
|
|
|
public void exceptionNotThrownWhenDisabled(CapturedOutput output) { |
|
|
|
|
assertThatCode(() -> new SpringApplication(MvcFailureAnalyzerApplication.class) |
|
|
|
|
.run("--spring.cloud.gateway.enabled=false", "--server.port=0")) |
|
|
|
|
.doesNotThrowAnyException(); |
|
|
|
|
.run("--spring.cloud.gateway.enabled=false", "--server.port=0")).doesNotThrowAnyException(); |
|
|
|
|
assertThat(output).doesNotContain(MvcFoundOnClasspathFailureAnalyzer.MESSAGE, |
|
|
|
|
MvcFoundOnClasspathFailureAnalyzer.ACTION); |
|
|
|
|
} |
|
|
|
@ -59,16 +56,12 @@ public class MvcFailureAnalyzerApplicationTests {
@@ -59,16 +56,12 @@ public class MvcFailureAnalyzerApplicationTests {
|
|
|
|
|
@Test |
|
|
|
|
public void exceptionNotThrownWhenReactiveTypeSet(CapturedOutput output) { |
|
|
|
|
assertThatCode(() -> { |
|
|
|
|
ConfigurableApplicationContext context = new SpringApplication( |
|
|
|
|
MvcFailureAnalyzerApplication.class).run( |
|
|
|
|
"--spring.main.web-application-type=reactive", |
|
|
|
|
"--server.port=0", "--debug=true"); |
|
|
|
|
Integer port = context.getEnvironment().getProperty("local.server.port", |
|
|
|
|
Integer.class); |
|
|
|
|
WebTestClient client = WebTestClient.bindToServer() |
|
|
|
|
.baseUrl("http://localhost:" + port).build(); |
|
|
|
|
client.get().uri("/myprefix/hello").exchange().expectStatus().isOk() |
|
|
|
|
.expectBody(String.class).isEqualTo("Hello"); |
|
|
|
|
ConfigurableApplicationContext context = new SpringApplication(MvcFailureAnalyzerApplication.class) |
|
|
|
|
.run("--spring.main.web-application-type=reactive", "--server.port=0", "--debug=true"); |
|
|
|
|
Integer port = context.getEnvironment().getProperty("local.server.port", Integer.class); |
|
|
|
|
WebTestClient client = WebTestClient.bindToServer().baseUrl("http://localhost:" + port).build(); |
|
|
|
|
client.get().uri("/myprefix/hello").exchange().expectStatus().isOk().expectBody(String.class) |
|
|
|
|
.isEqualTo("Hello"); |
|
|
|
|
context.close(); |
|
|
|
|
}).doesNotThrowAnyException(); |
|
|
|
|
assertThat(output).doesNotContain(MvcFoundOnClasspathFailureAnalyzer.MESSAGE, |
|
|
|
|