Polishing

This commit is contained in:
Juergen Hoeller
2019-11-13 23:56:44 +01:00
parent be0e0f6e48
commit a20d7fa119
2 changed files with 11 additions and 11 deletions

View File

@@ -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());
}

View File

@@ -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",