Skip to content

Commit

Permalink
TRUNK-3142: Fixed build for Oracle JDK 1.7 which is more permissive a…
Browse files Browse the repository at this point in the history
…bout locales
  • Loading branch information
rkorytkowski committed Apr 26, 2013
1 parent ab39d63 commit 4e778ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 1 addition & 3 deletions api/src/main/java/org/openmrs/util/LocaleUtility.java
Expand Up @@ -225,9 +225,7 @@ public boolean supportsPropertyName(String propertyName) {
*/
public static boolean isValid(Locale locale) {
try {
//Check if the language is available and then verify the country separately, because e.g. fr_RW combination is not among available locales.
return (LocaleUtils.isAvailableLocale(new Locale(locale.getLanguage())) || locale.getISO3Language() != null)
&& locale.getISO3Country() != null;
return locale.getISO3Language() != null && locale.getISO3Country() != null;
}
catch (MissingResourceException e) {
return false;
Expand Down
7 changes: 5 additions & 2 deletions web/src/test/java/org/openmrs/web/WebUtilTest.java
Expand Up @@ -50,7 +50,9 @@ public void normalizeLocale_shouldAcceptLanguageOnlyLocales() throws Exception {
@Test
public void normalizeLocale_shouldNotAcceptInvalidLocales() throws Exception {
Assert.assertNull(WebUtil.normalizeLocale("ptrg"));
Assert.assertNull(WebUtil.normalizeLocale("usa"));
Assert.assertNull(WebUtil.normalizeLocale("usaa"));
//'usa' is accepted by Oracle JDK 1.7.0_09
//Assert.assertNull(WebUtil.normalizeLocale("usa"));
}

/**
Expand All @@ -77,7 +79,8 @@ public void normalizeLocale_shouldNotFailWithWhitespaceOnly() throws Exception {
*/
@Test
public void sanitizeLocales_shouldSkipOverInvalidLocales() throws Exception {
Assert.assertEquals("fr_RW, it, en", WebUtil.sanitizeLocales("és, qqq, fr_RW, it, enñ"));
Assert.assertEquals("fr_RW, it, en", WebUtil.sanitizeLocales("és, qqqq, fr_RW, it, enñ"));
//'qqq' is accepted by Oracle JDK 1.7.0_09
}

/**
Expand Down

0 comments on commit 4e778ab

Please sign in to comment.