aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-04-17 17:45:24 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-04-17 17:45:24 +0200
commit9fb1ab8fc45a7735e2aef7d625acb130f78e4d26 (patch)
tree34eb674c74dbb3485fbbe451e55e60577749bc89 /sonar-core
parente06fbd40a4b52994f4c5a5f9918c09e2d6032c3c (diff)
downloadsonarqube-9fb1ab8fc45a7735e2aef7d625acb130f78e4d26.tar.gz
sonarqube-9fb1ab8fc45a7735e2aef7d625acb130f78e4d26.zip
When there's no language plugin, load core bundle
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java30
-rw-r--r--sonar-core/src/test/java/org/sonar/core/i18n/DefaultI18nTest.java9
2 files changed, 28 insertions, 11 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java b/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java
index b987061e18e..4bf009a9a42 100644
--- a/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java
+++ b/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java
@@ -84,21 +84,29 @@ public class DefaultI18n implements I18n, ServerExtension, BatchExtension, Start
void doStart(ClassLoader classloader) {
this.classloader = classloader;
propertyToBundles = Maps.newHashMap();
- for (PluginMetadata plugin : pluginRepository.getMetadata()) {
- try {
- String bundleKey = BUNDLE_PACKAGE + plugin.getKey();
- ResourceBundle bundle = ResourceBundle.getBundle(bundleKey, Locale.ENGLISH, this.classloader, control);
- Enumeration<String> keys = bundle.getKeys();
- while (keys.hasMoreElements()) {
- String key = keys.nextElement();
- propertyToBundles.put(key, bundleKey);
- }
- } catch (MissingResourceException e) {
- // ignore
+ Collection<PluginMetadata> metadata = pluginRepository.getMetadata();
+ if (metadata.isEmpty()) {
+ addPlugin("core");
+ } else {
+ for (PluginMetadata plugin : pluginRepository.getMetadata()) {
+ addPlugin(plugin.getKey());
}
}
LOG.debug(String.format("Loaded %d properties from l10n bundles", propertyToBundles.size()));
}
+ private void addPlugin(String pluginKey){
+ try {
+ String bundleKey = BUNDLE_PACKAGE + pluginKey;
+ ResourceBundle bundle = ResourceBundle.getBundle(bundleKey, Locale.ENGLISH, this.classloader, control);
+ Enumeration<String> keys = bundle.getKeys();
+ while (keys.hasMoreElements()) {
+ String key = keys.nextElement();
+ propertyToBundles.put(key, bundleKey);
+ }
+ } catch (MissingResourceException e) {
+ // ignore
+ }
+ }
@Override
public void stop() {
diff --git a/sonar-core/src/test/java/org/sonar/core/i18n/DefaultI18nTest.java b/sonar-core/src/test/java/org/sonar/core/i18n/DefaultI18nTest.java
index f9fc70b0960..7fd150b3608 100644
--- a/sonar-core/src/test/java/org/sonar/core/i18n/DefaultI18nTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/i18n/DefaultI18nTest.java
@@ -58,6 +58,15 @@ public class DefaultI18nTest {
}
@Test
+ public void load_core_bundle_when_no_plugin() {
+ DefaultI18n manager = new DefaultI18n(mock(PluginRepository.class), system2);
+ manager.doStart(getClass().getClassLoader());
+
+ assertThat(manager.getPropertyKeys().contains("any")).isTrue();
+ assertThat(manager.getPropertyKeys().contains("assignee")).isTrue();
+ }
+
+ @Test
public void introspect_all_available_properties() {
assertThat(manager.getPropertyKeys().contains("any")).isTrue();
// Only in english