Class ProfileValueUtils
- java.lang.Object
- org.springframework.test.annotation.ProfileValueUtils
public abstract class ProfileValueUtils extends Object
General utility methods for working with profile values.- Since:
- 2.5
- Author:
- Sam Brannen, Juergen Hoeller
- See Also:
ProfileValueSource
,ProfileValueSourceConfiguration
,IfProfileValue
Constructor Summary
Constructors Constructor Description ProfileValueUtils()
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
isTestEnabledInThisEnvironment(Class<?> testClass)
Determine if the suppliedtestClass
is enabled in the current environment, as specified by the@IfProfileValue
annotation at the class level.static boolean
isTestEnabledInThisEnvironment(Method testMethod, Class<?> testClass)
Determine if the suppliedtestMethod
is enabled in the current environment, as specified by the@IfProfileValue
annotation, which may be declared on the test method itself or at the class level.static boolean
isTestEnabledInThisEnvironment(ProfileValueSource profileValueSource, Method testMethod, Class<?> testClass)
Determine if the suppliedtestMethod
is enabled in the current environment, as specified by the@IfProfileValue
annotation, which may be declared on the test method itself or at the class level.static ProfileValueSource
retrieveProfileValueSource(Class<?> testClass)
Retrieves theProfileValueSource
type for the specifiedtest class
as configured via the@ProfileValueSourceConfiguration
annotation and instantiates a new instance of that type.
Constructor Detail
ProfileValueUtils
public ProfileValueUtils()
Method Detail
retrieveProfileValueSource
public static ProfileValueSource retrieveProfileValueSource(Class<?> testClass)
Retrieves theProfileValueSource
type for the specifiedtest class
as configured via the@ProfileValueSourceConfiguration
annotation and instantiates a new instance of that type.If
@ProfileValueSourceConfiguration
is not present on the specified class or if a customProfileValueSource
is not declared, the defaultSystemProfileValueSource
will be returned instead.- Parameters:
testClass
- the test class for which the ProfileValueSource should be retrieved- Returns:
- the configured (or default) ProfileValueSource for the specified class
- See Also:
SystemProfileValueSource
isTestEnabledInThisEnvironment
public static boolean isTestEnabledInThisEnvironment(Class<?> testClass)
Determine if the suppliedtestClass
is enabled in the current environment, as specified by the@IfProfileValue
annotation at the class level.Defaults to
true
if no@IfProfileValue
annotation is declared.- Parameters:
testClass
- the test class- Returns:
true
if the test is enabled in the current environment
isTestEnabledInThisEnvironment
public static boolean isTestEnabledInThisEnvironment(Method testMethod, Class<?> testClass)
Determine if the suppliedtestMethod
is enabled in the current environment, as specified by the@IfProfileValue
annotation, which may be declared on the test method itself or at the class level. Class-level usage overrides method-level usage.Defaults to
true
if no@IfProfileValue
annotation is declared.- Parameters:
testMethod
- the test methodtestClass
- the test class- Returns:
true
if the test is enabled in the current environment
isTestEnabledInThisEnvironment
public static boolean isTestEnabledInThisEnvironment(ProfileValueSource profileValueSource, Method testMethod, Class<?> testClass)
Determine if the suppliedtestMethod
is enabled in the current environment, as specified by the@IfProfileValue
annotation, which may be declared on the test method itself or at the class level. Class-level usage overrides method-level usage.Defaults to
true
if no@IfProfileValue
annotation is declared.- Parameters:
profileValueSource
- the ProfileValueSource to use to determine if the test is enabledtestMethod
- the test methodtestClass
- the test class- Returns:
true
if the test is enabled in the current environment