mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-07-10 04:13:27 +00:00
DATAES-224 retain newlines when reading mapping/setting files
Fixed test-settings yaml
This commit is contained in:
parent
7dbab75cf5
commit
9c91723833
@ -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()));
|
||||
|
@ -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();
|
||||
}
|
||||
|
8
src/test/resources/settings/test-settings.yml
Normal file
8
src/test/resources/settings/test-settings.yml
Normal file
@ -0,0 +1,8 @@
|
||||
index:
|
||||
number_of_shards: 1
|
||||
number_of_replicas: 0
|
||||
analysis:
|
||||
analyzer:
|
||||
emailAnalyzer:
|
||||
type: custom
|
||||
tokenizer: uax_url_email
|
Loading…
x
Reference in New Issue
Block a user