update jetty and tomcat to latest version
This commit is contained in:
@@ -183,10 +183,10 @@ public class TestForm extends WebappTestCase {
|
||||
HtmlImage img = page.getFirstByXPath("//img[contains(@alt, 'PlantUML diagram')]");
|
||||
assertNotEquals(0, img.getImageReader().getHeight(0)); // 131
|
||||
assertNotEquals(0, img.getImageReader().getWidth(0)); // 231
|
||||
// TODO: Ensure the image map is present
|
||||
//DomElement map = page.getElementById("plantuml_map");
|
||||
//assertNotNull(map);
|
||||
//assertEquals(1, map.getChildElementCount());
|
||||
// Ensure the image map is present
|
||||
DomElement map = page.getElementById("plantuml_map");
|
||||
assertNotNull(map);
|
||||
assertEquals(1, map.getChildElementCount());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@ import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.sourceforge.plantuml.servlet.server.EmbeddedJettyServer;
|
||||
import net.sourceforge.plantuml.servlet.server.ExternalServer;
|
||||
@@ -16,6 +19,8 @@ import net.sourceforge.plantuml.servlet.server.ServerUtils;
|
||||
|
||||
public abstract class WebappTestCase extends TestCase {
|
||||
|
||||
protected final Logger logger;
|
||||
|
||||
private final ServerUtils serverUtils;
|
||||
|
||||
public WebappTestCase() {
|
||||
@@ -24,24 +29,26 @@ public abstract class WebappTestCase extends TestCase {
|
||||
|
||||
public WebappTestCase(String name) {
|
||||
super(name);
|
||||
logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
String uri = System.getProperty("system.test.server", "");
|
||||
//uri = "http://localhost:8080/plantuml";
|
||||
if (!uri.isEmpty()) {
|
||||
// mvn test -DskipTests=false -DargLine="-Dsystem.test.server=http://localhost:8080/plantuml"
|
||||
System.out.println("Test against external server: " + uri);
|
||||
logger.info("Test against external server: " + uri);
|
||||
serverUtils = new ExternalServer(uri);
|
||||
return;
|
||||
}
|
||||
|
||||
// mvn test -DskipTests=false
|
||||
System.out.println("Test against embedded jetty server.");
|
||||
logger.info("Test against embedded jetty server.");
|
||||
serverUtils = new EmbeddedJettyServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
serverUtils.startServer();
|
||||
logger.info(getServerUrl());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,19 +1,51 @@
|
||||
package net.sourceforge.plantuml.servlet.server;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.http.UriCompliance;
|
||||
import org.eclipse.jetty.http.UriCompliance.Violation;
|
||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerList;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
|
||||
public class EmbeddedJettyServer implements ServerUtils {
|
||||
|
||||
private static final String contextPath = "/plantuml";
|
||||
private Server server;
|
||||
|
||||
public EmbeddedJettyServer() {
|
||||
server = new Server(new InetSocketAddress("127.0.0.1", 0));
|
||||
server.addBean(new WebAppContext(server, "src/main/webapp", "/plantuml"));
|
||||
server = new Server();
|
||||
|
||||
ServerConnector connector = new ServerConnector(server);
|
||||
// Proxy and OldProxy need empty path segments support in URIs
|
||||
// Hence: allow AMBIGUOUS_EMPTY_SEGMENT
|
||||
UriCompliance uriCompliance = UriCompliance.from(EnumSet.of(Violation.AMBIGUOUS_EMPTY_SEGMENT));
|
||||
connector.getConnectionFactory(HttpConnectionFactory.class)
|
||||
.getHttpConfiguration()
|
||||
.setUriCompliance(uriCompliance);
|
||||
server.addConnector(connector);
|
||||
|
||||
// PlantUML server web application
|
||||
WebAppContext context = new WebAppContext(server, "src/main/webapp", EmbeddedJettyServer.contextPath);
|
||||
|
||||
// Add static webjars resource files
|
||||
// The maven-dependency-plugin in the pom.xml provides these files.
|
||||
WebAppContext res = new WebAppContext(
|
||||
server,
|
||||
"target/classes/META-INF/resources/webjars",
|
||||
EmbeddedJettyServer.contextPath + "/webjars"
|
||||
);
|
||||
|
||||
// Create server handler
|
||||
HandlerList handlers = new HandlerList();
|
||||
handlers.addHandler(res); // provides: /plantuml/webjars
|
||||
handlers.addHandler(context); // provides: /plantuml
|
||||
handlers.addHandler(new DefaultHandler()); // provides: /
|
||||
|
||||
server.setHandler(handlers);
|
||||
}
|
||||
|
||||
public void startServer() throws Exception {
|
||||
@@ -25,8 +57,12 @@ public class EmbeddedJettyServer implements ServerUtils {
|
||||
}
|
||||
|
||||
public String getServerUrl() {
|
||||
Connector connector = server.getConnectors()[0];
|
||||
return String.format("http://%s:%d/plantuml", connector.getHost(), connector.getLocalPort());
|
||||
return String.format(
|
||||
"%s://%s%s",
|
||||
server.getURI().getScheme(),
|
||||
server.getURI().getAuthority(),
|
||||
EmbeddedJettyServer.contextPath
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user