diff --git a/src/test/java/org/elasticsearch/common/unit/ByteSizeValueTests.java b/src/test/java/org/elasticsearch/common/unit/ByteSizeValueTests.java index f1bafe2151a..2c8187c896c 100644 --- a/src/test/java/org/elasticsearch/common/unit/ByteSizeValueTests.java +++ b/src/test/java/org/elasticsearch/common/unit/ByteSizeValueTests.java @@ -104,4 +104,19 @@ public class ByteSizeValueTests extends ElasticsearchTestCase { public void testFailOnEmptyNumberParsing() { assertThat(ByteSizeValue.parseBytesSizeValue("g", "emptyNumberParsing").toString(), is("23b")); } + + public void testSpaceAllowed() { + ByteSizeValue result = ByteSizeValue.parseBytesSizeValue("42 gb", "test"); + assertEquals(42L*1024*1024*1024, result.bytes()); + } + + @Test(expected = ElasticsearchParseException.class) + public void testNoDotsAllowed() { + ByteSizeValue.parseBytesSizeValue("42b.", null, "test"); + } + + public void testCapsAllowed() { + ByteSizeValue result = ByteSizeValue.parseBytesSizeValue("42B", null, "test"); + assertEquals(42, result.bytes()); + } } diff --git a/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java b/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java index 702e0fbf688..cdae9cb61bb 100644 --- a/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java +++ b/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java @@ -97,4 +97,19 @@ public class TimeValueTests extends ElasticsearchTestCase { public void testFailOnMissingUnits() { TimeValue.parseTimeValue("42", null, "test"); } + + public void testSpaceAllowed() { + TimeValue result = TimeValue.parseTimeValue("42 ms", null, "test"); + assertEquals(42, result.millis()); + } + + @Test(expected = ElasticsearchParseException.class) + public void testNoDotsAllowed() { + TimeValue.parseTimeValue("42ms.", null, "test"); + } + + @Test(expected = ElasticsearchParseException.class) + public void testNoCapsAllowed() { + TimeValue.parseTimeValue("42MS", null, "test"); + } }