diff options
author | Florian Zschocke <f.zschocke+git@gmail.com> | 2021-10-20 21:05:02 +0200 |
---|---|---|
committer | Florian Zschocke <f.zschocke+git@gmail.com> | 2021-10-20 21:05:02 +0200 |
commit | 111eaef65eadb761d9593c88a63bc5949789d77d (patch) | |
tree | 447fb7185fd5b4de5ec91c3f337d6643bfd30415 /src/test/java | |
parent | ab58795dbf84257aa968989a4c965cc826dc278f (diff) | |
download | gitblit-111eaef65eadb761d9593c88a63bc5949789d77d.tar.gz gitblit-111eaef65eadb761d9593c88a63bc5949789d77d.zip |
Add a unit test to check if the resource bundle can be loaded
To prevent that we have a resource file in a resource bundle broken and
not loading undiscovered for years, add a unit test that will load the
resource properties file for each of the languages.
In order to check if the file was loaded and the bundle mechanism
didn't fall back on the default, a new property key is added to each
language file, solely for the purpose to be checked in the unit test.
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/com/gitblit/wicket/GitBlitWebAppResourceBundleTest.java | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/src/test/java/com/gitblit/wicket/GitBlitWebAppResourceBundleTest.java b/src/test/java/com/gitblit/wicket/GitBlitWebAppResourceBundleTest.java new file mode 100644 index 00000000..05549d16 --- /dev/null +++ b/src/test/java/com/gitblit/wicket/GitBlitWebAppResourceBundleTest.java @@ -0,0 +1,146 @@ +package com.gitblit.wicket; + +import org.junit.Test; + +import java.util.Locale; +import java.util.ResourceBundle; + +import static org.junit.Assert.*; + +public class GitBlitWebAppResourceBundleTest +{ + @Test + public void testDefaultResource() + { + ResourceBundle bundle = ResourceBundle.getBundle("com.gitblit.wicket.GitBlitWebApp"); + assertNotNull(bundle); + assertEquals("default", bundle.getString("gb.loadLang")); + } + + @Test + public void testCsResource() + { + Locale l = Locale.forLanguageTag("cs"); + ResourceBundle bundle = ResourceBundle.getBundle("com.gitblit.wicket.GitBlitWebApp", l); + assertNotNull(bundle); + assertEquals("čeština", bundle.getString("gb.loadLang")); + } + + @Test + public void testDeResource() + { + Locale l = Locale.GERMAN; + ResourceBundle bundle = ResourceBundle.getBundle("com.gitblit.wicket.GitBlitWebApp", l); + assertNotNull(bundle); + assertEquals("Deutsch", bundle.getString("gb.loadLang")); + } + + @Test + public void testEnResource() + { + Locale l = Locale.ENGLISH; + ResourceBundle bundle = ResourceBundle.getBundle("com.gitblit.wicket.GitBlitWebApp", l); + assertNotNull(bundle); + // The "en" file is just a placeholder for the default one. + assertEquals("default", bundle.getString("gb.loadLang")); + } + + @Test + public void testEsResource() + { + Locale l = Locale.forLanguageTag("es"); + ResourceBundle bundle = ResourceBundle.getBundle("com.gitblit.wicket.GitBlitWebApp", l); + assertNotNull(bundle); + assertEquals("Español", bundle.getString("gb.loadLang")); + } + + @Test + public void testFrResource() throws Exception + { + Locale l = Locale.FRENCH; + ResourceBundle bundle = ResourceBundle.getBundle("com.gitblit.wicket.GitBlitWebApp", l); + assertNotNull(bundle); + assertEquals("français", bundle.getString("gb.loadLang")); + } + + @Test + public void testItResource() throws Exception + { + Locale l = Locale.ITALIAN; + ResourceBundle bundle = ResourceBundle.getBundle("com.gitblit.wicket.GitBlitWebApp", l); + assertNotNull(bundle); + assertEquals("Italiano", bundle.getString("gb.loadLang")); + } + + @Test + public void testJaResource() throws Exception + { + Locale l = Locale.JAPANESE; + ResourceBundle bundle = ResourceBundle.getBundle("com.gitblit.wicket.GitBlitWebApp", l); + assertNotNull(bundle); + assertEquals("にほんご", bundle.getString("gb.loadLang")); + } + + @Test + public void testKoResource() throws Exception + { + Locale l = Locale.KOREAN; + ResourceBundle bundle = ResourceBundle.getBundle("com.gitblit.wicket.GitBlitWebApp", l); + assertNotNull(bundle); + assertEquals("한국어", bundle.getString("gb.loadLang")); + } + + @Test + public void testNlResource() throws Exception + { + Locale l = Locale.forLanguageTag("nl"); + ResourceBundle bundle = ResourceBundle.getBundle("com.gitblit.wicket.GitBlitWebApp", l); + assertNotNull(bundle); + assertEquals("Nederlands", bundle.getString("gb.loadLang")); + } + + @Test + public void testNoResource() throws Exception + { + Locale l = Locale.forLanguageTag("no"); + ResourceBundle bundle = ResourceBundle.getBundle("com.gitblit.wicket.GitBlitWebApp", l); + assertNotNull(bundle); + assertEquals("Norsk", bundle.getString("gb.loadLang")); + } + + @Test + public void testPlResource() throws Exception + { + Locale l = Locale.forLanguageTag("pl"); + ResourceBundle bundle = ResourceBundle.getBundle("com.gitblit.wicket.GitBlitWebApp", l); + assertNotNull(bundle); + assertEquals("polszczyzna", bundle.getString("gb.loadLang")); + } + + @Test + public void testPtBrResource() throws Exception + { + Locale l = Locale.forLanguageTag("pt-BR"); + ResourceBundle bundle = ResourceBundle.getBundle("com.gitblit.wicket.GitBlitWebApp", l); + assertNotNull(bundle); + assertEquals("Português", bundle.getString("gb.loadLang")); + } + + @Test + public void testZhCnResource() throws Exception + { + Locale l = Locale.SIMPLIFIED_CHINESE; + ResourceBundle bundle = ResourceBundle.getBundle("com.gitblit.wicket.GitBlitWebApp", l); + assertNotNull(bundle); + assertEquals("汉字", bundle.getString("gb.loadLang")); + } + + @Test + public void testZhTwResource() throws Exception + { + Locale l = Locale.TRADITIONAL_CHINESE; + ResourceBundle bundle = ResourceBundle.getBundle("com.gitblit.wicket.GitBlitWebApp", l); + assertNotNull(bundle); + assertEquals("漢字", bundle.getString("gb.loadLang")); + } +}
\ No newline at end of file |