Enum SpringBootTest.WebEnvironment
- java.lang.Object
- java.lang.Enum<SpringBootTest.WebEnvironment>
- org.springframework.boot.test.context.SpringBootTest.WebEnvironment
- All Implemented Interfaces:
Serializable,Comparable<SpringBootTest.WebEnvironment>
- Enclosing class:
- SpringBootTest
public static enum SpringBootTest.WebEnvironment extends Enum<SpringBootTest.WebEnvironment>
An enumeration web environment modes.
Enum Constant Summary
Enum Constants Enum Constant Description DEFINED_PORTCreates a (reactive) web application context without defining anyserver.port=0Environmentproperty.MOCKCreates aWebApplicationContextwith a mock servlet environment if servlet APIs are on the classpath, aReactiveWebApplicationContextif Spring WebFlux is on the classpath or a regularApplicationContextotherwise.NONECreates anApplicationContextand setsSpringApplication.setWebApplicationType(WebApplicationType)toWebApplicationType.NONE.RANDOM_PORTCreates a web application context (reactive or servlet based) and sets aserver.port=0Environmentproperty (which usually triggers listening on a random port).
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisEmbedded()Return if the environment uses anServletWebServerApplicationContext.static SpringBootTest.WebEnvironmentvalueOf(String name)Returns the enum constant of this type with the specified name.static SpringBootTest.WebEnvironment[]values()Returns an array containing the constants of this enum type, in the order they are declared.
Enum Constant Detail
MOCK
public static final SpringBootTest.WebEnvironment MOCK
Creates aWebApplicationContextwith a mock servlet environment if servlet APIs are on the classpath, aReactiveWebApplicationContextif Spring WebFlux is on the classpath or a regularApplicationContextotherwise.
RANDOM_PORT
public static final SpringBootTest.WebEnvironment RANDOM_PORT
Creates a web application context (reactive or servlet based) and sets aserver.port=0Environmentproperty (which usually triggers listening on a random port). Often used in conjunction with aLocalServerPortinjected field on the test.
DEFINED_PORT
public static final SpringBootTest.WebEnvironment DEFINED_PORT
Creates a (reactive) web application context without defining anyserver.port=0Environmentproperty.
NONE
public static final SpringBootTest.WebEnvironment NONE
Creates anApplicationContextand setsSpringApplication.setWebApplicationType(WebApplicationType)toWebApplicationType.NONE.
Method Detail
values
public static SpringBootTest.WebEnvironment[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (SpringBootTest.WebEnvironment c : SpringBootTest.WebEnvironment.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
valueOf
public static SpringBootTest.WebEnvironment valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
isEmbedded
public boolean isEmbedded()
Return if the environment uses anServletWebServerApplicationContext.- Returns:
- if an
ServletWebServerApplicationContextis used.