test if bundle for supported locales exist and are not empty

This commit is contained in:
Sebastian Stenzel
2022-04-04 15:57:01 +02:00
parent d10c8fcf17
commit 508b9f5c64

View File

@@ -0,0 +1,31 @@
package org.cryptomator.launcher;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.stream.Stream;
public class SupportedLanguagesTest {
@DisplayName("test if resource bundle is localized")
@ParameterizedTest(name = "{0}")
@MethodSource("languageTags")
public void testResourceBundleExists(String tag) {
var locale = Locale.forLanguageTag(tag);
Assertions.assertNotEquals("und", locale.toLanguageTag(), "Undefined language tag");
var bundle = Assertions.assertDoesNotThrow(() -> ResourceBundle.getBundle("/i18n/strings", locale));
Assertions.assertEquals(locale, bundle.getLocale());
Assertions.assertFalse(bundle.keySet().isEmpty());
}
public static Stream<String> languageTags() {
return SupportedLanguages.LANGUAGAE_TAGS.stream() //
.filter(tag -> !"en".equals(tag)); // english uses the default bundle
}
}