@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 public void templateExists() { this.context = new AnnotationConfigApplicationContext(); this.context.register(TestExcludeConfiguration.class, TestConfiguration.class, PropertyPlaceholderAutoConfiguration.class, CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class); this.context.refresh(); assertThat(this.context.getBeanNamesForType(CassandraTemplate.class).length) .isEqualTo(1); }
@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); }
private void addConfigurations(Class<?>... configurations) { this.context.register(configurations); this.context.register(CassandraAutoConfiguration.class, CassandraRepositoriesAutoConfiguration.class, CassandraDataAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); this.context.refresh(); }
@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 templateExists() { this.context = new AnnotationConfigApplicationContext(); this.context.register(TestExcludeConfiguration.class, TestConfiguration.class, PropertyPlaceholderAutoConfiguration.class, CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class); this.context.refresh(); assertEquals(1, this.context.getBeanNamesForType(CassandraTemplate.class).length); }