Only fail if mvc is on the classpath and gateway is enabled.
This is useful for libraries that might write functionality for zuul and gateway. See gh-2176
This commit is contained in:
@@ -25,6 +25,7 @@ import org.springframework.boot.test.system.OutputCaptureExtension;
|
||||
import org.springframework.cloud.gateway.support.MvcFoundOnClasspathException;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatCode;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
/**
|
||||
@@ -34,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
public class MvcFailureAnalyzerApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads(CapturedOutput output) {
|
||||
public void exceptionThrown(CapturedOutput output) {
|
||||
assertThatThrownBy(
|
||||
() -> new SpringApplication(MvcFailureAnalyzerApplication.class)
|
||||
.run("--server.port=0")).hasRootCauseInstanceOf(
|
||||
@@ -43,4 +44,13 @@ public class MvcFailureAnalyzerApplicationTests {
|
||||
"Please remove spring-boot-starter-web dependency");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exceptionNotThrownWhenDisabled(CapturedOutput output) {
|
||||
assertThatCode(() -> new SpringApplication(MvcFailureAnalyzerApplication.class)
|
||||
.run("--spring.cloud.gateway.enabled=false", "--server.port=0"))
|
||||
.doesNotThrowAnyException();
|
||||
assertThat(output).doesNotContain("Spring MVC found on classpath",
|
||||
"Please remove spring-boot-starter-web dependency");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,11 +22,13 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.cloud.gateway.support.MvcFoundOnClasspathException;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@AutoConfigureBefore(GatewayAutoConfiguration.class)
|
||||
@ConditionalOnProperty(name = "spring.cloud.gateway.enabled", matchIfMissing = true)
|
||||
public class GatewayClassPathWarningAutoConfiguration {
|
||||
|
||||
private static final Log log = LogFactory
|
||||
|
||||
Reference in New Issue
Block a user