Skip to content

Test-Case for #14753 #14755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: issue-11795
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ class ResourceBundleMessageSourceSpec extends Specification {
void setup(){
messages = new TestResource('messages.properties','''\
foo=bar
shared.message=Messages Message
'''.stripIndent().getBytes('UTF-8'))

other = new TestResource('other.properties','''\
bar=foo
shared.message=Other Message
'''.stripIndent().getBytes('UTF-8'))
}

Expand All @@ -49,11 +51,27 @@ class ResourceBundleMessageSourceSpec extends Specification {
messageSource.setBasenames('messages','other')
def locale = Locale.default
expect:
messageSource.getBundleCodes(locale,'messages') == (['foo'] as Set)
messageSource.getBundleCodes(locale,'other') == (['bar'] as Set)
messageSource.getBundleCodes(locale,'messages','other') == (['foo','bar'] as Set)
messageSource.getBundleCodes(locale,'messages') == (['foo', 'shared.message'] as Set)
messageSource.getBundleCodes(locale,'other') == (['bar', 'shared.message'] as Set)
messageSource.getBundleCodes(locale,'messages','other') == (['foo','bar', 'shared.message'] as Set)
}

void 'Check method to verify ResourceBundle ordering prioritizes application over plugin messages'(){
given:
def messageSource = new ReloadableResourceBundleMessageSource(
resourceLoader: new DefaultResourceLoader(){
Resource getResourceByPath(String path){
path.startsWith('messages') ? messages:other
}
}
)
messageSource.setBasenames('other', 'messages')
def locale = Locale.default
expect: "other messages override plugin messages"
messageSource.getMessage('shared.message', null, locale) == 'Other Message'
messageSource.getMessage('foo', null, locale) == 'bar'
}

class TestResource extends ByteArrayResource{
String filename

Expand Down
Loading