Polish "Add test slice for Spring Data Cassandra"

See gh-17490
This commit is contained in:
Stephane Nicoll
2020-08-05 10:53:20 +02:00
parent ae152b176b
commit 313b2bef6f
22 changed files with 174 additions and 162 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 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.
@@ -27,11 +27,11 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
/**
* {@link ImportAutoConfiguration Auto-configuration imports} for typical Data Cassandra
* tests. Most tests should consider using {@link DataCassandraTest} rather than using
* this annotation directly.
* tests. Most tests should consider using {@link DataCassandraTest @DataCassandraTest}
* rather than using this annotation directly.
*
* @author Artsiom Yudovin
* @since 2.1.0
* @since 2.4.0
* @see DataCassandraTest
*/
@Target(ElementType.TYPE)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 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.
@@ -30,25 +30,25 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration;
import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache;
import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.core.annotation.AliasFor;
import org.springframework.core.env.Environment;
import org.springframework.test.context.BootstrapWith;
import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
* Annotation that can be used in combination with {@code @RunWith(SpringRunner.class)}
* for a typical Cassandra test. Can be used when a test focuses <strong>only</strong> on
* Annotation that can be used for a Cassandra test that focuses <strong>only</strong> on
* Cassandra components.
* <p>
* Using this annotation will disable full auto-configuration and instead apply only
* configuration relevant to Cassandra tests.
* <p>
* By default, tests annotated with {@code @DataCassandraTest} will use an embedded
* in-memory Cassandra process (if available).
* When using JUnit 4, this annotation should be used in combination with
* {@code @RunWith(SpringRunner.class)}.
*
* @author Artsiom Yudovin
* @since 2.1.0
* @author Stephane Nicoll
* @since 2.4.0
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@@ -86,14 +86,14 @@ public @interface DataCassandraTest {
* application context.
* @return include filters to apply
*/
ComponentScan.Filter[] includeFilters() default {};
Filter[] includeFilters() default {};
/**
* A set of exclude filters which can be used to filter beans that would otherwise be
* added to the application context.
* @return exclude filters to apply
*/
ComponentScan.Filter[] excludeFilters() default {};
Filter[] excludeFilters() default {};
/**
* Auto-configuration exclusions that should be applied for this test.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 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.
@@ -18,6 +18,7 @@ package org.springframework.boot.test.autoconfigure.data.cassandra;
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper;
import org.springframework.core.annotation.MergedAnnotations;
import org.springframework.core.annotation.MergedAnnotations.SearchStrategy;
import org.springframework.test.context.TestContextBootstrapper;
/**
@@ -25,14 +26,13 @@ import org.springframework.test.context.TestContextBootstrapper;
* support.
*
* @author Artsiom Yudovin
* @since 2.1.0
*/
public class DataCassandraTestContextBootstrapper extends SpringBootTestContextBootstrapper {
class DataCassandraTestContextBootstrapper extends SpringBootTestContextBootstrapper {
@Override
protected String[] getProperties(Class<?> testClass) {
return MergedAnnotations.from(testClass, MergedAnnotations.SearchStrategy.INHERITED_ANNOTATIONS)
.get(DataCassandraTest.class).getValue("properties", String[].class).orElse(null);
return MergedAnnotations.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS).get(DataCassandraTest.class)
.getValue("properties", String[].class).orElse(null);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 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.
@@ -23,9 +23,8 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust
* {@link TypeExcludeFilter} for {@link DataCassandraTest @DataCassandraTest}.
*
* @author Artsiom Yudovin
* @since 2.1.0
*/
public class DataCassandraTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataCassandraTest> {
class DataCassandraTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter<DataCassandraTest> {
protected DataCassandraTypeExcludeFilter(Class<?> testClass) {
super(testClass);

View File

@@ -6,6 +6,8 @@ org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration
org.springframework.boot.test.autoconfigure.data.cassandra.AutoConfigureDataCassandra=\
org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration,\
org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration,\
org.springframework.boot.autoconfigure.data.cassandra.CassandraReactiveDataAutoConfiguration,\
org.springframework.boot.autoconfigure.data.cassandra.CassandraReactiveRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.cassandra.CassandraRepositoriesAutoConfiguration
# AutoConfigureDataJdbc auto-configuration imports