Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
3799496d
Commit
3799496d
authored
Jun 17, 2016
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.3.x'
parents
f5f116d6
9abca48a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
4 deletions
+26
-4
HalBrowserMvcEndpoint.java
...work/boot/actuate/endpoint/mvc/HalBrowserMvcEndpoint.java
+5
-4
HalBrowserMvcEndpointManagementContextPathIntegrationTests.java
...wserMvcEndpointManagementContextPathIntegrationTests.java
+9
-0
HalBrowserMvcEndpointServerContextPathIntegrationTests.java
...lBrowserMvcEndpointServerContextPathIntegrationTests.java
+12
-0
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpoint.java
View file @
3799496d
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
6
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -38,6 +38,7 @@ import org.springframework.web.servlet.resource.TransformedResource;
* @author Dave Syer
* @author Phillip Webb
* @author Andy Wilkinson
* @author Stephane Nicoll
* @since 1.3.0
*/
public
class
HalBrowserMvcEndpoint
extends
HalJsonMvcEndpoint
...
...
@@ -142,15 +143,15 @@ public class HalBrowserMvcEndpoint extends HalJsonMvcEndpoint
resource
=
transformerChain
.
transform
(
request
,
resource
);
if
(
resource
.
getFilename
().
equalsIgnoreCase
(
HalBrowserMvcEndpoint
.
this
.
location
.
getHtmlFile
()))
{
return
replaceInitialLink
(
resource
);
return
replaceInitialLink
(
re
quest
.
getContextPath
(),
re
source
);
}
return
resource
;
}
private
Resource
replaceInitialLink
(
Resource
resource
)
throws
IOException
{
private
Resource
replaceInitialLink
(
String
contextPath
,
Resource
resource
)
throws
IOException
{
byte
[]
bytes
=
FileCopyUtils
.
copyToByteArray
(
resource
.
getInputStream
());
String
content
=
new
String
(
bytes
,
DEFAULT_CHARSET
);
String
initial
=
getManagementServletContext
().
getContextPath
()
+
getPath
();
String
initial
=
contextPath
+
getManagementServletContext
().
getContextPath
()
+
getPath
();
content
=
content
.
replace
(
"entryPoint: '/'"
,
"entryPoint: '"
+
initial
+
"'"
);
return
new
TransformedResource
(
resource
,
content
.
getBytes
(
DEFAULT_CHARSET
));
}
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointManagementContextPathIntegrationTests.java
View file @
3799496d
...
...
@@ -34,8 +34,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.context.WebApplicationContext
;
import
static
org
.
hamcrest
.
CoreMatchers
.
containsString
;
import
static
org
.
springframework
.
hateoas
.
mvc
.
ControllerLinkBuilder
.
linkTo
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
content
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
forwardedUrl
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
jsonPath
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
...
...
@@ -85,6 +87,13 @@ public class HalBrowserMvcEndpointManagementContextPathIntegrationTests {
.
andExpect
(
forwardedUrl
(
"/admin/browser.html"
));
}
@Test
public
void
actuatorBrowserHtml
()
throws
Exception
{
this
.
mockMvc
.
perform
(
get
(
"/admin/browser.html"
).
accept
(
MediaType
.
APPLICATION_JSON
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
string
(
containsString
(
"entryPoint: '/admin'"
)));
}
@Test
public
void
trace
()
throws
Exception
{
this
.
mockMvc
.
perform
(
get
(
"/admin/trace"
).
accept
(
MediaType
.
APPLICATION_JSON
))
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointServerContextPathIntegrationTests.java
View file @
3799496d
...
...
@@ -79,6 +79,18 @@ public class HalBrowserMvcEndpointServerContextPathIntegrationTests {
assertThat
(
entity
.
getBody
()).
contains
(
"<title"
);
}
@Test
public
void
actuatorBrowserEntryPoint
()
throws
Exception
{
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setAccept
(
Arrays
.
asList
(
MediaType
.
TEXT_HTML
));
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
exchange
(
"http://localhost:"
+
this
.
port
+
"/spring/actuator/browser.html"
,
HttpMethod
.
GET
,
new
HttpEntity
<
Void
>(
null
,
headers
),
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
entity
.
getStatusCode
());
assertTrue
(
"Wrong body: "
+
entity
.
getBody
(),
entity
.
getBody
().
contains
(
"entryPoint: '/spring/actuator'"
));
}
@Test
public
void
actuatorLinks
()
throws
Exception
{
HttpHeaders
headers
=
new
HttpHeaders
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment