diff --git a/spring-cloud-netflix-hystrix-dashboard/src/main/java/org/springframework/cloud/netflix/hystrix/dashboard/HystrixDashboardController.java b/spring-cloud-netflix-hystrix-dashboard/src/main/java/org/springframework/cloud/netflix/hystrix/dashboard/HystrixDashboardController.java
index 9b4b972f..9c4ca316 100644
--- a/spring-cloud-netflix-hystrix-dashboard/src/main/java/org/springframework/cloud/netflix/hystrix/dashboard/HystrixDashboardController.java
+++ b/spring-cloud-netflix-hystrix-dashboard/src/main/java/org/springframework/cloud/netflix/hystrix/dashboard/HystrixDashboardController.java
@@ -44,7 +44,7 @@ public class HystrixDashboardController {
private String extractPath(WebRequest request) {
String path = request.getContextPath()
- + (String) request.getAttribute("org.springframework."
+ + request.getAttribute("org.springframework."
+ "web.servlet.HandlerMapping.pathWithinHandlerMapping",
RequestAttributes.SCOPE_REQUEST);
return path;
diff --git a/spring-cloud-netflix-hystrix-dashboard/src/main/resources/templates/hystrix/index.ftl b/spring-cloud-netflix-hystrix-dashboard/src/main/resources/templates/hystrix/index.ftl
index e71bbc82..6108cc80 100644
--- a/spring-cloud-netflix-hystrix-dashboard/src/main/resources/templates/hystrix/index.ftl
+++ b/spring-cloud-netflix-hystrix-dashboard/src/main/resources/templates/hystrix/index.ftl
@@ -2,7 +2,7 @@
-
+
Hystrix Dashboard
diff --git a/spring-cloud-netflix-hystrix-dashboard/src/main/resources/templates/hystrix/monitor.ftl b/spring-cloud-netflix-hystrix-dashboard/src/main/resources/templates/hystrix/monitor.ftl
index 1826c1fc..84b2e25d 100644
--- a/spring-cloud-netflix-hystrix-dashboard/src/main/resources/templates/hystrix/monitor.ftl
+++ b/spring-cloud-netflix-hystrix-dashboard/src/main/resources/templates/hystrix/monitor.ftl
@@ -2,7 +2,7 @@
-
+
Hystrix Monitor
diff --git a/spring-cloud-netflix-hystrix-dashboard/src/test/java/org/springframework/cloud/netflix/hystrix/dashboard/HystrixDashboardContextTests.java b/spring-cloud-netflix-hystrix-dashboard/src/test/java/org/springframework/cloud/netflix/hystrix/dashboard/HystrixDashboardContextTests.java
index 6d7db75d..505883f7 100644
--- a/spring-cloud-netflix-hystrix-dashboard/src/test/java/org/springframework/cloud/netflix/hystrix/dashboard/HystrixDashboardContextTests.java
+++ b/spring-cloud-netflix-hystrix-dashboard/src/test/java/org/springframework/cloud/netflix/hystrix/dashboard/HystrixDashboardContextTests.java
@@ -32,6 +32,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* @author Dave Syer
@@ -44,6 +45,7 @@ import static org.junit.Assert.assertEquals;
"server.contextPath=/context" })
public class HystrixDashboardContextTests {
+ public static final String JQUERY_PATH = "/context/webjars/jquery/2.1.1/jquery.min.js";
@Value("${local.server.port}")
private int port = 0;
@@ -52,6 +54,19 @@ public class HystrixDashboardContextTests {
ResponseEntity entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port + "/context/hystrix", String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
+ String body = entity.getBody();
+ assertTrue("wrong base path rendered in template",
+ body.contains("base href=\"/context/hystrix\""));
+ }
+
+ @Test
+ public void correctJavascriptLink() {
+ ResponseEntity entity = new TestRestTemplate().getForEntity(
+ "http://localhost:" + this.port + "/context/hystrix", String.class);
+ assertEquals(HttpStatus.OK, entity.getStatusCode());
+ String body = entity.getBody();
+ assertTrue("wrong jquery path rendered in template",
+ body.contains("src=\""+JQUERY_PATH+"\""));
}
@Test
@@ -65,8 +80,7 @@ public class HystrixDashboardContextTests {
@Test
public void webjarsAvailable() {
ResponseEntity entity = new TestRestTemplate().getForEntity(
- "http://localhost:" + this.port
- + "/context/webjars/jquery/2.1.1/jquery.min.js", String.class);
+ "http://localhost:" + this.port + JQUERY_PATH, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
}
@@ -76,6 +90,9 @@ public class HystrixDashboardContextTests {
"http://localhost:" + this.port + "/context/hystrix/monitor",
String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
+ String body = entity.getBody();
+ assertTrue("wrong base path rendered in template",
+ body.contains("base href=\"/context/hystrix/monitor\""));
}
@Configuration
diff --git a/spring-cloud-netflix-hystrix-dashboard/src/test/java/org/springframework/cloud/netflix/hystrix/dashboard/HystrixDashboardTests.java b/spring-cloud-netflix-hystrix-dashboard/src/test/java/org/springframework/cloud/netflix/hystrix/dashboard/HystrixDashboardTests.java
index c196ce05..954ba5c7 100644
--- a/spring-cloud-netflix-hystrix-dashboard/src/test/java/org/springframework/cloud/netflix/hystrix/dashboard/HystrixDashboardTests.java
+++ b/spring-cloud-netflix-hystrix-dashboard/src/test/java/org/springframework/cloud/netflix/hystrix/dashboard/HystrixDashboardTests.java
@@ -71,6 +71,8 @@ public class HystrixDashboardTests {
ResponseEntity entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.port + "/hystrix/monitor", String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
+ String body = entity.getBody();
+ assertTrue(body.contains(""));
}
@Configuration