Commit 8fe18303 authored by Phillip Webb's avatar Phillip Webb

Merge pull request #16971 from nosan

* pr/16971:
  Polish "Fix Spring Data Cassandra auto-configure condition"
  Fix Spring Data Cassandra auto-configure condition
parents ef09ee5d 278a0866
/*
* 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")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment