|
16 | 16 |
|
17 | 17 | package org.springframework.boot.autoconfigure.data.cassandra;
|
18 | 18 |
|
19 |
| -import java.util.Arrays; |
| 19 | +import java.util.Collections; |
20 | 20 | import java.util.Set;
|
21 | 21 |
|
22 | 22 | import com.datastax.driver.core.Session;
|
|
27 | 27 | import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
28 | 28 | import org.springframework.boot.autoconfigure.data.cassandra.city.City;
|
29 | 29 | import org.springframework.boot.autoconfigure.domain.EntityScan;
|
30 |
| -import org.springframework.boot.test.util.EnvironmentTestUtils; |
31 | 30 | import org.springframework.boot.test.util.TestPropertyValues;
|
32 | 31 | import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
33 | 32 | import org.springframework.context.annotation.Bean;
|
@@ -105,11 +104,25 @@ public void userTypeResolverShouldBeSet() throws Exception {
|
105 | 104 | .isInstanceOf(SimpleUserTypeResolver.class);
|
106 | 105 | }
|
107 | 106 |
|
| 107 | + @Test |
| 108 | + public void defaultConversions() { |
| 109 | + this.context = new AnnotationConfigApplicationContext(); |
| 110 | + TestPropertyValues.of("spring.data.cassandra.keyspaceName:boot_test") |
| 111 | + .applyTo(this.context); |
| 112 | + this.context.register(TestConfiguration.class, |
| 113 | + PropertyPlaceholderAutoConfiguration.class, |
| 114 | + CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class); |
| 115 | + this.context.refresh(); |
| 116 | + CassandraTemplate template = this.context.getBean(CassandraTemplate.class); |
| 117 | + assertThat(template.getConverter().getConversionService().canConvert(Person.class, |
| 118 | + String.class)).isFalse(); |
| 119 | + } |
| 120 | + |
108 | 121 | @Test
|
109 | 122 | public void customConversions() {
|
110 | 123 | this.context = new AnnotationConfigApplicationContext();
|
111 |
| - EnvironmentTestUtils.addEnvironment(this.context, |
112 |
| - "spring.data.cassandra.keyspaceName:boot_test"); |
| 124 | + TestPropertyValues.of("spring.data.cassandra.keyspaceName:boot_test") |
| 125 | + .applyTo(this.context); |
113 | 126 | this.context.register(CustomConversionConfig.class,
|
114 | 127 | TestConfiguration.class,
|
115 | 128 | PropertyPlaceholderAutoConfiguration.class,
|
@@ -148,8 +161,9 @@ static class EntityScanConfig {
|
148 | 161 | static class CustomConversionConfig {
|
149 | 162 |
|
150 | 163 | @Bean
|
151 |
| - public CassandraCustomConversions cassandraCustomConversions() { |
152 |
| - return new CassandraCustomConversions(Arrays.asList(new MyConverter())); |
| 164 | + public CassandraCustomConversions myCassandraCustomConversions() { |
| 165 | + return new CassandraCustomConversions(Collections.singletonList( |
| 166 | + new MyConverter())); |
153 | 167 | }
|
154 | 168 |
|
155 | 169 | }
|
|
0 commit comments