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.web; 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; 031import org.springframework.test.context.junit.jupiter.SpringExtension; 032import org.springframework.test.context.web.WebAppConfiguration; 033 034/** 035 * {@code @SpringJUnitWebConfig} is a <em>composed annotation</em> that combines 036 * {@link ExtendWith @ExtendWith(SpringExtension.class)} from JUnit Jupiter with 037 * {@link ContextConfiguration @ContextConfiguration} and 038 * {@link WebAppConfiguration @WebAppConfiguration} from the <em>Spring TestContext 039 * Framework</em>. 040 * 041 * @author Sam Brannen 042 * @since 5.0 043 * @see ExtendWith 044 * @see SpringExtension 045 * @see ContextConfiguration 046 * @see WebAppConfiguration 047 * @see org.springframework.test.context.junit.jupiter.SpringJUnitConfig 048 */ 049@ExtendWith(SpringExtension.class) 050@ContextConfiguration 051@WebAppConfiguration 052@Documented 053@Inherited 054@Retention(RetentionPolicy.RUNTIME) 055@Target(ElementType.TYPE) 056public @interface SpringJUnitWebConfig { 057 058 /** 059 * Alias for {@link ContextConfiguration#classes}. 060 */ 061 @AliasFor(annotation = ContextConfiguration.class, attribute = "classes") 062 Class<?>[] value() default {}; 063 064 /** 065 * Alias for {@link ContextConfiguration#classes}. 066 */ 067 @AliasFor(annotation = ContextConfiguration.class) 068 Class<?>[] classes() default {}; 069 070 /** 071 * Alias for {@link ContextConfiguration#locations}. 072 */ 073 @AliasFor(annotation = ContextConfiguration.class) 074 String[] locations() default {}; 075 076 /** 077 * Alias for {@link ContextConfiguration#initializers}. 078 */ 079 @AliasFor(annotation = ContextConfiguration.class) 080 Class<? extends ApplicationContextInitializer<?>>[] initializers() default {}; 081 082 /** 083 * Alias for {@link ContextConfiguration#inheritLocations}. 084 */ 085 @AliasFor(annotation = ContextConfiguration.class) 086 boolean inheritLocations() default true; 087 088 /** 089 * Alias for {@link ContextConfiguration#inheritInitializers}. 090 */ 091 @AliasFor(annotation = ContextConfiguration.class) 092 boolean inheritInitializers() default true; 093 094 /** 095 * Alias for {@link ContextConfiguration#name}. 096 */ 097 @AliasFor(annotation = ContextConfiguration.class) 098 String name() default ""; 099 100 /** 101 * Alias for {@link WebAppConfiguration#value}. 102 */ 103 @AliasFor(annotation = WebAppConfiguration.class, attribute = "value") 104 String resourcePath() default "src/main/webapp"; 105 106}