|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2014 the original author or authors. |
| 2 | + * Copyright 2002-2017 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -210,6 +210,39 @@ public void testDefaultApplicationContextMessageSource() {
|
210 | 210 | assertEquals("default value", ac.getMessage("code1", new Object[] {"value"}, "default {0}", Locale.ENGLISH));
|
211 | 211 | }
|
212 | 212 |
|
| 213 | + @Test |
| 214 | + public void testDefaultApplicationContextMessageSourceWithParent() { |
| 215 | + GenericApplicationContext ac = new GenericApplicationContext(); |
| 216 | + GenericApplicationContext parent = new GenericApplicationContext(); |
| 217 | + parent.refresh(); |
| 218 | + ac.setParent(parent); |
| 219 | + ac.refresh(); |
| 220 | + assertEquals("default", ac.getMessage("code1", null, "default", Locale.ENGLISH)); |
| 221 | + assertEquals("default value", ac.getMessage("code1", new Object[] {"value"}, "default {0}", Locale.ENGLISH)); |
| 222 | + } |
| 223 | + |
| 224 | + @Test |
| 225 | + public void testStaticApplicationContextMessageSourceWithStaticParent() { |
| 226 | + StaticApplicationContext ac = new StaticApplicationContext(); |
| 227 | + StaticApplicationContext parent = new StaticApplicationContext(); |
| 228 | + parent.refresh(); |
| 229 | + ac.setParent(parent); |
| 230 | + ac.refresh(); |
| 231 | + assertEquals("default", ac.getMessage("code1", null, "default", Locale.ENGLISH)); |
| 232 | + assertEquals("default value", ac.getMessage("code1", new Object[] {"value"}, "default {0}", Locale.ENGLISH)); |
| 233 | + } |
| 234 | + |
| 235 | + @Test |
| 236 | + public void testStaticApplicationContextMessageSourceWithDefaultParent() { |
| 237 | + StaticApplicationContext ac = new StaticApplicationContext(); |
| 238 | + GenericApplicationContext parent = new GenericApplicationContext(); |
| 239 | + parent.refresh(); |
| 240 | + ac.setParent(parent); |
| 241 | + ac.refresh(); |
| 242 | + assertEquals("default", ac.getMessage("code1", null, "default", Locale.ENGLISH)); |
| 243 | + assertEquals("default value", ac.getMessage("code1", new Object[] {"value"}, "default {0}", Locale.ENGLISH)); |
| 244 | + } |
| 245 | + |
213 | 246 | @Test
|
214 | 247 | public void testResourceBundleMessageSourceStandalone() {
|
215 | 248 | ResourceBundleMessageSource ms = new ResourceBundleMessageSource();
|
|
0 commit comments