aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/sonar-l10n-en-plugin/pom.xml62
-rw-r--r--plugins/sonar-l10n-en-plugin/src/main/java/org/sonar/plugins/l10n/EnglishPackPlugin.java32
-rw-r--r--plugins/sonar-l10n-en-plugin/src/test/java/org/sonar/plugins/l10n/EnglishPackPluginTest.java31
-rw-r--r--pom.xml1
-rw-r--r--sonar-application/pom.xml7
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java9
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginRepositoryTest.java9
-rw-r--r--sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java16
-rw-r--r--sonar-core/src/main/java/org/sonar/core/i18n/I18nClassloader.java19
-rw-r--r--sonar-core/src/main/resources/org/sonar/l10n/core.properties (renamed from plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties)0
-rw-r--r--sonar-core/src/main/resources/org/sonar/l10n/gwt.properties (renamed from plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/gwt.properties)8
-rw-r--r--sonar-core/src/test/java/org/sonar/core/i18n/DefaultI18nTest.java80
-rw-r--r--sonar-core/src/test/java/org/sonar/core/i18n/GwtI18nTest.java4
-rw-r--r--sonar-core/src/test/java/org/sonar/core/i18n/I18nClassloaderTest.java39
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/i18n/I18nClassloaderTest/org/sonar/l10n/checkstyle.properties1
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/i18n/checkstylePlugin/org/sonar/l10n/checkstyle/ArchitectureRule.html1
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/i18n/corePlugin/org/sonar/l10n/core.properties9
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/i18n/frenchPack/org/sonar/l10n/checkstyle_fr/ArchitectureRule.html1
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/i18n/frenchPack/org/sonar/l10n/core_fr.properties2
-rw-r--r--sonar-core/src/test/resources/org/sonar/l10n/checkstyle.properties (renamed from sonar-core/src/test/resources/org/sonar/core/i18n/checkstylePlugin/org/sonar/l10n/checkstyle.properties)0
-rw-r--r--sonar-core/src/test/resources/org/sonar/l10n/checkstyle_fr.properties (renamed from sonar-core/src/test/resources/org/sonar/core/i18n/frenchPack/org/sonar/l10n/checkstyle_fr.properties)0
-rw-r--r--sonar-core/src/test/resources/org/sonar/l10n/core_fr.properties2
-rw-r--r--sonar-core/src/test/resources/org/sonar/l10n/sqale.properties (renamed from sonar-core/src/test/resources/org/sonar/core/i18n/sqalePlugin/org/sonar/l10n/sqale.properties)0
-rw-r--r--sonar-core/src/test/resources/org/sonar/l10n/sqale_fr.properties (renamed from sonar-core/src/test/resources/org/sonar/core/i18n/sqalePlugin/org/sonar/l10n/sqale_fr.properties)0
-rw-r--r--sonar-server/pom.xml7
25 files changed, 81 insertions, 259 deletions
diff --git a/plugins/sonar-l10n-en-plugin/pom.xml b/plugins/sonar-l10n-en-plugin/pom.xml
deleted file mode 100644
index 2f8bc3e9f7b..00000000000
--- a/plugins/sonar-l10n-en-plugin/pom.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar</artifactId>
- <version>4.3-SNAPSHOT</version>
- <relativePath>../..</relativePath>
- </parent>
-
- <groupId>org.codehaus.sonar.plugins</groupId>
- <artifactId>sonar-l10n-en-plugin</artifactId>
- <packaging>sonar-plugin</packaging>
- <name>SonarQube :: Plugins :: English Pack</name>
-
- <dependencies>
- <dependency>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-plugin-api</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.easytesting</groupId>
- <artifactId>fest-assert</artifactId>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>native2ascii-maven-plugin</artifactId>
- <version>1.0-beta-1</version>
- <executions>
- <execution>
- <goals>
- <goal>native2ascii</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-packaging-maven-plugin</artifactId>
- <configuration>
- <pluginName>English Pack</pluginName>
- <pluginClass>org.sonar.plugins.l10n.EnglishPackPlugin</pluginClass>
- <pluginDescription><![CDATA[Language pack for English]]></pluginDescription>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/plugins/sonar-l10n-en-plugin/src/main/java/org/sonar/plugins/l10n/EnglishPackPlugin.java b/plugins/sonar-l10n-en-plugin/src/main/java/org/sonar/plugins/l10n/EnglishPackPlugin.java
deleted file mode 100644
index 1a774bda931..00000000000
--- a/plugins/sonar-l10n-en-plugin/src/main/java/org/sonar/plugins/l10n/EnglishPackPlugin.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.plugins.l10n;
-
-import org.sonar.api.SonarPlugin;
-
-import java.util.Collections;
-import java.util.List;
-
-public final class EnglishPackPlugin extends SonarPlugin {
-
- public List getExtensions() {
- return Collections.emptyList();
- }
-}
diff --git a/plugins/sonar-l10n-en-plugin/src/test/java/org/sonar/plugins/l10n/EnglishPackPluginTest.java b/plugins/sonar-l10n-en-plugin/src/test/java/org/sonar/plugins/l10n/EnglishPackPluginTest.java
deleted file mode 100644
index 1e8ecc6c7af..00000000000
--- a/plugins/sonar-l10n-en-plugin/src/test/java/org/sonar/plugins/l10n/EnglishPackPluginTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.plugins.l10n;
-
-import org.junit.Test;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class EnglishPackPluginTest {
- @Test
- public void no_extensions() {
- assertThat(new EnglishPackPlugin().getExtensions()).isEmpty();
- }
-}
diff --git a/pom.xml b/pom.xml
index d7a92dcf1de..62b3fcaea10 100644
--- a/pom.xml
+++ b/pom.xml
@@ -34,7 +34,6 @@
<module>plugins/sonar-dbcleaner-plugin</module>
<module>plugins/sonar-cpd-plugin</module>
<module>plugins/sonar-design-plugin</module>
- <module>plugins/sonar-l10n-en-plugin</module>
<module>plugins/sonar-email-notifications-plugin</module>
<module>plugins/sonar-maven-batch-plugin</module>
<module>plugins/sonar-xoo-plugin</module>
diff --git a/sonar-application/pom.xml b/sonar-application/pom.xml
index 34c0f89f99a..c59caf02c7b 100644
--- a/sonar-application/pom.xml
+++ b/sonar-application/pom.xml
@@ -146,13 +146,6 @@
</dependency>
<dependency>
<groupId>org.codehaus.sonar.plugins</groupId>
- <artifactId>sonar-l10n-en-plugin</artifactId>
- <version>${project.version}</version>
- <type>sonar-plugin</type>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.codehaus.sonar.plugins</groupId>
<artifactId>sonar-email-notifications-plugin</artifactId>
<version>${project.version}</version>
<type>sonar-plugin</type>
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java
index 584ecce1cad..2e2b09da23c 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java
@@ -36,11 +36,7 @@ import org.sonar.core.plugins.RemotePlugin;
import java.io.File;
import java.text.MessageFormat;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Sets.newHashSet;
@@ -49,7 +45,6 @@ public class BatchPluginRepository implements PluginRepository {
private static final Logger LOG = LoggerFactory.getLogger(BatchPluginRepository.class);
private static final String CORE_PLUGIN = "core";
- private static final String ENGLISH_PACK_PLUGIN = "l10nen";
private PluginDownloader pluginDownloader;
private Map<String, Plugin> pluginsByKey;
@@ -164,7 +159,7 @@ public class BatchPluginRepository implements PluginRepository {
}
boolean accepts(String pluginKey) {
- if (CORE_PLUGIN.equals(pluginKey) || ENGLISH_PACK_PLUGIN.equals(pluginKey)) {
+ if (CORE_PLUGIN.equals(pluginKey)) {
return true;
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginRepositoryTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginRepositoryTest.java
index b1a4eb2a999..0592c2158d4 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginRepositoryTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginRepositoryTest.java
@@ -158,15 +158,6 @@ public class BatchPluginRepositoryTest {
assertThat(filter.accepts("core")).isTrue();
}
- // English Pack plugin should never be blacklisted as it is mandatory for the I18nManager on batch side
- @Test
- public void englishPackPluginShouldNeverBeInBlackList() {
- Settings settings = new Settings()
- .setProperty(CoreProperties.BATCH_EXCLUDE_PLUGINS, "l10nen,findbugs");
- BatchPluginRepository.PluginFilter filter = new BatchPluginRepository.PluginFilter(settings, mode);
- assertThat(filter.accepts("l10nen")).isTrue();
- }
-
@Test
public void check_white_list_with_black_list() {
Settings settings = new Settings()
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 066743f9a6d..b987061e18e 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
@@ -49,7 +49,7 @@ public class DefaultI18n implements I18n, ServerExtension, BatchExtension, Start
public static final String BUNDLE_PACKAGE = "org.sonar.l10n.";
private PluginRepository pluginRepository;
- private I18nClassloader i18nClassloader;
+ private ClassLoader classloader;
private Map<String, String> propertyToBundles;
private final ResourceBundle.Control control;
private final System2 system2;
@@ -81,13 +81,13 @@ public class DefaultI18n implements I18n, ServerExtension, BatchExtension, Start
}
@VisibleForTesting
- void doStart(I18nClassloader classloader) {
- this.i18nClassloader = classloader;
+ 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, i18nClassloader, control);
+ ResourceBundle bundle = ResourceBundle.getBundle(bundleKey, Locale.ENGLISH, this.classloader, control);
Enumeration<String> keys = bundle.getKeys();
while (keys.hasMoreElements()) {
String key = keys.nextElement();
@@ -102,7 +102,7 @@ public class DefaultI18n implements I18n, ServerExtension, BatchExtension, Start
@Override
public void stop() {
- i18nClassloader = null;
+ classloader = null;
propertyToBundles = null;
}
@@ -112,7 +112,7 @@ public class DefaultI18n implements I18n, ServerExtension, BatchExtension, Start
String value = null;
if (bundleKey != null) {
try {
- ResourceBundle resourceBundle = ResourceBundle.getBundle(bundleKey, locale, i18nClassloader, control);
+ ResourceBundle resourceBundle = ResourceBundle.getBundle(bundleKey, locale, classloader, control);
value = resourceBundle.getString(key);
} catch (MissingResourceException e1) {
// ignore
@@ -165,7 +165,7 @@ public class DefaultI18n implements I18n, ServerExtension, BatchExtension, Start
filePath += "_" + locale.getLanguage();
}
filePath += "/" + filename;
- InputStream input = i18nClassloader.getResourceAsStream(filePath);
+ InputStream input = classloader.getResourceAsStream(filePath);
if (input != null) {
result = readInputStream(filePath, input);
}
@@ -198,6 +198,6 @@ public class DefaultI18n implements I18n, ServerExtension, BatchExtension, Start
}
ClassLoader getBundleClassLoader() {
- return i18nClassloader;
+ return classloader;
}
}
diff --git a/sonar-core/src/main/java/org/sonar/core/i18n/I18nClassloader.java b/sonar-core/src/main/java/org/sonar/core/i18n/I18nClassloader.java
index 9987fa9800e..d0eb0510763 100644
--- a/sonar-core/src/main/java/org/sonar/core/i18n/I18nClassloader.java
+++ b/sonar-core/src/main/java/org/sonar/core/i18n/I18nClassloader.java
@@ -30,25 +30,28 @@ import java.util.List;
class I18nClassloader extends URLClassLoader {
- private ClassLoader[] pluginClassloaders;
-
- public I18nClassloader(PluginRepository pluginRepository) {
- super(new URL[0]);
+ private static List<ClassLoader> classLoadersFromPlugin(PluginRepository pluginRepository) {
List<ClassLoader> list = Lists.newArrayList();
-
for (PluginMetadata metadata : pluginRepository.getMetadata()) {
Plugin plugin = pluginRepository.getPlugin(metadata.getKey());
list.add(plugin.getClass().getClassLoader());
}
+ return list;
+ }
+
+ private ClassLoader[] pluginClassloaders;
- this.pluginClassloaders = list.toArray(new ClassLoader[list.size()]);
+ public I18nClassloader(PluginRepository pluginRepository) {
+ this(classLoadersFromPlugin(pluginRepository));
}
- I18nClassloader(ClassLoader[] pluginClassloaders) {
+ I18nClassloader(List<ClassLoader> pluginClassloaders) {
super(new URL[0]);
- this.pluginClassloaders = pluginClassloaders;
+ pluginClassloaders.add(getClass().getClassLoader());
+ this.pluginClassloaders = pluginClassloaders.toArray(new ClassLoader[pluginClassloaders.size()]);
}
+ @Override
public URL getResource(String name) {
for (ClassLoader pluginClassloader : pluginClassloaders) {
URL url = pluginClassloader.getResource(name);
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
index c9a1ae7140a..c9a1ae7140a 100644
--- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
+++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/gwt.properties b/sonar-core/src/main/resources/org/sonar/l10n/gwt.properties
index 9febb9a1a1f..aaa12a5fa72 100644
--- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/gwt.properties
+++ b/sonar-core/src/main/resources/org/sonar/l10n/gwt.properties
@@ -17,11 +17,3 @@ libs.expand=Expand all
libs.collapse=Collapse all
libs.noLibraries=No libraries
libs.usageLink=Usages
-
-
-# Unit tests viewer
-unittest.duration=Duration
-unittest.name=Unit test name
-unittest.skipped=skipped
-unittest.tests=Tests
-unittest.failures=Failures/Errors \ No newline at end of file
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 66e35d66d28..f9fc70b0960 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
@@ -50,38 +50,36 @@ public class DefaultI18nTest {
@Before
public void before() {
PluginRepository pluginRepository = mock(PluginRepository.class);
- List<PluginMetadata> plugins = Arrays.asList(newPlugin("sqale"), newPlugin("frpack"), newPlugin("core"), newPlugin("checkstyle"), newPlugin("other"));
+ List<PluginMetadata> plugins = Arrays.asList(newPlugin("core"), newPlugin("sqale"), newPlugin("frpack"), newPlugin("checkstyle"), newPlugin("other"));
when(pluginRepository.getMetadata()).thenReturn(plugins);
- I18nClassloader i18nClassloader = new I18nClassloader(new ClassLoader[]{
- newCoreClassloader(), newFrenchPackClassloader(), newSqaleClassloader(), newCheckstyleClassloader()
- });
manager = new DefaultI18n(pluginRepository, system2);
- manager.doStart(i18nClassloader);
+ manager.doStart(getClass().getClassLoader());
}
@Test
- public void should_introspect_all_available_properties() {
- assertThat(manager.getPropertyKeys().contains("by")).isTrue();
- assertThat(manager.getPropertyKeys().contains("only.in.english")).isTrue();
+ public void introspect_all_available_properties() {
+ assertThat(manager.getPropertyKeys().contains("any")).isTrue();
+ // Only in english
+ assertThat(manager.getPropertyKeys().contains("assignee")).isTrue();
assertThat(manager.getPropertyKeys().contains("sqale.page")).isTrue();
assertThat(manager.getPropertyKeys().contains("unknown")).isFalse();
}
@Test
- public void should_get_english_labels() {
- assertThat(manager.message(Locale.ENGLISH, "by", null)).isEqualTo("By");
+ public void get_english_labels() {
+ assertThat(manager.message(Locale.ENGLISH, "any", null)).isEqualTo("Any");
assertThat(manager.message(Locale.ENGLISH, "sqale.page", null)).isEqualTo("Sqale page title");
assertThat(manager.message(Locale.ENGLISH, "checkstyle.rule1.name", null)).isEqualTo("Rule one");
}
// SONAR-2927
@Test
- public void should_get_english_labels_when_default_locale_is_not_english() {
+ public void get_english_labels_when_default_locale_is_not_english() {
Locale defaultLocale = Locale.getDefault();
try {
Locale.setDefault(Locale.FRENCH);
- assertThat(manager.message(Locale.ENGLISH, "by", null)).isEqualTo("By");
+ assertThat(manager.message(Locale.ENGLISH, "any", null)).isEqualTo("Any");
assertThat(manager.message(Locale.ENGLISH, "sqale.page", null)).isEqualTo("Sqale page title");
assertThat(manager.message(Locale.ENGLISH, "checkstyle.rule1.name", null)).isEqualTo("Rule one");
} finally {
@@ -90,85 +88,61 @@ public class DefaultI18nTest {
}
@Test
- public void should_get_labels_from_french_pack() {
+ public void get_labels_from_french_pack() {
assertThat(manager.message(Locale.FRENCH, "checkstyle.rule1.name", null)).isEqualTo("Rule un");
- assertThat(manager.message(Locale.FRENCH, "by", null)).isEqualTo("Par");
+ assertThat(manager.message(Locale.FRENCH, "any", null)).isEqualTo("Tous");
// language pack
assertThat(manager.message(Locale.FRENCH, "sqale.page", null)).isEqualTo("Titre de la page Sqale");
}
@Test
- public void should_get_french_label_if_swiss_country() {
+ public void get_french_label_if_swiss_country() {
Locale swiss = new Locale("fr", "CH");
assertThat(manager.message(swiss, "checkstyle.rule1.name", null)).isEqualTo("Rule un");
- assertThat(manager.message(swiss, "by", null)).isEqualTo("Par");
+ assertThat(manager.message(swiss, "any", null)).isEqualTo("Tous");
// language pack
assertThat(manager.message(swiss, "sqale.page", null)).isEqualTo("Titre de la page Sqale");
}
@Test
- public void should_fallback_to_default_locale() {
+ public void fallback_to_default_locale() {
assertThat(manager.message(Locale.CHINA, "checkstyle.rule1.name", null)).isEqualTo("Rule one");
- assertThat(manager.message(Locale.CHINA, "by", null)).isEqualTo("By");
+ assertThat(manager.message(Locale.CHINA, "any", null)).isEqualTo("Any");
assertThat(manager.message(Locale.CHINA, "sqale.page", null)).isEqualTo("Sqale page title");
}
@Test
- public void should_return_default_value_if_missing_key() {
+ public void return_default_value_if_missing_key() {
assertThat(manager.message(Locale.ENGLISH, "unknown", "default")).isEqualTo("default");
assertThat(manager.message(Locale.FRENCH, "unknown", "default")).isEqualTo("default");
}
@Test
- public void should_accept_empty_labels() {
- assertThat(manager.message(Locale.ENGLISH, "empty", "default")).isEqualTo("");
- assertThat(manager.message(Locale.FRENCH, "empty", "default")).isEqualTo("");
+ public void format_message_with_parameters() {
+ assertThat(manager.message(Locale.ENGLISH, "name_too_long_x", null, "10")).isEqualTo("Name is too long (maximum is 10 characters)");
}
@Test
- public void shouldFormatMessageWithParameters() {
- assertThat(manager.message(Locale.ENGLISH, "with.parameters", null, "one", "two")).isEqualTo("First is one and second is two");
+ public void use_default_locale_if_missing_value_in_localized_bundle() {
+ assertThat(manager.message(Locale.FRENCH, "assignee", null)).isEqualTo("Assignee");
+ assertThat(manager.message(Locale.CHINA, "assignee", null)).isEqualTo("Assignee");
}
@Test
- public void shouldUseDefaultLocaleIfMissingValueInLocalizedBundle() {
- assertThat(manager.message(Locale.FRENCH, "only.in.english", null)).isEqualTo("Missing in French bundle");
- assertThat(manager.message(Locale.CHINA, "only.in.english", null)).isEqualTo("Missing in French bundle");
- }
-
- @Test
- public void should_locate_english_file() {
- String html = manager.messageFromFile(Locale.ENGLISH, "ArchitectureRule.html", "checkstyle.rule1.name");
- assertThat(html).isEqualTo("This is the architecture rule");
- }
-
- @Test
- public void should_return_null_if_file_not_found() {
+ public void return_null_if_file_not_found() {
String html = manager.messageFromFile(Locale.ENGLISH, "UnknownRule.html", "checkstyle.rule1.name");
assertThat(html).isNull();
}
@Test
- public void should_return_null_if_rule_not_internationalized() {
+ public void return_null_if_rule_not_internationalized() {
String html = manager.messageFromFile(Locale.ENGLISH, "UnknownRule.html", "foo.rule1.name");
assertThat(html).isNull();
}
@Test
- public void should_locate_french_file() {
- String html = manager.messageFromFile(Locale.FRENCH, "ArchitectureRule.html", "checkstyle.rule1.name");
- assertThat(html).isEqualTo("Règle d'architecture");
- }
-
- @Test
- public void should_locate_file_with_missing_locale() {
- String html = manager.messageFromFile(Locale.CHINA, "ArchitectureRule.html", "checkstyle.rule1.name");
- assertThat(html).isNull();
- }
-
- @Test
public void get_age_with_duration() {
assertThat(manager.age(Locale.ENGLISH, 10)).isEqualTo("less than a minute");
}
@@ -195,12 +169,8 @@ public class DefaultI18nTest {
assertThat(manager.formatDate(Locale.ENGLISH, DateUtils.parseDateTime("2014-01-22T19:10:03+0100"))).isEqualTo("Jan 22, 2014");
}
- static URLClassLoader newCoreClassloader() {
- return newClassLoader("/org/sonar/core/i18n/corePlugin/");
- }
-
static URLClassLoader newCheckstyleClassloader() {
- return newClassLoader("/org/sonar/core/i18n/checkstylePlugin/");
+ return newClassLoader("/org/sonar/core/i18n/I18nClassloaderTest/");
}
/**
diff --git a/sonar-core/src/test/java/org/sonar/core/i18n/GwtI18nTest.java b/sonar-core/src/test/java/org/sonar/core/i18n/GwtI18nTest.java
index f719ece6297..0f299a7bedc 100644
--- a/sonar-core/src/test/java/org/sonar/core/i18n/GwtI18nTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/i18n/GwtI18nTest.java
@@ -46,13 +46,13 @@ public class GwtI18nTest {
}
@Test
- public void shouldListAllPropertyKeysAtStartup() {
+ public void list_all_property_keys_at_startup() {
assertThat(i18n.getPropertyKeys().length, Is.is(2));
assertThat(Lists.newArrayList(i18n.getPropertyKeys()), hasItems("one", "two"));
}
@Test
- public void shouldEncodeJavascriptValues() {
+ public void encode_javascript_values() {
String js = i18n.getJsDictionnary(bundle);
assertThat(js, containsString("var l10n = {"));
assertThat(js, containsString("one\": \"One"));
diff --git a/sonar-core/src/test/java/org/sonar/core/i18n/I18nClassloaderTest.java b/sonar-core/src/test/java/org/sonar/core/i18n/I18nClassloaderTest.java
index 2a62a129fcf..00a6b3e0372 100644
--- a/sonar-core/src/test/java/org/sonar/core/i18n/I18nClassloaderTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/i18n/I18nClassloaderTest.java
@@ -19,14 +19,18 @@
*/
package org.sonar.core.i18n;
+import com.google.common.collect.Lists;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.sonar.api.platform.PluginRepository;
+import java.net.URL;
import java.net.URLClassLoader;
import static org.fest.assertions.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
public class I18nClassloaderTest {
private I18nClassloader i18nClassloader;
@@ -36,32 +40,49 @@ public class I18nClassloaderTest {
@Before
public void init() {
- URLClassLoader sqale = DefaultI18nTest.newSqaleClassloader();
- URLClassLoader checkstyle = DefaultI18nTest.newCheckstyleClassloader();
-
- i18nClassloader = new I18nClassloader(new ClassLoader[]{sqale, checkstyle});
+ i18nClassloader = new I18nClassloader(mock(PluginRepository.class));
}
@Test
- public void should_aggregate_plugin_classloaders() {
+ public void aggregate_plugin_classloaders() {
+ URLClassLoader checkstyle = newCheckstyleClassloader();
+
+ I18nClassloader i18nClassloader = new I18nClassloader(Lists.<ClassLoader>newArrayList(checkstyle));
assertThat(i18nClassloader.getResource("org/sonar/l10n/checkstyle.properties")).isNotNull();
assertThat(i18nClassloader.getResource("org/sonar/l10n/checkstyle.properties").getFile()).endsWith("checkstyle.properties");
- assertThat(i18nClassloader.getResource("org/sonar/l10n/checkstyle/ArchitectureRule.html").getFile()).endsWith("ArchitectureRule.html");
}
@Test
- public void should_return_null_if_resource_not_found() {
+ public void contain_its_own_classloader() {
+ assertThat(i18nClassloader.getResource("org/sonar/l10n/core.properties")).isNotNull();
+ assertThat(i18nClassloader.getResource("org/sonar/l10n/gwt.properties")).isNotNull();
+ }
+
+ @Test
+ public void return_null_if_resource_not_found() {
assertThat(i18nClassloader.getResource("org/unknown.properties")).isNull();
}
@Test
- public void should_not_support_lookup_of_java_classes() throws ClassNotFoundException {
+ public void not_support_lookup_of_java_classes() throws ClassNotFoundException {
thrown.expect(UnsupportedOperationException.class);
i18nClassloader.loadClass("java.lang.String");
}
@Test
- public void should_override_toString() throws ClassNotFoundException {
+ public void override_toString() throws ClassNotFoundException {
assertThat(i18nClassloader.toString()).isEqualTo("i18n-classloader");
}
+
+ private static URLClassLoader newCheckstyleClassloader() {
+ return newClassLoader("/org/sonar/core/i18n/I18nClassloaderTest/");
+ }
+
+ private static URLClassLoader newClassLoader(String... resourcePaths) {
+ URL[] urls = new URL[resourcePaths.length];
+ for (int index = 0; index < resourcePaths.length; index++) {
+ urls[index] = DefaultI18nTest.class.getResource(resourcePaths[index]);
+ }
+ return new URLClassLoader(urls);
+ }
}
diff --git a/sonar-core/src/test/resources/org/sonar/core/i18n/I18nClassloaderTest/org/sonar/l10n/checkstyle.properties b/sonar-core/src/test/resources/org/sonar/core/i18n/I18nClassloaderTest/org/sonar/l10n/checkstyle.properties
new file mode 100644
index 00000000000..81756045d79
--- /dev/null
+++ b/sonar-core/src/test/resources/org/sonar/core/i18n/I18nClassloaderTest/org/sonar/l10n/checkstyle.properties
@@ -0,0 +1 @@
+rule1.name=Rule one
diff --git a/sonar-core/src/test/resources/org/sonar/core/i18n/checkstylePlugin/org/sonar/l10n/checkstyle/ArchitectureRule.html b/sonar-core/src/test/resources/org/sonar/core/i18n/checkstylePlugin/org/sonar/l10n/checkstyle/ArchitectureRule.html
deleted file mode 100644
index a7cad9049d7..00000000000
--- a/sonar-core/src/test/resources/org/sonar/core/i18n/checkstylePlugin/org/sonar/l10n/checkstyle/ArchitectureRule.html
+++ /dev/null
@@ -1 +0,0 @@
-This is the architecture rule \ No newline at end of file
diff --git a/sonar-core/src/test/resources/org/sonar/core/i18n/corePlugin/org/sonar/l10n/core.properties b/sonar-core/src/test/resources/org/sonar/core/i18n/corePlugin/org/sonar/l10n/core.properties
deleted file mode 100644
index d185db89e91..00000000000
--- a/sonar-core/src/test/resources/org/sonar/core/i18n/corePlugin/org/sonar/l10n/core.properties
+++ /dev/null
@@ -1,9 +0,0 @@
-by=By
-empty=
-with.parameters=First is {0} and second is {1}
-only.in.english=Missing in French bundle
-duration.seconds=less than a minute
-duration.day=a day
-work_duration.x_days={0}d
-work_duration.x_hours={0}h
-work_duration.x_minutes={0}min
diff --git a/sonar-core/src/test/resources/org/sonar/core/i18n/frenchPack/org/sonar/l10n/checkstyle_fr/ArchitectureRule.html b/sonar-core/src/test/resources/org/sonar/core/i18n/frenchPack/org/sonar/l10n/checkstyle_fr/ArchitectureRule.html
deleted file mode 100644
index 9b12ae071ce..00000000000
--- a/sonar-core/src/test/resources/org/sonar/core/i18n/frenchPack/org/sonar/l10n/checkstyle_fr/ArchitectureRule.html
+++ /dev/null
@@ -1 +0,0 @@
-Règle d'architecture \ No newline at end of file
diff --git a/sonar-core/src/test/resources/org/sonar/core/i18n/frenchPack/org/sonar/l10n/core_fr.properties b/sonar-core/src/test/resources/org/sonar/core/i18n/frenchPack/org/sonar/l10n/core_fr.properties
deleted file mode 100644
index e9ced4039ae..00000000000
--- a/sonar-core/src/test/resources/org/sonar/core/i18n/frenchPack/org/sonar/l10n/core_fr.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-by=Par
-empty= \ No newline at end of file
diff --git a/sonar-core/src/test/resources/org/sonar/core/i18n/checkstylePlugin/org/sonar/l10n/checkstyle.properties b/sonar-core/src/test/resources/org/sonar/l10n/checkstyle.properties
index 10fa9295c44..10fa9295c44 100644
--- a/sonar-core/src/test/resources/org/sonar/core/i18n/checkstylePlugin/org/sonar/l10n/checkstyle.properties
+++ b/sonar-core/src/test/resources/org/sonar/l10n/checkstyle.properties
diff --git a/sonar-core/src/test/resources/org/sonar/core/i18n/frenchPack/org/sonar/l10n/checkstyle_fr.properties b/sonar-core/src/test/resources/org/sonar/l10n/checkstyle_fr.properties
index b2fc8f9651f..b2fc8f9651f 100644
--- a/sonar-core/src/test/resources/org/sonar/core/i18n/frenchPack/org/sonar/l10n/checkstyle_fr.properties
+++ b/sonar-core/src/test/resources/org/sonar/l10n/checkstyle_fr.properties
diff --git a/sonar-core/src/test/resources/org/sonar/l10n/core_fr.properties b/sonar-core/src/test/resources/org/sonar/l10n/core_fr.properties
new file mode 100644
index 00000000000..9b473d07f5c
--- /dev/null
+++ b/sonar-core/src/test/resources/org/sonar/l10n/core_fr.properties
@@ -0,0 +1,2 @@
+any=Tous
+empty=
diff --git a/sonar-core/src/test/resources/org/sonar/core/i18n/sqalePlugin/org/sonar/l10n/sqale.properties b/sonar-core/src/test/resources/org/sonar/l10n/sqale.properties
index a8ea9c0553e..a8ea9c0553e 100644
--- a/sonar-core/src/test/resources/org/sonar/core/i18n/sqalePlugin/org/sonar/l10n/sqale.properties
+++ b/sonar-core/src/test/resources/org/sonar/l10n/sqale.properties
diff --git a/sonar-core/src/test/resources/org/sonar/core/i18n/sqalePlugin/org/sonar/l10n/sqale_fr.properties b/sonar-core/src/test/resources/org/sonar/l10n/sqale_fr.properties
index 471d015a11a..471d015a11a 100644
--- a/sonar-core/src/test/resources/org/sonar/core/i18n/sqalePlugin/org/sonar/l10n/sqale_fr.properties
+++ b/sonar-core/src/test/resources/org/sonar/l10n/sqale_fr.properties
diff --git a/sonar-server/pom.xml b/sonar-server/pom.xml
index f1e00cd756c..5dd76005a69 100644
--- a/sonar-server/pom.xml
+++ b/sonar-server/pom.xml
@@ -498,13 +498,6 @@
</dependency>
<dependency>
<groupId>org.codehaus.sonar.plugins</groupId>
- <artifactId>sonar-l10n-en-plugin</artifactId>
- <version>${project.version}</version>
- <type>sonar-plugin</type>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.codehaus.sonar.plugins</groupId>
<artifactId>sonar-email-notifications-plugin</artifactId>
<version>${project.version}</version>
<type>sonar-plugin</type>