Merge branch '1.5.x'

pull/9648/merge
Stephane Nicoll 7 years ago
commit afc3fc50dc

@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,6 +20,7 @@ import org.elasticsearch.client.Client;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
@ -49,6 +50,7 @@ public class ElasticsearchDataAutoConfiguration {
@Bean
@ConditionalOnMissingBean
@ConditionalOnBean(Client.class)
public ElasticsearchTemplate elasticsearchTemplate(Client client,
ElasticsearchConverter converter) {
try {

@ -45,6 +45,13 @@ public class ElasticsearchDataAutoConfigurationTests {
}
}
@Test
public void templateBackOffWithNoClient() {
this.context = new AnnotationConfigApplicationContext(
ElasticsearchDataAutoConfiguration.class);
assertThat(this.context.getBeansOfType(ElasticsearchTemplate.class)).isEmpty();
}
@Test
public void templateExists() {
this.context = new AnnotationConfigApplicationContext();

Loading…
Cancel
Save