public void testGetLanguageRootWithCountry() { String noMatch = "/content/path/some/deep/verydeep/1/z/_/xy_zy"; assertNull("No language in path", LanguageUtil.getLanguageRoot(noMatch)); String root = "/content/path/some/deep/verydeep/1/z/_"; String hit = root + "/de_ch"; assertEquals("Root missed with language at end", hit, LanguageUtil.getLanguageRoot(hit)); assertEquals( "Root missed with language at parent", hit, LanguageUtil.getLanguageRoot(hit + "/deeper/level")); assertEquals( "Root searched bottom up instead top down", hit, LanguageUtil.getLanguageRoot(hit + "/inter/en_gb/content")); }
public void testGetLanguageRootCountryTree() { String noMatch = "/content/path/some/zy/verydeep/1/z/_/xy"; assertNull("No language in path", LanguageUtil.getLanguageRoot(noMatch)); String root = "/content/path/some/ch/verydeep/1/z/_"; String hit = root + "/de"; assertEquals("Root missed at end", hit, LanguageUtil.getLanguageRoot(hit)); assertEquals( "Root missed with language at ancestor", hit, LanguageUtil.getLanguageRoot(hit + "/deeper/level")); assertEquals( "Root searched bottom up instead top down", hit, LanguageUtil.getLanguageRoot(hit + "/inter/fr/content/en")); assertEquals( "Root detected wrong hit", root + "/inter/xy/content/en", LanguageUtil.getLanguageRoot(root + "/inter/xy/content/en")); }
public void testGetLanguageRootSearchOrder() { String root = "/content/path/some/ch/verydeep/en_GB"; String hit = root + "/de/_"; assertEquals("Precedence of en_GB not respected", root, LanguageUtil.getLanguageRoot(hit)); }
private void assertLanguage(String code, String language, String country) { Language lang = LanguageUtil.getLanguage(code); assertEquals(code.replaceAll("-", "_"), lang.toString()); assertEquals(language, lang.getLanguageCode()); assertEquals(country, lang.getCountryCode()); }