Merge pull request #16971 from nosan

* pr/16971:
  Polish "Fix Spring Data Cassandra auto-configure condition"
  Fix Spring Data Cassandra auto-configure condition
pull/17068/head
Phillip Webb 6 years ago
commit 8fe18303cc

@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2019 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.
@ -28,6 +28,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
import org.springframework.boot.autoconfigure.cassandra.CassandraProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.domain.EntityScanPackages;
@ -59,6 +60,7 @@ import org.springframework.data.cassandra.core.mapping.SimpleUserTypeResolver;
*/
@Configuration
@ConditionalOnClass({ Cluster.class, CassandraAdminOperations.class })
@ConditionalOnBean(Cluster.class)
@EnableConfigurationProperties(CassandraProperties.class)
@AutoConfigureAfter(CassandraAutoConfiguration.class)
public class CassandraDataAutoConfiguration {

@ -105,6 +105,13 @@ public class CassandraDataAutoConfigurationTests {
}
@Test
public void clusterDoesNotExist() {
this.context = new AnnotationConfigApplicationContext(
CassandraDataAutoConfiguration.class);
assertThat(this.context.getBeansOfType(Session.class)).isEmpty();
}
public void load(Class<?>... config) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
TestPropertyValues.of("spring.data.cassandra.keyspaceName:boot_test")

Loading…
Cancel
Save