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
884fd012
Commit
884fd012
authored
Dec 04, 2013
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some handler adapter tests
parent
e1a09e09
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
2 deletions
+33
-2
EndpointHandlerAdapter.java
...ork/boot/actuate/endpoint/mvc/EndpointHandlerAdapter.java
+1
-0
EndpointHandlerAdapterTests.java
...oot/actuate/endpoint/mvc/EndpointHandlerAdapterTests.java
+32
-2
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/EndpointHandlerAdapter.java
View file @
884fd012
...
...
@@ -50,6 +50,7 @@ import com.fasterxml.jackson.databind.SerializationFeature;
* {@link AbstractMessageConverterMethodProcessor} but not tied to annotated methods.
*
* @author Phillip Webb
*
* @see EndpointHandlerMapping
*/
public
final
class
EndpointHandlerAdapter
implements
HandlerAdapter
{
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/EndpointHandlerAdapterTests.java
View file @
884fd012
...
...
@@ -16,10 +16,16 @@
package
org
.
springframework
.
boot
.
actuate
.
endpoint
.
mvc
;
import
java.util.Collections
;
import
java.util.Map
;
import
org.junit.Test
;
import
org.springframework.boot.actuate.endpoint.AbstractEndpoint
;
import
org.springframework.boot.actuate.endpoint.Endpoint
;
import
org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerAdapter
;
import
org.springframework.mock.web.MockHttpServletRequest
;
import
org.springframework.mock.web.MockHttpServletResponse
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Mockito
.
mock
;
...
...
@@ -32,6 +38,8 @@ import static org.mockito.Mockito.mock;
public
class
EndpointHandlerAdapterTests
{
private
EndpointHandlerAdapter
adapter
=
new
EndpointHandlerAdapter
();
private
MockHttpServletRequest
request
=
new
MockHttpServletRequest
();
private
MockHttpServletResponse
response
=
new
MockHttpServletResponse
();
@Test
public
void
onlySupportsEndpoints
()
throws
Exception
{
...
...
@@ -39,6 +47,28 @@ public class EndpointHandlerAdapterTests {
assertFalse
(
this
.
adapter
.
supports
(
mock
(
Object
.
class
)));
}
// FIXME tests
@Test
public
void
rendersJson
()
throws
Exception
{
this
.
adapter
.
handle
(
this
.
request
,
this
.
response
,
new
AbstractEndpoint
<
Map
<
String
,
String
>>(
"/foo"
)
{
@Override
protected
Map
<
String
,
String
>
doInvoke
()
{
return
Collections
.
singletonMap
(
"hello"
,
"world"
);
}
});
assertEquals
(
"{\"hello\":\"world\"}"
,
this
.
response
.
getContentAsString
());
}
@Test
public
void
rendersString
()
throws
Exception
{
this
.
request
.
addHeader
(
"Accept"
,
"text/plain"
);
this
.
adapter
.
handle
(
this
.
request
,
this
.
response
,
new
AbstractEndpoint
<
String
>(
"/foo"
)
{
@Override
protected
String
doInvoke
()
{
return
"hello world"
;
}
});
assertEquals
(
"hello world"
,
this
.
response
.
getContentAsString
());
}
}
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