Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -43,6 +43,7 @@ public class StaticMessageSource extends AbstractMessageSource {
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected String resolveCodeWithoutArguments(String code, Locale locale) {
|
||||
return this.messages.get(code + '_' + locale.toString());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -62,7 +62,6 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests {
|
||||
@Test
|
||||
@Override
|
||||
public void count() {
|
||||
// These are only checked for current Ctx (not parent ctx)
|
||||
assertCount(15);
|
||||
}
|
||||
|
||||
@@ -109,8 +108,8 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests {
|
||||
|
||||
// Now msg better be as expected
|
||||
assertTrue("2nd search within MsgFormat cache returned expected message for Locale.US",
|
||||
sac.getMessage("message.format.example1", arguments, Locale.US).indexOf(
|
||||
"there was \"a disturbance in the Force\" on planet 7.") != -1);
|
||||
sac.getMessage("message.format.example1", arguments, Locale.US).
|
||||
contains("there was \"a disturbance in the Force\" on planet 7."));
|
||||
|
||||
Object[] newArguments = {
|
||||
new Integer(8), new Date(System.currentTimeMillis()),
|
||||
@@ -119,8 +118,8 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests {
|
||||
|
||||
// Now msg better be as expected even with different args
|
||||
assertTrue("2nd search within MsgFormat cache with different args returned expected message for Locale.US",
|
||||
sac.getMessage("message.format.example1", newArguments, Locale.US)
|
||||
.indexOf("there was \"a disturbance in the Force\" on planet 8.") != -1);
|
||||
sac.getMessage("message.format.example1", newArguments, Locale.US).
|
||||
contains("there was \"a disturbance in the Force\" on planet 8."));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,13 +141,13 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests {
|
||||
minutes of the time might not be the same.
|
||||
*/
|
||||
assertTrue("msg from staticMsgSource for Locale.US substituting args for placeholders is as expected",
|
||||
sac.getMessage("message.format.example1", arguments, Locale.US)
|
||||
.indexOf("there was \"a disturbance in the Force\" on planet 7.") != -1);
|
||||
sac.getMessage("message.format.example1", arguments, Locale.US).
|
||||
contains("there was \"a disturbance in the Force\" on planet 7."));
|
||||
|
||||
// Try with Locale.UK
|
||||
assertTrue("msg from staticMsgSource for Locale.UK substituting args for placeholders is as expected",
|
||||
sac.getMessage("message.format.example1", arguments, Locale.UK)
|
||||
.indexOf("there was \"a disturbance in the Force\" on station number 7.") != -1);
|
||||
sac.getMessage("message.format.example1", arguments, Locale.UK).
|
||||
contains("there was \"a disturbance in the Force\" on station number 7."));
|
||||
|
||||
// Try with Locale.US - Use a different test msg that requires no args
|
||||
assertTrue("msg from staticMsgSource for Locale.US that requires no args is as expected",
|
||||
|
||||
Reference in New Issue
Block a user