Polish "Log context path at startup"

Closes gh-10544
pull/10941/head
Stephane Nicoll 7 years ago
parent f76479fb99
commit dbea25fa8b

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

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

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

@ -263,6 +263,15 @@ public abstract class AbstractServletWebServerFactoryTests {
assertThat(getResponse(getLocalUrl("/say/hello"))).isEqualTo("Hello World"); 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 @Test
public void contextPathMustStartWithSlash() throws Exception { public void contextPathMustStartWithSlash() throws Exception {
this.thrown.expect(IllegalArgumentException.class); this.thrown.expect(IllegalArgumentException.class);

Loading…
Cancel
Save