@Test public void hasRecreateSchemaActionSet() { createTestKeyspaceIfNotExists(); this.context = new AnnotationConfigApplicationContext(); String cityPackage = City.class.getPackage().getName(); AutoConfigurationPackages.register(this.context, cityPackage); EnvironmentTestUtils.addEnvironment(this.context, "spring.data.cassandra.schemaAction:RECREATE_DROP_UNUSED", "spring.data.cassandra.keyspaceName:boot_test"); this.context.register(CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class); this.context.refresh(); CassandraSessionFactoryBean bean = this.context .getBean(CassandraSessionFactoryBean.class); assertThat(bean.getSchemaAction()).isEqualTo(SchemaAction.RECREATE_DROP_UNUSED); }
@Test @SuppressWarnings("unchecked") public void entityScanShouldSetInitialEntitySet() throws Exception { this.context = new AnnotationConfigApplicationContext(); this.context.register(TestConfiguration.class, EntityScanConfig.class, PropertyPlaceholderAutoConfiguration.class, CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class); this.context.refresh(); CassandraMappingContext mappingContext = this.context .getBean(CassandraMappingContext.class); Set<Class<?>> initialEntitySet = (Set<Class<?>>) ReflectionTestUtils .getField(mappingContext, "initialEntitySet"); assertThat(initialEntitySet).containsOnly(City.class); }
@Test public void hasDefaultSchemaActionSet() { this.context = new AnnotationConfigApplicationContext(); String cityPackage = City.class.getPackage().getName(); AutoConfigurationPackages.register(this.context, cityPackage); this.context.register(CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class); this.context.refresh(); CassandraSessionFactoryBean bean = this.context .getBean(CassandraSessionFactoryBean.class); assertThat(bean.getSchemaAction()).isEqualTo(SchemaAction.NONE); }
@Test public void testNoRepositoryConfiguration() { addConfigurations(TestExcludeConfiguration.class, EmptyConfiguration.class); assertThat(this.context.getBean(Cluster.class)).isNotNull(); assertThat(getInitialEntitySet()).hasSize(1).containsOnly(City.class); }
@Test public void doesNotTriggerDefaultRepositoryDetectionIfCustomized() { addConfigurations(TestExcludeConfiguration.class, CustomizedConfiguration.class); assertThat(this.context.getBean(CityCassandraRepository.class)).isNotNull(); assertThat(getInitialEntitySet()).hasSize(1).containsOnly(City.class); }