@TargetSE(valueSE=TYPESE) @RetentionSE(valueSE=RUNTIMESE) @DocumentedSE @InheritedSE @BootstrapWith(value=org.springframework.boot.test.autoconfigure.web.client.RestClientTestContextBootstrapper.class) @ExtendWith(value=org.springframework.test.context.junit.jupiter.SpringExtension.class) @OverrideAutoConfiguration(enabled=false) @TypeExcludeFilters(value=RestClientTypeExcludeFilter.class) @AutoConfigureCache @AutoConfigureWebClient @AutoConfigureMockRestServiceServer @ImportAutoConfiguration public @interface RestClientTest
RestTemplateBuilder
を使用する Bean のみに焦点を当てた Spring REST クライアントテストのアノテーション。 このアノテーションを使用すると、完全な自動構成が無効になり、代わりに残りのクライアントテストに関連する構成のみが適用されます(つまり、Jackson または GSON 自動構成と @JsonComponent
Bean、通常の @Component
Bean は適用されません)。
デフォルトでは、RestClientTest
でアノテーションが付けられたテストも MockRestServiceServer
を自動構成します。より細かい制御のために、@AutoConfigureMockRestServiceServer
アノテーションを使用できます。
RestTemplateBuilder
を使用せずに RestTemplate
を直接注入する Bean をテストする場合は、@AutoConfigureWebClient(registerRestTemplate=true)
を追加できます。
JUnit 4 を使用する場合、このアノテーションは @RunWith(SpringRunner.class)
と組み合わせて使用する必要があります。
修飾子と型 | オプションの要素と説明 |
---|---|
ClassSE<?>[] | components テストするコンポーネントを指定します。 |
ClassSE<?>[] | excludeAutoConfiguration このテストに適用する必要がある自動構成の除外。 |
ComponentScan.Filter[] | excludeFilters それ以外の場合はアプリケーションコンテキストに追加される Bean のフィルタリングに使用できる除外フィルターのセット。 |
ComponentScan.Filter[] | includeFilters 他の方法でフィルタリングされた Bean をアプリケーションコンテキストに追加するために使用できる一連の組み込みフィルター。 |
StringSE[] | properties テストの実行前に Spring Environment に追加する必要がある key = value 形式のプロパティ。 |
boolean | useDefaultFilters @SpringBootApplication でデフォルトのフィルタリングを使用するかどうかを決定します。 |
ClassSE<?>[] | value テストするコンポーネントを指定します。 |
public abstract StringSE[] properties
Environment
に追加する必要がある key = value 形式のプロパティ。@AliasFor(value="components") public abstract ClassSE<?>[] value
components()
のエイリアスであり、他の属性が定義されていない場合に簡潔にするために使用できます。詳細については、components()
を参照してください。components()
public abstract boolean useDefaultFilters
@SpringBootApplication
で使用するかどうかを決定します。デフォルトでは、@JsonComponent
および Module
Bean のみが含まれています。includeFilters()
, excludeFilters()
public abstract ComponentScan.Filter[] includeFilters
public abstract ComponentScan.Filter[] excludeFilters
@AliasFor(annotation=ImportAutoConfiguration.class, attribute="exclude") public abstract ClassSE<?>[] excludeAutoConfiguration