@Test public void verifySingleConnector() { // Relevant to Tomcat 9.0 assertThat(applicationContext).isInstanceOf(WebServerApplicationContext.class); WebServer webServer = ((WebServerApplicationContext) applicationContext).getWebServer(); assertThat(webServer).isInstanceOf(TomcatWebServer.class); assertThat(((TomcatWebServer) webServer).getTomcat() .getEngine() .getService() .findConnectors()).hasSize(1); }
private Optional<Context> findContext() { return Stream.of(this.webServer.getTomcat().getHost().findChildren()) .filter(Context.class::isInstance).map(Context.class::cast) .findFirst(); }
private Context findContext(TomcatWebServer tomcatWebServer) { for (Container container : tomcatWebServer.getTomcat().getHost().findChildren()) { if (container instanceof Context) { return (Context) container; } } return null; }