|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.test.context.ContextLoaderUtils
abstract class ContextLoaderUtils
Utility methods for working with ContextLoaders
and
SmartContextLoaders
and resolving resource locations,
configuration classes, and active bean definition profiles.
ContextLoader
,
SmartContextLoader
,
ContextConfiguration
,
ContextConfigurationAttributes
,
ActiveProfiles
,
MergedContextConfiguration
Field Summary | |
---|---|
private static java.lang.String |
DEFAULT_CONTEXT_LOADER_CLASS_NAME
|
private static Log |
logger
|
Constructor Summary | |
---|---|
private |
ContextLoaderUtils()
|
Method Summary | |
---|---|
(package private) static MergedContextConfiguration |
buildMergedContextConfiguration(java.lang.Class<?> testClass,
java.lang.String defaultContextLoaderClassName)
Build the merged context configuration
for the supplied testClass and
defaultContextLoaderClassName . |
(package private) static java.lang.String[] |
resolveActiveProfiles(java.lang.Class<?> clazz)
Resolve active bean definition profiles for the supplied Class . |
(package private) static java.util.List<ContextConfigurationAttributes> |
resolveContextConfigurationAttributes(java.lang.Class<?> clazz)
Resolve the list of configuration
attributes for the supplied class and its superclasses. |
(package private) static ContextLoader |
resolveContextLoader(java.lang.Class<?> testClass,
java.lang.String defaultContextLoaderClassName)
Resolve the ContextLoader class to use for the
supplied testClass and then instantiate and return that
ContextLoader . |
(package private) static java.lang.Class<? extends ContextLoader> |
resolveContextLoaderClass(java.lang.Class<?> testClass,
java.lang.String defaultContextLoaderClassName)
Resolve the ContextLoader Class to use for the supplied
testClass . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Log logger
private static final java.lang.String DEFAULT_CONTEXT_LOADER_CLASS_NAME
Constructor Detail |
---|
private ContextLoaderUtils()
Method Detail |
---|
static ContextLoader resolveContextLoader(java.lang.Class<?> testClass, java.lang.String defaultContextLoaderClassName)
ContextLoader
class
to use for the
supplied testClass
and then instantiate and return that
ContextLoader
.
If the supplied defaultContextLoaderClassName
is
null
or empty, the standard
default context loader class name "org.springframework.test.context.support.DelegatingSmartContextLoader"
will be used. For details on the class resolution process, see
#resolveContextLoaderClass()
.
testClass
- the test class for which the ContextLoader
should be resolved (must not be null
)defaultContextLoaderClassName
- the name of the default
ContextLoader
class to use (may be null
)
ContextLoader
for the supplied
testClass
(never null
)#resolveContextLoaderClass()
static java.lang.Class<? extends ContextLoader> resolveContextLoaderClass(java.lang.Class<?> testClass, java.lang.String defaultContextLoaderClassName)
ContextLoader
Class
to use for the supplied
testClass
.
loader
attribute of
@ContextConfiguration
is configured
with an explicit class, that class will be returned.loader
class is not specified, the class hierarchy
will be traversed to find a parent class annotated with
@ContextConfiguration
; go to step #1.loader
class is found after traversing
the class hierarchy, an attempt will be made to load and return the class
with the supplied defaultContextLoaderClassName
.
testClass
- the class for which to resolve the ContextLoader
class; must not be null
defaultContextLoaderClassName
- the name of the default
ContextLoader
class to use; must not be null
or empty
ContextLoader
class to use for the supplied test class
java.lang.IllegalArgumentException
- if @ContextConfiguration
is not
present on the supplied test class
java.lang.IllegalStateException
- if the default ContextLoader
class
could not be loadedstatic java.util.List<ContextConfigurationAttributes> resolveContextConfigurationAttributes(java.lang.Class<?> clazz)
configuration
attributes
for the supplied class
and its superclasses.
Note that the inheritLocations
flag of @ContextConfiguration
will be taken into consideration.
Specifically, if the inheritLocations
flag is set to
true
, configuration attributes defined in the annotated
class will be appended to the configuration attributes defined in
superclasses.
clazz
- the class for which to resolve the configuration attributes (must
not be null
)
null
)
java.lang.IllegalArgumentException
- if the supplied class is null
or
if @ContextConfiguration
is not present on the supplied classstatic java.lang.String[] resolveActiveProfiles(java.lang.Class<?> clazz)
Class
.
Note that the inheritProfiles
flag of @ActiveProfiles
will be taken into
consideration. Specifically, if the inheritProfiles
flag is
set to true
, profiles defined in the annotated class will be
merged with those defined in superclasses.
clazz
- the class for which to resolve the active profiles (must
not be null
)
null
)ActiveProfiles
,
Profile
static MergedContextConfiguration buildMergedContextConfiguration(java.lang.Class<?> testClass, java.lang.String defaultContextLoaderClassName)
merged context configuration
for the supplied testClass
and
defaultContextLoaderClassName
.
testClass
- the test class for which the MergedContextConfiguration
should be built (must not be null
)defaultContextLoaderClassName
- the name of the default
ContextLoader
class to use (may be null
)
#resolveContextLoader()
,
#resolveContextConfigurationAttributes()
,
SmartContextLoader#processContextConfiguration()
,
ContextLoader#processLocations()
,
#resolveActiveProfiles()
,
MergedContextConfiguration
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |