[TEST] add test to ensure legacy list syntax in yml works fine

This commit is contained in:
Simon Willnauer 2017-10-05 14:40:15 +02:00
parent 41925e1171
commit 8583727590
1 changed files with 11 additions and 0 deletions

View File

@ -35,6 +35,8 @@ import org.hamcrest.CoreMatchers;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.StringBufferInputStream;
import java.io.StringReader;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
@ -618,6 +620,15 @@ public class SettingsTests extends ESTestCase {
assertThat(settings.getAsArray("test1.test3")[1], equalTo("test3-2")); assertThat(settings.getAsArray("test1.test3")[1], equalTo("test3-2"));
} }
public void testYamlLegacyList() throws IOException {
Settings settings = Settings.builder()
.loadFromStream("foo.yml", new ByteArrayInputStream("foo.bar.baz.0: 1\nfoo.bar.baz.1: 2".getBytes(StandardCharsets.UTF_8)),
false).build();
assertThat(settings.getAsArray("foo.bar.baz").length, equalTo(2));
assertThat(settings.getAsArray("foo.bar.baz")[0], equalTo("1"));
assertThat(settings.getAsArray("foo.bar.baz")[1], equalTo("2"));
}
public void testIndentation() throws Exception { public void testIndentation() throws Exception {
String yaml = "/org/elasticsearch/common/settings/loader/indentation-settings.yml"; String yaml = "/org/elasticsearch/common/settings/loader/indentation-settings.yml";
ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> { ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> {