Merge branch '1.2.x'
In addition to the changes already made in 1.2.x, this commit updates the tests in spring-boot-actuator to ensure that any Elasticsearch data files are written into the target directory. This avoids problems when switching branches caused by different versions of Elasticsearch trying to read the files.
This commit is contained in:
@@ -27,6 +27,7 @@ import org.springframework.boot.autoconfigure.data.elasticsearch.city.CityReposi
|
||||
import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
|
||||
import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchDataAutoConfiguration;
|
||||
import org.springframework.boot.test.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
||||
@@ -50,6 +51,9 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
|
||||
@Test
|
||||
public void testDefaultRepositoryConfiguration() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.data.elasticsearch.properties.path.data:target/data",
|
||||
"spring.data.elasticsearch.properties.path.logs:target/logs");
|
||||
this.context.register(TestConfiguration.class,
|
||||
ElasticsearchAutoConfiguration.class,
|
||||
ElasticsearchRepositoriesAutoConfiguration.class,
|
||||
@@ -63,6 +67,9 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
|
||||
@Test
|
||||
public void testNoRepositoryConfiguration() throws Exception {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.data.elasticsearch.properties.path.data:target/data",
|
||||
"spring.data.elasticsearch.properties.path.logs:target/logs");
|
||||
this.context.register(EmptyConfiguration.class,
|
||||
ElasticsearchAutoConfiguration.class,
|
||||
ElasticsearchRepositoriesAutoConfiguration.class,
|
||||
@@ -75,6 +82,9 @@ public class ElasticsearchRepositoriesAutoConfigurationTests {
|
||||
@Test
|
||||
public void doesNotTriggerDefaultRepositoryDetectionIfCustomized() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.data.elasticsearch.properties.path.data:target/data",
|
||||
"spring.data.elasticsearch.properties.path.logs:target/logs");
|
||||
this.context.register(CustomizedConfiguration.class,
|
||||
ElasticsearchAutoConfiguration.class,
|
||||
ElasticsearchRepositoriesAutoConfiguration.class,
|
||||
|
||||
@@ -56,7 +56,9 @@ public class ElasticsearchAutoConfigurationTests {
|
||||
public void createNodeClient() {
|
||||
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.data:target/data",
|
||||
"spring.data.elasticsearch.properties.path.logs:target/logs");
|
||||
this.context.register(PropertyPlaceholderAutoConfiguration.class,
|
||||
ElasticsearchAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
@@ -72,7 +74,9 @@ 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.data:target/data",
|
||||
"spring.data.elasticsearch.properties.path.logs:target/logs");
|
||||
this.context.register(PropertyPlaceholderAutoConfiguration.class,
|
||||
ElasticsearchAutoConfiguration.class);
|
||||
this.thrown.expect(BeanCreationException.class);
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.elasticsearch;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.test.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
|
||||
|
||||
@@ -42,10 +43,14 @@ public class ElasticsearchDataAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void templateExists() {
|
||||
this.context = new AnnotationConfigApplicationContext(
|
||||
PropertyPlaceholderAutoConfiguration.class,
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"spring.data.elasticsearch.properties.path.data:target/data",
|
||||
"spring.data.elasticsearch.properties.path.logs:target/logs");
|
||||
this.context.register(PropertyPlaceholderAutoConfiguration.class,
|
||||
ElasticsearchAutoConfiguration.class,
|
||||
ElasticsearchDataAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertEquals(1,
|
||||
this.context.getBeanNamesForType(ElasticsearchTemplate.class).length);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user