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
43c5151e
Commit
43c5151e
authored
Jul 20, 2015
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.2.x'
parents
e1479a02
539b009d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
24 deletions
+34
-24
ManagementServerProperties.java
...oot/actuate/autoconfigure/ManagementServerProperties.java
+13
-1
ManagementServerPropertiesAutoConfigurationTests.java
...ure/ManagementServerPropertiesAutoConfigurationTests.java
+21
-23
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementServerProperties.java
View file @
43c5151e
...
...
@@ -26,11 +26,13 @@ import org.springframework.boot.autoconfigure.web.ServerProperties;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.security.config.http.SessionCreationPolicy
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.StringUtils
;
/**
* Properties for the management server (e.g. port and path settings).
*
* @author Dave Syer
* @author Stephane Nicoll
* @see ServerProperties
*/
@ConfigurationProperties
(
prefix
=
"management"
,
ignoreUnknownFields
=
true
)
...
...
@@ -103,12 +105,22 @@ public class ManagementServerProperties implements SecurityPrerequisite {
this
.
address
=
address
;
}
/**
* Return the context path with no trailing slash (i.e. the '/' root context is
* represented as the empty string).
* @return the context path (no trailing slash)
*/
public
String
getContextPath
()
{
return
this
.
contextPath
;
}
public
void
setContextPath
(
String
contextPath
)
{
this
.
contextPath
=
contextPath
;
if
(
StringUtils
.
hasText
(
contextPath
)
&&
contextPath
.
endsWith
(
"/"
))
{
this
.
contextPath
=
contextPath
.
substring
(
0
,
contextPath
.
length
()
-
1
);
}
else
{
this
.
contextPath
=
contextPath
;
}
}
public
Security
getSecurity
()
{
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ManagementServerPropertiesAutoConfigurationTests.java
View file @
43c5151e
...
...
@@ -17,9 +17,6 @@
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
;
import
org.junit.Test
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
nullValue
;
...
...
@@ -29,37 +26,38 @@ import static org.junit.Assert.assertThat;
* Tests for {@link ManagementServerPropertiesAutoConfiguration}.
*
* @author Phillip Webb
* @author Stephane Nicoll
*/
public
class
ManagementServerPropertiesAutoConfigurationTests
{
@Test
public
void
defaultManagementServerProperties
()
{
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
(
ManagementServerPropertiesAutoConfiguration
.
class
);
assertThat
(
context
.
getBean
(
ManagementServerProperties
.
class
).
getPort
(),
nullValue
());
context
.
close
();
ManagementServerProperties
properties
=
new
ManagementServerProperties
();
assertThat
(
properties
.
getPort
(),
nullValue
());
assertThat
(
properties
.
getContextPath
(),
equalTo
(
""
));
}
@Test
public
void
definedManagementServerProperties
()
throws
Exception
{
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
(
Config
.
class
,
ManagementServerPropertiesAutoConfiguration
.
class
);
assertThat
(
context
.
getBean
(
ManagementServerProperties
.
class
).
getPort
(),
equalTo
(
Integer
.
valueOf
(
123
)
));
context
.
close
(
);
public
void
definedManagementServerProperties
()
{
ManagementServerProperties
properties
=
new
ManagementServerProperties
();
properties
.
setPort
(
123
);
properties
.
setContextPath
(
"/foo"
);
assertThat
(
properties
.
getPort
(),
equalTo
(
123
));
assertThat
(
properties
.
getContextPath
(),
equalTo
(
"/foo"
)
);
}
@Configuration
public
static
class
Config
{
@Bean
public
ManagementServerProperties
managementServerProperties
()
{
ManagementServerProperties
properties
=
new
ManagementServerProperties
();
properties
.
setPort
(
123
);
return
properties
;
}
@Test
public
void
trailingSlashOfContextPathIsRemoved
()
{
ManagementServerProperties
properties
=
new
ManagementServerProperties
();
properties
.
setContextPath
(
"/foo/"
);
assertThat
(
properties
.
getContextPath
(),
equalTo
(
"/foo"
));
}
@Test
public
void
slashOfContextPathIsDefaultValue
()
{
ManagementServerProperties
properties
=
new
ManagementServerProperties
();
properties
.
setContextPath
(
"/"
);
assertThat
(
properties
.
getContextPath
(),
equalTo
(
""
));
}
}
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