LANG-941: Test failure in LocaleUtilsTest when building with JDK 8 - make problem more explicit by checking for empty strings
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1555040 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d230e3a426
commit
c99a4a3ee2
|
@ -90,6 +90,9 @@ public class LocaleUtils {
|
|||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
if (str.isEmpty()) {
|
||||
throw new IllegalArgumentException("Cannot create locale from empty string");
|
||||
}
|
||||
if (str.contains("#")) { // LANG-879 - Cannot handle Java 7 script & extensions
|
||||
throw new IllegalArgumentException("Invalid locale format: " + str);
|
||||
}
|
||||
|
|
|
@ -137,6 +137,10 @@ public class LocaleUtilsTest {
|
|||
// Valid format but lang doesnt exist, should make instance anyway
|
||||
assertValidToLocale("qq");
|
||||
|
||||
try {
|
||||
LocaleUtils.toLocale("");
|
||||
fail("Should fail if str is empty");
|
||||
} catch (final IllegalArgumentException iae) {}
|
||||
try {
|
||||
LocaleUtils.toLocale("Us");
|
||||
fail("Should fail if not lowercase");
|
||||
|
|
Loading…
Reference in New Issue