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
9bde1e89
Commit
9bde1e89
authored
Oct 21, 2016
by
Madhura Bhave
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move some tests to AbstractEndpointHandlerMapping
See gh-7108
parent
5fc58b45
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
112 additions
and
34 deletions
+112
-34
AbstractEndpointHandlerMapping.java
.../actuate/endpoint/mvc/AbstractEndpointHandlerMapping.java
+1
-1
CloudFoundryEndpointHandlerMappingTests.java
...cloudfoundry/CloudFoundryEndpointHandlerMappingTests.java
+2
-2
AbstractEndpointHandlerMappingTests.java
...ate/endpoint/mvc/AbstractEndpointHandlerMappingTests.java
+108
-0
EndpointHandlerMappingTests.java
...oot/actuate/endpoint/mvc/EndpointHandlerMappingTests.java
+1
-31
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/AbstractEndpointHandlerMapping.java
View file @
9bde1e89
...
@@ -52,7 +52,7 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
...
@@ -52,7 +52,7 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
* @author Dave Syer
* @author Dave Syer
* @author Madhura Bhave
* @author Madhura Bhave
*/
*/
public
class
AbstractEndpointHandlerMapping
<
E
extends
MvcEndpoint
>
public
abstract
class
AbstractEndpointHandlerMapping
<
E
extends
MvcEndpoint
>
extends
RequestMappingHandlerMapping
{
extends
RequestMappingHandlerMapping
{
private
final
Set
<
E
>
endpoints
;
private
final
Set
<
E
>
endpoints
;
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cloudfoundry/CloudFoundryEndpointHandlerMappingTests.java
View file @
9bde1e89
...
@@ -22,6 +22,7 @@ import java.util.Collections;
...
@@ -22,6 +22,7 @@ import java.util.Collections;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.actuate.endpoint.AbstractEndpoint
;
import
org.springframework.boot.actuate.endpoint.AbstractEndpoint
;
import
org.springframework.boot.actuate.endpoint.mvc.AbstractEndpointHandlerMappingTests
;
import
org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter
;
import
org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter
;
import
org.springframework.boot.actuate.endpoint.mvc.HalJsonMvcEndpoint
;
import
org.springframework.boot.actuate.endpoint.mvc.HalJsonMvcEndpoint
;
import
org.springframework.boot.actuate.endpoint.mvc.ManagementServletContext
;
import
org.springframework.boot.actuate.endpoint.mvc.ManagementServletContext
;
...
@@ -39,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -39,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
*
* @author Madhura Bhave
* @author Madhura Bhave
*/
*/
public
class
CloudFoundryEndpointHandlerMappingTests
{
public
class
CloudFoundryEndpointHandlerMappingTests
extends
AbstractEndpointHandlerMappingTests
{
@Test
@Test
public
void
getHandlerExecutionChainShouldHaveSecurityInterceptor
()
throws
Exception
{
public
void
getHandlerExecutionChainShouldHaveSecurityInterceptor
()
throws
Exception
{
...
@@ -117,7 +118,6 @@ public class CloudFoundryEndpointHandlerMappingTests {
...
@@ -117,7 +118,6 @@ public class CloudFoundryEndpointHandlerMappingTests {
}
}
});
});
}
}
}
}
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/AbstractEndpointHandlerMappingTests.java
0 → 100644
View file @
9bde1e89
/*
* Copyright 2012-2015 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
actuate
.
endpoint
.
mvc
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
org.junit.Test
;
import
org.springframework.boot.actuate.endpoint.AbstractEndpoint
;
import
org.springframework.context.support.StaticApplicationContext
;
import
org.springframework.mock.web.MockHttpServletRequest
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Tests for {@link AbstractEndpointHandlerMapping}.
*
* @author Madhura Bhave
*/
public
abstract
class
AbstractEndpointHandlerMappingTests
{
private
final
StaticApplicationContext
context
=
new
StaticApplicationContext
();
@Test
public
void
pathNotMappedWhenGetPathReturnsNull
()
throws
Exception
{
TestMvcEndpoint
endpoint
=
new
TestMvcEndpoint
(
new
TestEndpoint
(
"a"
));
TestActionEndpoint
other
=
new
TestActionEndpoint
(
new
TestEndpoint
(
"b"
));
AbstractEndpointHandlerMapping
mapping
=
new
TestEndpointHandlerMapping
(
Arrays
.
asList
(
endpoint
,
other
));
mapping
.
setApplicationContext
(
this
.
context
);
mapping
.
afterPropertiesSet
();
assertThat
(
mapping
.
getHandlerMethods
()).
hasSize
(
1
);
assertThat
(
mapping
.
getHandler
(
request
(
"GET"
,
"/a"
))).
isNull
();
assertThat
(
mapping
.
getHandler
(
request
(
"POST"
,
"/b"
))).
isNotNull
();
}
private
MockHttpServletRequest
request
(
String
method
,
String
requestURI
)
{
return
new
MockHttpServletRequest
(
method
,
requestURI
);
}
private
static
class
TestEndpoint
extends
AbstractEndpoint
<
Object
>
{
TestEndpoint
(
String
id
)
{
super
(
id
);
}
@Override
public
Object
invoke
()
{
return
null
;
}
}
private
static
class
TestMvcEndpoint
extends
EndpointMvcAdapter
{
TestMvcEndpoint
(
TestEndpoint
delegate
)
{
super
(
delegate
);
}
}
private
static
class
TestActionEndpoint
extends
EndpointMvcAdapter
{
TestActionEndpoint
(
TestEndpoint
delegate
)
{
super
(
delegate
);
}
@Override
@PostMapping
public
Object
invoke
()
{
return
null
;
}
}
private
static
class
TestEndpointHandlerMapping
extends
AbstractEndpointHandlerMapping
{
TestEndpointHandlerMapping
(
Collection
<?
extends
MvcEndpoint
>
endpoints
)
{
super
(
endpoints
);
}
@Override
protected
String
getPath
(
MvcEndpoint
endpoint
)
{
if
(
endpoint
instanceof
TestActionEndpoint
)
{
return
super
.
getPath
(
endpoint
);
}
return
null
;
}
}
}
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/EndpointHandlerMappingTests.java
View file @
9bde1e89
...
@@ -18,7 +18,6 @@ package org.springframework.boot.actuate.endpoint.mvc;
...
@@ -18,7 +18,6 @@ package org.springframework.boot.actuate.endpoint.mvc;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -39,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -39,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Phillip Webb
* @author Phillip Webb
* @author Dave Syer
* @author Dave Syer
*/
*/
public
class
EndpointHandlerMappingTests
{
public
class
EndpointHandlerMappingTests
extends
AbstractEndpointHandlerMappingTests
{
private
final
StaticApplicationContext
context
=
new
StaticApplicationContext
();
private
final
StaticApplicationContext
context
=
new
StaticApplicationContext
();
...
@@ -137,19 +136,6 @@ public class EndpointHandlerMappingTests {
...
@@ -137,19 +136,6 @@ public class EndpointHandlerMappingTests {
assertThat
(
mapping
.
getHandler
(
request
(
"POST"
,
"/a"
))).
isNull
();
assertThat
(
mapping
.
getHandler
(
request
(
"POST"
,
"/a"
))).
isNull
();
}
}
@Test
public
void
pathNotMappedWhenGetPathReturnsNull
()
throws
Exception
{
TestMvcEndpoint
endpoint
=
new
TestMvcEndpoint
(
new
TestEndpoint
(
"a"
));
TestActionEndpoint
other
=
new
TestActionEndpoint
(
new
TestEndpoint
(
"b"
));
EndpointHandlerMapping
mapping
=
new
TestEndpointHandlerMapping
(
Arrays
.
asList
(
endpoint
,
other
));
mapping
.
setApplicationContext
(
this
.
context
);
mapping
.
afterPropertiesSet
();
assertThat
(
mapping
.
getHandlerMethods
()).
hasSize
(
1
);
assertThat
(
mapping
.
getHandler
(
request
(
"GET"
,
"/a"
))).
isNull
();
assertThat
(
mapping
.
getHandler
(
request
(
"POST"
,
"/b"
))).
isNotNull
();
}
private
MockHttpServletRequest
request
(
String
method
,
String
requestURI
)
{
private
MockHttpServletRequest
request
(
String
method
,
String
requestURI
)
{
return
new
MockHttpServletRequest
(
method
,
requestURI
);
return
new
MockHttpServletRequest
(
method
,
requestURI
);
}
}
...
@@ -189,20 +175,4 @@ public class EndpointHandlerMappingTests {
...
@@ -189,20 +175,4 @@ public class EndpointHandlerMappingTests {
}
}
static
class
TestEndpointHandlerMapping
extends
EndpointHandlerMapping
{
TestEndpointHandlerMapping
(
Collection
<?
extends
MvcEndpoint
>
endpoints
)
{
super
(
endpoints
);
}
@Override
protected
String
getPath
(
MvcEndpoint
endpoint
)
{
if
(
endpoint
instanceof
TestActionEndpoint
)
{
return
super
.
getPath
(
endpoint
);
}
return
null
;
}
}
}
}
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