org.springframework.test.annotation
Class ProfileValueUtils

java.lang.Object
  extended by org.springframework.test.annotation.ProfileValueUtils

public abstract class ProfileValueUtils
extends java.lang.Object

General utility methods for working with profile values.

Since:
2.5
Author:
Sam Brannen, Juergen Hoeller
See Also:
ProfileValueSource, ProfileValueSourceConfiguration, IfProfileValue

Field Summary
private static Log logger
           
 
Constructor Summary
ProfileValueUtils()
           
 
Method Summary
static boolean isTestEnabledInThisEnvironment(java.lang.Class<?> testClass)
          Determine if the supplied testClass is enabled in the current environment, as specified by the @IfProfileValue annotation at the class level.
static boolean isTestEnabledInThisEnvironment(java.lang.reflect.Method testMethod, java.lang.Class<?> testClass)
          Determine if the supplied testMethod 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.
private static boolean isTestEnabledInThisEnvironment(ProfileValueSource profileValueSource, IfProfileValue ifProfileValue)
          Determine if the value (or one of the values) in the supplied @IfProfileValue annotation is enabled in the current environment.
static boolean isTestEnabledInThisEnvironment(ProfileValueSource profileValueSource, java.lang.reflect.Method testMethod, java.lang.Class<?> testClass)
          Determine if the supplied testMethod 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(java.lang.Class<?> testClass)
          Retrieves the ProfileValueSource type for the specified test class as configured via the @ProfileValueSourceConfiguration annotation and instantiates a new instance of that type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final Log logger
Constructor Detail

ProfileValueUtils

public ProfileValueUtils()
Method Detail

retrieveProfileValueSource

public static ProfileValueSource retrieveProfileValueSource(java.lang.Class<?> testClass)
Retrieves the ProfileValueSource type for the specified test 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 custom ProfileValueSource is not declared, the default SystemProfileValueSource 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(java.lang.Class<?> testClass)
Determine if the supplied testClass 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(java.lang.reflect.Method testMethod,
                                                     java.lang.Class<?> testClass)
Determine if the supplied testMethod 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 method
testClass - the test class
Returns:
true if the test is enabled in the current environment

isTestEnabledInThisEnvironment

public static boolean isTestEnabledInThisEnvironment(ProfileValueSource profileValueSource,
                                                     java.lang.reflect.Method testMethod,
                                                     java.lang.Class<?> testClass)
Determine if the supplied testMethod 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 enabled
testMethod - the test method
testClass - the test class
Returns:
true if the test is enabled in the current environment

isTestEnabledInThisEnvironment

private static boolean isTestEnabledInThisEnvironment(ProfileValueSource profileValueSource,
                                                      IfProfileValue ifProfileValue)
Determine if the value (or one of the values) in the supplied @IfProfileValue annotation is enabled in the current environment.

Parameters:
profileValueSource - the ProfileValueSource to use to determine if the test is enabled
ifProfileValue - the annotation to introspect; may be null
Returns:
true if the test is enabled in the current environment or if the supplied ifProfileValue is null