Polish contribution
Closes gh-5511
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.autoconfigure.data.elasticsearch;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
@@ -63,7 +62,7 @@ public class ElasticsearchAutoConfiguration implements DisposableBean {
|
||||
Map<String, String> defaults = new LinkedHashMap<String, String>();
|
||||
defaults.put("http.enabled", String.valueOf(false));
|
||||
defaults.put("node.local", String.valueOf(true));
|
||||
defaults.put("path.home", new File(System.getProperty("java.io.tmpdir"), "elastic-home").getAbsolutePath());
|
||||
defaults.put("path.home", System.getProperty("user.dir"));
|
||||
DEFAULTS = Collections.unmodifiableMap(defaults);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,8 @@ public class ElasticsearchAutoConfigurationTests {
|
||||
public void createNodeClientWithDefaults() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.data.elasticsearch.properties.foo.bar:baz");
|
||||
"spring.data.elasticsearch.properties.foo.bar:baz",
|
||||
"spring.data.elasticsearch.properties.path.home:target");
|
||||
this.context.register(PropertyPlaceholderAutoConfiguration.class,
|
||||
ElasticsearchAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -72,6 +73,7 @@ public class ElasticsearchAutoConfigurationTests {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.data.elasticsearch.properties.foo.bar:baz",
|
||||
"spring.data.elasticsearch.properties.path.home:target",
|
||||
"spring.data.elasticsearch.properties.node.local:false",
|
||||
"spring.data.elasticsearch.properties.node.data:true",
|
||||
"spring.data.elasticsearch.properties.http.enabled:true");
|
||||
@@ -104,7 +106,8 @@ public class ElasticsearchAutoConfigurationTests {
|
||||
// a port and check the exception
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.data.elasticsearch.cluster-nodes:localhost");
|
||||
"spring.data.elasticsearch.cluster-nodes:localhost",
|
||||
"spring.data.elasticsearch.properties.path.home:target");
|
||||
this.context.register(PropertyPlaceholderAutoConfiguration.class,
|
||||
ElasticsearchAutoConfiguration.class);
|
||||
this.thrown.expect(BeanCreationException.class);
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.boot.autoconfigure.data.alt.elasticsearch.CityElastic
|
||||
import org.springframework.boot.autoconfigure.data.elasticsearch.city.City;
|
||||
import org.springframework.boot.autoconfigure.data.elasticsearch.city.CityRepository;
|
||||
import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
|
||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
||||
@@ -49,6 +50,7 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
|
||||
@Test
|
||||
public void testDefaultRepositoryConfiguration() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
addElasticsearchProperties(this.context);
|
||||
this.context.register(TestConfiguration.class,
|
||||
ElasticsearchAutoConfiguration.class,
|
||||
ElasticsearchRepositoriesAutoConfiguration.class,
|
||||
@@ -62,6 +64,7 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
|
||||
@Test
|
||||
public void testNoRepositoryConfiguration() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
addElasticsearchProperties(this.context);
|
||||
this.context.register(EmptyConfiguration.class,
|
||||
ElasticsearchAutoConfiguration.class,
|
||||
ElasticsearchRepositoriesAutoConfiguration.class,
|
||||
@@ -74,6 +77,7 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
|
||||
@Test
|
||||
public void doesNotTriggerDefaultRepositoryDetectionIfCustomized() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
addElasticsearchProperties(this.context);
|
||||
this.context.register(CustomizedConfiguration.class,
|
||||
ElasticsearchAutoConfiguration.class,
|
||||
ElasticsearchRepositoriesAutoConfiguration.class,
|
||||
@@ -83,6 +87,11 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
|
||||
assertThat(this.context.getBean(CityElasticsearchDbRepository.class)).isNotNull();
|
||||
}
|
||||
|
||||
private void addElasticsearchProperties(AnnotationConfigApplicationContext context) {
|
||||
EnvironmentTestUtils.addEnvironment(context,
|
||||
"spring.data.elasticsearch.properties.path.home:target");
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@TestAutoConfigurationPackage(City.class)
|
||||
protected static class TestConfiguration {
|
||||
|
||||
Reference in New Issue
Block a user