MessageSourceResourceBundle overrides JDK 1.6 containsKey method, avoiding NPE in getKeys

Issue: SPR-10136
This commit is contained in:
Juergen Hoeller
2013-01-03 16:31:00 +01:00
committed by unknown
parent 10dceb182e
commit 3a9ca4a6bb
2 changed files with 35 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@@ -340,6 +340,17 @@ public class ResourceBundleMessageSourceTests extends TestCase {
assertEquals(0, filenames.size());
}
public void testMessageSourceResourceBundle() {
ResourceBundleMessageSource ms = new ResourceBundleMessageSource();
ms.setBasename("org/springframework/context/support/messages");
MessageSourceResourceBundle rbe = new MessageSourceResourceBundle(ms, Locale.ENGLISH);
assertEquals("message1", rbe.getString("code1"));
assertTrue(rbe.containsKey("code1"));
MessageSourceResourceBundle rbg = new MessageSourceResourceBundle(ms, Locale.GERMAN);
assertEquals("nachricht2", rbg.getString("code2"));
assertTrue(rbg.containsKey("code2"));
}
@Override
protected void tearDown() throws Exception {
if (JdkVersion.getMajorJavaVersion() >= JdkVersion.JAVA_16) {