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
11ac9bf6
Commit
11ac9bf6
authored
Oct 04, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Add ReloadableResourceBundleMessageSource support"
See gh-13377
parent
22abe35f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
24 deletions
+18
-24
MessageSourceAutoConfigurationTests.java
...onfigure/context/MessageSourceAutoConfigurationTests.java
+18
-24
No files found.
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/context/MessageSourceAutoConfigurationTests.java
View file @
11ac9bf6
...
@@ -21,7 +21,6 @@ import java.util.Locale;
...
@@ -21,7 +21,6 @@ import java.util.Locale;
import
org.junit.Ignore
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.DirectFieldAccessor
;
import
org.springframework.beans.DirectFieldAccessor
;
import
org.springframework.boot.autoconfigure.AutoConfigurations
;
import
org.springframework.boot.autoconfigure.AutoConfigurations
;
import
org.springframework.boot.test.context.assertj.AssertableApplicationContext
;
import
org.springframework.boot.test.context.assertj.AssertableApplicationContext
;
...
@@ -226,39 +225,34 @@ public class MessageSourceAutoConfigurationTests {
...
@@ -226,39 +225,34 @@ public class MessageSourceAutoConfigurationTests {
@Test
@Test
public
void
testDefaultReloadableValueMessageSource
()
{
public
void
testDefaultReloadableValueMessageSource
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.messages.basename:test/messages"
)
testReloadableMessageSource
(
ResourceBundleMessageSource
.
class
,
.
run
((
context
)
->
assertThat
(
getDeclaredMessageSource
(
context
))
"spring.messages.basename:test/messages"
);
.
isInstanceOf
(
ResourceBundleMessageSource
.
class
));
}
}
@Test
@Test
public
void
testNotReloadableMessageSource
()
{
public
void
testNotReloadableMessageSource
()
{
this
.
contextRunner
testReloadableMessageSource
(
ResourceBundleMessageSource
.
class
,
.
withPropertyValues
(
"spring.messages.basename:test/messages"
,
"spring.messages.basename:test/messages"
,
"spring.messages.reloadable:false"
)
"spring.messages.reloadable:false"
);
.
run
((
context
)
->
assertThat
(
getDeclaredMessageSource
(
context
))
.
isInstanceOf
(
ResourceBundleMessageSource
.
class
));
}
}
@Test
@Test
public
void
testReloadableMessageSource
()
{
public
void
testReloadableMessageSource
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.messages.basename:test/messages"
,
testReloadableMessageSource
(
ReloadableResourceBundleMessageSource
.
class
,
"spring.messages.reloadable:true"
).
run
((
context
)
->
{
"spring.messages.basename:test/messages"
,
assertThat
(
getDeclaredMessageSource
(
context
))
"spring.messages.reloadable:true"
);
.
isInstanceOf
(
ReloadableResourceBundleMessageSource
.
class
);
assertThat
(
context
.
getMessage
(
"foo"
,
null
,
"Foo message"
,
Locale
.
UK
))
.
isEqualTo
(
"bar"
);
});
}
}
private
MessageSource
getDeclaredMessageSource
(
AssertableApplicationContext
context
)
private
void
testReloadableMessageSource
(
Class
<?>
expectedInstance
,
throws
BeansException
{
String
...
propertyValues
)
{
MessageSource
messageSource
=
context
.
getBean
(
MessageSource
.
class
);
this
.
contextRunner
.
withPropertyValues
(
propertyValues
).
run
((
context
)
->
{
if
(
messageSource
instanceof
DelegatingMessageSource
)
{
MessageSource
messageSource
=
context
.
getBean
(
MessageSource
.
class
);
messageSource
=
((
DelegatingMessageSource
)
messageSource
)
if
(
messageSource
instanceof
DelegatingMessageSource
)
{
.
getParentMessageSource
();
messageSource
=
((
DelegatingMessageSource
)
messageSource
)
}
.
getParentMessageSource
();
return
messageSource
;
}
assertThat
(
messageSource
).
isInstanceOf
(
expectedInstance
);
});
}
}
@Configuration
@Configuration
...
...
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