001/* 002 * Copyright 2002-2017 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.test.context.junit.jupiter; 018 019import java.lang.annotation.Documented; 020import java.lang.annotation.ElementType; 021import java.lang.annotation.Inherited; 022import java.lang.annotation.Retention; 023import java.lang.annotation.RetentionPolicy; 024import java.lang.annotation.Target; 025 026import org.junit.jupiter.api.extension.ExtendWith; 027 028import org.springframework.context.ApplicationContextInitializer; 029import org.springframework.core.annotation.AliasFor; 030import org.springframework.test.context.ContextConfiguration; 031 032/** 033 * {@code @SpringJUnitConfig} is a <em>composed annotation</em> that combines 034 * {@link ExtendWith @ExtendWith(SpringExtension.class)} from JUnit Jupiter with 035 * {@link ContextConfiguration @ContextConfiguration} from the <em>Spring TestContext 036 * Framework</em>. 037 * 038 * @author Sam Brannen 039 * @since 5.0 040 * @see ExtendWith 041 * @see SpringExtension 042 * @see ContextConfiguration 043 * @see org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig 044 */ 045@ExtendWith(SpringExtension.class) 046@ContextConfiguration 047@Documented 048@Inherited 049@Retention(RetentionPolicy.RUNTIME) 050@Target(ElementType.TYPE) 051public @interface SpringJUnitConfig { 052 053 /** 054 * Alias for {@link ContextConfiguration#classes}. 055 */ 056 @AliasFor(annotation = ContextConfiguration.class, attribute = "classes") 057 Class<?>[] value() default {}; 058 059 /** 060 * Alias for {@link ContextConfiguration#classes}. 061 */ 062 @AliasFor(annotation = ContextConfiguration.class) 063 Class<?>[] classes() default {}; 064 065 /** 066 * Alias for {@link ContextConfiguration#locations}. 067 */ 068 @AliasFor(annotation = ContextConfiguration.class) 069 String[] locations() default {}; 070 071 /** 072 * Alias for {@link ContextConfiguration#initializers}. 073 */ 074 @AliasFor(annotation = ContextConfiguration.class) 075 Class<? extends ApplicationContextInitializer<?>>[] initializers() default {}; 076 077 /** 078 * Alias for {@link ContextConfiguration#inheritLocations}. 079 */ 080 @AliasFor(annotation = ContextConfiguration.class) 081 boolean inheritLocations() default true; 082 083 /** 084 * Alias for {@link ContextConfiguration#inheritInitializers}. 085 */ 086 @AliasFor(annotation = ContextConfiguration.class) 087 boolean inheritInitializers() default true; 088 089 /** 090 * Alias for {@link ContextConfiguration#name}. 091 */ 092 @AliasFor(annotation = ContextConfiguration.class) 093 String name() default ""; 094 095}