summaryrefslogtreecommitdiffstats
path: root/sonar-application
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-10-15 10:18:13 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2013-10-15 10:38:35 +0200
commit3c4052ab43317b72f1075942ea192dbcb04b8667 (patch)
tree52906e65b7b8f325eff7e1ebda5cee13d66adaf5 /sonar-application
parent3aca3b8c7f87e803bb992d4d993d0ab2c29cee2a (diff)
downloadsonarqube-3c4052ab43317b72f1075942ea192dbcb04b8667.tar.gz
sonarqube-3c4052ab43317b72f1075942ea192dbcb04b8667.zip
SONAR-4675 root web context must be "" instead of "/"
Diffstat (limited to 'sonar-application')
-rw-r--r--sonar-application/src/main/java/org/sonar/application/Webapp.java9
-rw-r--r--sonar-application/src/test/java/org/sonar/application/WebappTest.java10
2 files changed, 15 insertions, 4 deletions
diff --git a/sonar-application/src/main/java/org/sonar/application/Webapp.java b/sonar-application/src/main/java/org/sonar/application/Webapp.java
index 89f84c3603a..19ad12c20c6 100644
--- a/sonar-application/src/main/java/org/sonar/application/Webapp.java
+++ b/sonar-application/src/main/java/org/sonar/application/Webapp.java
@@ -26,6 +26,7 @@ class Webapp {
private static final String JRUBY_MAX_RUNTIMES = "jruby.max.runtimes";
private static final String RAILS_ENV = "rails.env";
+ private static final String PROPERTY_CONTEXT = "sonar.web.context";
static void configure(Tomcat tomcat, Env env, Props props) {
String ctx = getContext(props);
@@ -41,9 +42,11 @@ class Webapp {
}
static String getContext(Props props) {
- String context = props.of("sonar.web.context", "");
- if (!"".equals(context) && !context.startsWith("/")) {
- throw new IllegalStateException("Value of sonar.web.context must start with a forward slash: " + context);
+ String context = props.of(PROPERTY_CONTEXT, "");
+ if ("/".equals(context)) {
+ context = "";
+ } else if (!"".equals(context) && !context.startsWith("/")) {
+ throw new IllegalStateException(String.format("Value of '%s' must start with a forward slash: '%s'", PROPERTY_CONTEXT, context));
}
return context;
}
diff --git a/sonar-application/src/test/java/org/sonar/application/WebappTest.java b/sonar-application/src/test/java/org/sonar/application/WebappTest.java
index aa1ba82eee8..19dc03ff94b 100644
--- a/sonar-application/src/test/java/org/sonar/application/WebappTest.java
+++ b/sonar-application/src/test/java/org/sonar/application/WebappTest.java
@@ -87,11 +87,19 @@ public class WebappTest {
Webapp.getContext(new Props(p));
fail();
} catch (IllegalStateException e) {
- assertThat(e.getMessage()).isEqualTo("Value of sonar.web.context must start with a forward slash: foo");
+ assertThat(e.getMessage()).isEqualTo("Value of 'sonar.web.context' must start with a forward slash: 'foo'");
}
}
@Test
+ public void root_context_must_be_blank() throws Exception {
+ Properties p = new Properties();
+ p.setProperty("sonar.web.context", "/");
+
+ assertThat(Webapp.getContext(new Props(p))).isEqualTo("");
+ }
+
+ @Test
public void default_context_is_root() throws Exception {
String context = Webapp.getContext(new Props(new Properties()));
assertThat(context).isEqualTo("");