Source:
public void start(File sourceWARDirectory) throws Exception { String xwikiIPAddress = "localhost"; int xwikiPort = 8080; switch (this.testConfiguration.getServletEngine()) { case TOMCAT: File logFile = new File(sourceWARDirectory, "WEB-INF/classes/logging.properties"); logFile.createNewFile(); try (FileWriter writer = new FileWriter(logFile)) { IOUtils.write("org.apache.catalina.core.ContainerBase.[Catalina].level = FINE\n" + "org.apache.catalina.core.ContainerBase.[Catalina].handlers = " + "java.util.logging.ConsoleHandler\n", writer); } servletContainer = getServletContainer(testConfiguration); mountFromHostToContainer(sourceWARDirectory, "/usr/local/tomcat/webapps/xwiki"); this.servletContainer.withEnv("CATALINA_OPTS", "-Xmx1024m " + "-Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true " + "-Dorg.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true " + "-Dsecurerandom.source=file:/dev/urandom"); break; case JETTY: servletContainer = getServletContainer(testConfiguration); mountFromHostToContainer(sourceWARDirectory, "/var/lib/jetty/webapps/xwiki"); break; case WILDFLY: servletContainer = getServletContainer(testConfiguration); mountFromHostToContainer(sourceWARDirectory, "/opt/jboss/wildfly/standalone/deployments/xwiki"); break; case JETTY_STANDALONE: this.jettyStandaloneExecutor.start(); break; default: this.throwExceptionForServletEngineNotYetSupported(testConfiguration); } if (this.servletContainer != null) { startContainer(); xwikiIPAddress = this.servletContainer.getContainerIpAddress(); xwikiPort = this.servletContainer.getMappedPort(this.testConfiguration.getServletEngine().getInternalPort()); } this.testConfiguration.getServletEngine().setIP(xwikiIPAddress); this.testConfiguration.getServletEngine().setPort(xwikiPort); }

Target:
public void start(File sourceWARDirectory) throws Exception { String xwikiIPAddress = "localhost"; int xwikiPort = 8080; switch (this.testConfiguration.getServletEngine()) { case TOMCAT: File logFile = new File(sourceWARDirectory, "WEB-INF/classes/logging.properties"); logFile.createNewFile(); try (FileWriter writer = new FileWriter(logFile)) { IOUtils.write("org.apache.catalina.core.ContainerBase.[Catalina].level = FINE\n" + "org.apache.catalina.core.ContainerBase.[Catalina].handlers = " + "java.util.logging.ConsoleHandler\n", writer); } servletContainer = createServletContainer(testConfiguration); mountFromHostToContainer(this.servletContainer, sourceWARDirectory.toString(), "/usr/local/tomcat/webapps/xwiki"); this.servletContainer.withEnv("CATALINA_OPTS", "-Xmx1024m " + "-Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true " + "-Dorg.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true " + "-Dsecurerandom.source=file:/dev/urandom"); break; case JETTY: this.servletContainer = createServletContainer(testConfiguration); mountFromHostToContainer(this.servletContainer, sourceWARDirectory.toString(), "/var/lib/jetty/webapps/xwiki"); break; case WILDFLY: this.servletContainer = createServletContainer(testConfiguration); mountFromHostToContainer(this.servletContainer, sourceWARDirectory.toString(), "/opt/jboss/wildfly/standalone/deployments/xwiki"); break; case JETTY_STANDALONE: this.jettyStandaloneExecutor.start(); break; default: throw new RuntimeException(String.format("Servlet engine [%s] is not yet supported!", testConfiguration.getServletEngine())); } if (this.servletContainer != null) { startContainer(); xwikiIPAddress = this.servletContainer.getContainerIpAddress(); xwikiPort = this.servletContainer.getMappedPort(this.testConfiguration.getServletEngine().getInternalPort()); } this.testConfiguration.getServletEngine().setIP(xwikiIPAddress); this.testConfiguration.getServletEngine().setPort(xwikiPort); }