DATAES-224 retain newlines when reading mapping/setting files

Fixed test-settings yaml
This commit is contained in:
pkraeutli 2015-12-18 14:09:32 +01:00 committed by Mohsin Husen
parent 7dbab75cf5
commit 9c91723833
3 changed files with 29 additions and 1 deletions

View File

@ -1164,8 +1164,9 @@ public class ElasticsearchTemplate implements ElasticsearchOperations, Applicati
bufferedReader = new BufferedReader(inputStreamReader);
String line;
String lineSeparator = System.getProperty("line.separator");
while ((line = bufferedReader.readLine()) != null) {
stringBuilder.append(line);
stringBuilder.append(line).append(lineSeparator);
}
} catch (Exception e) {
logger.debug(String.format("Failed to load file from url: %s: %s", url, e.getMessage()));

View File

@ -2006,6 +2006,25 @@ public class ElasticsearchTemplateTests {
assertThat(setting.get("index.number_of_replicas"), Matchers.<Object>is("1"));
}
@Test
public void shouldReadFileFromClasspathRetainingNewlines() {
// given
String settingsFile = "/settings/test-settings.yml";
// when
String content = ElasticsearchTemplate.readFileFromClasspath(settingsFile);
// then
assertThat(content, is("index:\n" +
" number_of_shards: 1\n" +
" number_of_replicas: 0\n" +
" analysis:\n" +
" analyzer:\n" +
" emailAnalyzer:\n" +
" type: custom\n" +
" tokenizer: uax_url_email\n"));
}
private IndexQuery getIndexQuery(SampleEntity sampleEntity) {
return new IndexQueryBuilder().withId(sampleEntity.getId()).withObject(sampleEntity).build();
}

View File

@ -0,0 +1,8 @@
index:
number_of_shards: 1
number_of_replicas: 0
analysis:
analyzer:
emailAnalyzer:
type: custom
tokenizer: uax_url_email