use of java.util.ListResourceBundle in project jdk8u_jdk by JetBrains.
the class NewResourcesNames method loadClass.
/**
* Loads a resources using JRE and returns the names
*/
private static Set<String> loadClass(String clazz) throws Exception {
ListResourceBundle lrb = (ListResourceBundle) Class.forName(clazz).newInstance();
Set<String> keys = lrb.keySet();
Map<String, String> newold = new HashMap<String, String>();
boolean dup = false;
// Check if normalize() creates dup entries. This is crucial.
for (String k : keys) {
String key = normalize(k);
if (newold.containsKey(key)) {
err("Dup found for " + key + ":");
err("[" + newold.get(key) + "]");
err("[" + k + "]");
dup = true;
}
newold.put(key, k);
}
if (dup)
throw new Exception();
return keys;
}
use of java.util.ListResourceBundle in project sling by apache.
the class MockSlingHttpServletRequestTest method testResourceBundleFromProvider.
@Test
public void testResourceBundleFromProvider() {
ResourceBundleProvider provider = mock(ResourceBundleProvider.class);
bundleContext.registerService(ResourceBundleProvider.class.getName(), provider, null);
when(provider.getResourceBundle("base1", Locale.US)).thenReturn(new ListResourceBundle() {
@Override
protected Object[][] getContents() {
return new Object[][] { { "key1", "value1" } };
}
});
ResourceBundle bundle = request.getResourceBundle("base1", Locale.US);
assertNotNull(bundle);
assertEquals("value1", bundle.getString("key1"));
ResourceBundle bundle2 = request.getResourceBundle("base2", Locale.US);
assertNotNull(bundle2);
assertFalse(bundle2.getKeys().hasMoreElements());
}
Aggregations