Skip to content

Commit

Permalink
Issue #5394 Fix injection for quickstart (#5396)
Browse files Browse the repository at this point in the history
* Issue #5394 Fix injection for quickstart

Signed-off-by: Jan Bartel <janb@webtide.com>
  • Loading branch information
janbartel committed Oct 6, 2020
1 parent 9c0f61d commit 6ddbec3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Expand Up @@ -26,6 +26,7 @@
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.resource.JarResource;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.webapp.MetaInfConfiguration;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.xml.XmlConfiguration;
import org.slf4j.Logger;
Expand Down Expand Up @@ -109,7 +110,7 @@ public static void preconfigure(Resource war, Resource dir, Resource xml) throws
new AnnotationConfiguration());
webapp.setAttribute(QuickStartConfiguration.MODE, QuickStartConfiguration.Mode.GENERATE);
webapp.setAttribute(QuickStartConfiguration.ORIGIN_ATTRIBUTE, "");

webapp.setAttribute(MetaInfConfiguration.CONTAINER_JAR_PATTERN, ".*/jetty-servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/org.apache.taglibs.taglibs-standard-impl-.*\\.jar$");
if (xml != null)
{
if (xml.isDirectory() || !xml.toString().toLowerCase(Locale.ENGLISH).endsWith(".xml"))
Expand Down
Expand Up @@ -157,7 +157,7 @@ public void generateQuickStartWebXml(WebAppContext context, OutputStream stream)
webappAttr.put("xmlns", "http://xmlns.jcp.org/xml/ns/javaee");
webappAttr.put("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
webappAttr.put("xsi:schemaLocation", "http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_" + (major + "_" + minor) + ".xsd");
webappAttr.put("metadata-complete", "true");
webappAttr.put("metadata-complete", Boolean.toString(context.getMetaData().isMetaDataComplete()));
webappAttr.put("version", major + "." + minor);

XmlAppendable out = new XmlAppendable(stream, "UTF-8");
Expand Down
Expand Up @@ -139,14 +139,16 @@ public void testSpecWar() throws Exception
}

server.setHandler(webapp);

server.start();

URL url = new URL("http://127.0.0.1:" + server.getBean(NetworkConnector.class).getLocalPort() + "/");
URL url = new URL("http://127.0.0.1:" + server.getBean(NetworkConnector.class).getLocalPort() + "/test/");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");

assertEquals(200, connection.getResponseCode());
assertThat(IO.toString((InputStream)connection.getContent()), Matchers.containsString("Test Specification WebApp"));

String content = IO.toString((InputStream)connection.getContent());
assertThat(content, Matchers.containsString("Results"));
assertThat(content, Matchers.not(Matchers.containsString("FAIL")));
server.stop();
}

Expand Down

0 comments on commit 6ddbec3

Please sign in to comment.