001/* 002 * Copyright 2002-2016 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.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 026/** 027 * {@code @WebAppConfiguration} is a class-level annotation that is used to 028 * declare that the {@code ApplicationContext} loaded for an integration test 029 * should be a {@link org.springframework.web.context.WebApplicationContext 030 * WebApplicationContext}. 031 * 032 * <p>The presence of {@code @WebAppConfiguration} on a test class indicates that 033 * a {@code WebApplicationContext} should be loaded for the test using a default 034 * for the path to the root of the web application. To override the default, 035 * specify an explicit resource path via the {@link #value} attribute. 036 * 037 * <p>Note that {@code @WebAppConfiguration} must be used in conjunction with 038 * {@link org.springframework.test.context.ContextConfiguration @ContextConfiguration}, 039 * either within a single test class or within a test class hierarchy. 040 * 041 * <p>As of Spring Framework 4.0, this annotation may be used as a 042 * <em>meta-annotation</em> to create custom <em>composed annotations</em>. 043 * 044 * @author Sam Brannen 045 * @since 3.2 046 * @see org.springframework.web.context.WebApplicationContext 047 * @see org.springframework.test.context.ContextConfiguration 048 * @see ServletTestExecutionListener 049 */ 050@Target(ElementType.TYPE) 051@Retention(RetentionPolicy.RUNTIME) 052@Documented 053@Inherited 054public @interface WebAppConfiguration { 055 056 /** 057 * The resource path to the root directory of the web application. 058 * <p>A path that does not include a Spring resource prefix (e.g., {@code classpath:}, 059 * {@code file:}, etc.) will be interpreted as a file system resource, and a 060 * path should not end with a slash. 061 * <p>Defaults to {@code "src/main/webapp"} as a file system resource. Note 062 * that this is the standard directory for the root of a web application in 063 * a project that follows the standard Maven project layout for a WAR. 064 */ 065 String value() default "src/main/webapp"; 066 067}