Polish "Log context path at startup"

Closes gh-10544
This commit is contained in:
Stephane Nicoll 2017-11-06 12:48:51 +01:00
parent f76479fb99
commit dbea25fa8b
4 changed files with 12 additions and 3 deletions

View File

@ -156,7 +156,7 @@ public class JettyWebServer implements WebServer {
this.started = true;
JettyWebServer.logger
.info("Jetty started on port(s) " + getActualPortsDescription()
+ " with context path " + getContextPath());
+ " with context path '" + getContextPath() + "'");
}
catch (WebServerException ex) {
throw ex;

View File

@ -195,7 +195,7 @@ public class TomcatWebServer implements WebServer {
this.started = true;
TomcatWebServer.logger
.info("Tomcat started on port(s): " + getPortsDescription(true)
+ " with context path " + getContextPath());
+ " with context path '" + getContextPath() + "'");
}
catch (ConnectorStartFailedException ex) {
stopSilently();

View File

@ -158,7 +158,7 @@ public class UndertowServletWebServer implements WebServer {
this.started = true;
UndertowServletWebServer.logger
.info("Undertow started on port(s) " + getPortsDescription()
+ " with context path " + this.contextPath);
+ " with context path '" + this.contextPath + "'");
}
catch (Exception ex) {
try {

View File

@ -263,6 +263,15 @@ public abstract class AbstractServletWebServerFactoryTests {
assertThat(getResponse(getLocalUrl("/say/hello"))).isEqualTo("Hello World");
}
@Test
public void contextPathIsLoggedOnStartup() {
AbstractServletWebServerFactory factory = getFactory();
factory.setContextPath("/custom");
this.webServer = factory.getWebServer(exampleServletRegistration());
this.webServer.start();
assertThat(this.output.toString()).containsOnlyOnce("with context path '/custom'");
}
@Test
public void contextPathMustStartWithSlash() throws Exception {
this.thrown.expect(IllegalArgumentException.class);