Enum Class SpringBootTest.WebEnvironment
java.lang.Object
java.lang.Enum<SpringBootTest.WebEnvironment>
org.springframework.boot.test.context.SpringBootTest.WebEnvironment
- All Implemented Interfaces:
- Serializable, Comparable<SpringBootTest.WebEnvironment>, Constable
- Enclosing class:
- SpringBootTest
An enumeration web environment modes.
- Since:
- 1.4.0
- Author:
- Phillip Webb, Andy Wilkinson
- 
Nested Class SummaryNested classes/interfaces inherited from class EnumEnum.EnumDesc<E>
- 
Enum Constant SummaryEnum ConstantsEnum ConstantDescriptionCreates a web application context (reactive or servlet based) without defining anyserver.port=0Environmentproperty.Creates aWebApplicationContextwith a mock servlet environment if servlet APIs are on the classpath, aReactiveWebApplicationContextif Spring WebFlux is on the classpath or a regularApplicationContextotherwise.Creates anApplicationContextand setsSpringApplication.setWebApplicationType(WebApplicationType)toWebApplicationType.NONE.Creates a web application context (reactive or servlet based) and sets aserver.port=0Environmentproperty (which usually triggers listening on a random port).
- 
Method SummaryModifier and TypeMethodDescriptionbooleanReturn if the environment uses an embedded web server.Returns the enum constant of this class with the specified name.static SpringBootTest.WebEnvironment[]values()Returns an array containing the constants of this enum class, in the order they are declared.
- 
Enum Constant Details- 
MOCKCreates aWebApplicationContextwith a mock servlet environment if servlet APIs are on the classpath, aReactiveWebApplicationContextif Spring WebFlux is on the classpath or a regularApplicationContextotherwise.
- 
RANDOM_PORTCreates a web application context (reactive or servlet based) and sets aserver.port=0Environmentproperty (which usually triggers listening on a random port). Requires a dependency onspring-boot-web-server. Often used in conjunction with a@LocalServerPortinjected field on the test.
- 
DEFINED_PORTCreates a web application context (reactive or servlet based) without defining anyserver.port=0Environmentproperty. Requires a dependency onspring-boot-web-server.
- 
NONECreates anApplicationContextand setsSpringApplication.setWebApplicationType(WebApplicationType)toWebApplicationType.NONE.
 
- 
- 
Method Details- 
valuesReturns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
 
- 
valueOfReturns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified name
- NullPointerException- if the argument is null
 
- 
isEmbeddedpublic boolean isEmbedded()Return if the environment uses an embedded web server.- Returns:
- if an embedded web server is used
 
 
-