ACCUMULO-3886 Allow True and False as valid boolean values
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/d764d272 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/d764d272 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/d764d272 Branch: refs/heads/1.7 Commit: d764d2724379f0304b501af84615d89e3ff77008 Parents: c475af0 Author: Josh Elser <[email protected]> Authored: Wed Jun 3 17:24:16 2015 -0400 Committer: Josh Elser <[email protected]> Committed: Wed Jun 3 21:00:06 2015 -0400 ---------------------------------------------------------------------- .../org/apache/accumulo/core/conf/PropertyType.java | 2 +- .../apache/accumulo/core/conf/PropertyTypeTest.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/d764d272/core/src/main/java/org/apache/accumulo/core/conf/PropertyType.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/conf/PropertyType.java b/core/src/main/java/org/apache/accumulo/core/conf/PropertyType.java index a100513..3814b6f 100644 --- a/core/src/main/java/org/apache/accumulo/core/conf/PropertyType.java +++ b/core/src/main/java/org/apache/accumulo/core/conf/PropertyType.java @@ -74,7 +74,7 @@ public enum PropertyType { STRING("string", ".*", "An arbitrary string of characters whose format is unspecified and interpreted based on the context of the property to which it applies."), BOOLEAN( - "boolean", "(?:true|false)", "Has a value of either 'true' or 'false'"), URI("uri", ".*", "A valid URI"); + "boolean", "(?:True|true|False|false)", "Has a value of either 'true' or 'false'"), URI("uri", ".*", "A valid URI"); private String shortname, format; private Pattern regex; http://git-wip-us.apache.org/repos/asf/accumulo/blob/d764d272/core/src/test/java/org/apache/accumulo/core/conf/PropertyTypeTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/accumulo/core/conf/PropertyTypeTest.java b/core/src/test/java/org/apache/accumulo/core/conf/PropertyTypeTest.java index b70806d..73174c2 100644 --- a/core/src/test/java/org/apache/accumulo/core/conf/PropertyTypeTest.java +++ b/core/src/test/java/org/apache/accumulo/core/conf/PropertyTypeTest.java @@ -20,6 +20,9 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import java.util.Arrays; +import java.util.List; + import org.junit.Test; public class PropertyTypeTest { @@ -70,4 +73,16 @@ public class PropertyTypeTest { // assertTrue(PropertyType.PREFIX.isValidFormat("whatever")); currently forbidden assertTrue(PropertyType.PREFIX.isValidFormat(null)); } + + @Test + public void testBooleans() { + List<String> goodValues = Arrays.asList("True", "true", "False", "false"); + for (String value : goodValues) { + assertTrue(value + " should be a valid boolean format", PropertyType.BOOLEAN.isValidFormat(value)); + } + List<String> badValues = Arrays.asList("foobar", "tRUE", "fAlSe"); + for (String value : badValues) { + assertFalse(value + " should not be a valid boolean format", PropertyType.BOOLEAN.isValidFormat(value)); + } + } }
