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
7a935d37
Commit
7a935d37
authored
Aug 13, 2013
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for nested properties
parent
c6c1f508
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
EnableConfigurationPropertiesTests.java
...ontext/properties/EnableConfigurationPropertiesTests.java
+38
-0
No files found.
spring-boot/src/test/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesTests.java
View file @
7a935d37
...
@@ -52,6 +52,16 @@ public class EnableConfigurationPropertiesTests {
...
@@ -52,6 +52,16 @@ public class EnableConfigurationPropertiesTests {
assertEquals
(
"foo"
,
this
.
context
.
getBean
(
TestProperties
.
class
).
name
);
assertEquals
(
"foo"
,
this
.
context
.
getBean
(
TestProperties
.
class
).
name
);
}
}
@Test
public
void
testNestedPropertiesBinding
()
{
this
.
context
.
register
(
NestedConfiguration
.
class
);
TestUtils
.
addEnviroment
(
this
.
context
,
"name:foo"
,
"nested.name:bar"
);
this
.
context
.
refresh
();
assertEquals
(
1
,
this
.
context
.
getBeanNamesForType
(
NestedProperties
.
class
).
length
);
assertEquals
(
"foo"
,
this
.
context
.
getBean
(
NestedProperties
.
class
).
name
);
assertEquals
(
"bar"
,
this
.
context
.
getBean
(
NestedProperties
.
class
).
nested
.
name
);
}
@Test
@Test
public
void
testBasicPropertiesBindingWithAnnotationOnBaseClass
()
{
public
void
testBasicPropertiesBindingWithAnnotationOnBaseClass
()
{
this
.
context
.
register
(
DerivedConfiguration
.
class
);
this
.
context
.
register
(
DerivedConfiguration
.
class
);
...
@@ -190,6 +200,11 @@ public class EnableConfigurationPropertiesTests {
...
@@ -190,6 +200,11 @@ public class EnableConfigurationPropertiesTests {
protected
static
class
DerivedConfiguration
{
protected
static
class
DerivedConfiguration
{
}
}
@Configuration
@EnableConfigurationProperties
(
NestedProperties
.
class
)
protected
static
class
NestedConfiguration
{
}
@Configuration
@Configuration
protected
static
class
DefaultConfiguration
{
protected
static
class
DefaultConfiguration
{
@Bean
@Bean
...
@@ -225,6 +240,29 @@ public class EnableConfigurationPropertiesTests {
...
@@ -225,6 +240,29 @@ public class EnableConfigurationPropertiesTests {
protected
static
class
MoreConfiguration
{
protected
static
class
MoreConfiguration
{
}
}
@ConfigurationProperties
protected
static
class
NestedProperties
{
private
String
name
;
private
Nested
nested
=
new
Nested
();
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
Nested
getNested
()
{
return
this
.
nested
;
}
protected
static
class
Nested
{
private
String
name
;
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
}
}
@ConfigurationProperties
@ConfigurationProperties
protected
static
class
BaseProperties
{
protected
static
class
BaseProperties
{
private
String
name
;
private
String
name
;
...
...
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