From 0074c004153457904aea3fe9bfccf1a344b2fff0 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Wed, 6 Mar 2019 11:09:57 +1100 Subject: [PATCH] Issue #3399 jetty.webapps.uri should be the parent of the webapp Signed-off-by: Jan Bartel --- .../eclipse/jetty/xml/XmlConfiguration.java | 2 +- .../jetty/xml/XmlConfigurationTest.java | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java index d9061ec3aa5a..1956e975524c 100644 --- a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java +++ b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java @@ -153,7 +153,7 @@ public void setJettyStandardIdsAndProperties(Object server, Resource webapp) Path webappPath = webapp.getFile().toPath().toAbsolutePath(); getProperties().put("jetty.webapp", webappPath.toString()); getProperties().put("jetty.webapps", webappPath.getParent().toString()); - getProperties().put("jetty.webapps.uri", normalizeURI(webapp.getURI().toString())); + getProperties().put("jetty.webapps.uri", normalizeURI(webappPath.getParent().toUri().toString())); } } catch(Exception e) diff --git a/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java b/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java index bcc3798f7fac..271eb9022480 100644 --- a/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java +++ b/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java @@ -22,10 +22,14 @@ import java.lang.reflect.InvocationTargetException; import java.net.URL; import java.nio.charset.StandardCharsets; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; +import org.eclipse.jetty.toolchain.test.MavenTestingUtils; +import org.eclipse.jetty.util.resource.Resource; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -981,4 +985,24 @@ public void testJettyStandardIdsAndProperties_JettyHomeUri_JettyBaseUri() throws assertThat(propName, tc.getTestString(), startsWith("file:")); } } + + @Test + public void testJettyStandardIdsAndProperties_JettyWebappsUri() throws Exception + { + Path war = MavenTestingUtils.getTargetPath("no.war"); + XmlConfiguration configuration = + new XmlConfiguration("" + + "" + + " " + + " " + + " " + + ""); + + configuration.setJettyStandardIdsAndProperties(null, Resource.newResource(war)); + + TestConfiguration tc = new TestConfiguration(); + configuration.configure(tc); + + assertThat("jetty.webapps.uri", tc.getTestString(), is(XmlConfiguration.normalizeURI(war.getParent().toUri().toString()))); + } }