Class TestContextResourceUtils
java.lang.Object
org.springframework.test.context.util.TestContextResourceUtils
Utility methods for working with resources within the Spring TestContext
 Framework. Mainly for internal use within the framework.
- Since:
- 4.1
- Author:
- Sam Brannen, Tadaya Tsuyukubo
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic String[]convertToClasspathResourcePaths(Class<?> clazz, boolean preservePlaceholders, String... paths) Convert the supplied paths to classpath resource paths.static String[]convertToClasspathResourcePaths(Class<?> clazz, String... paths) Convert the supplied paths to classpath resource paths.convertToResourceList(ResourceLoader resourceLoader, String... paths) Convert the supplied paths to a list ofResourcehandles using the givenResourceLoader.convertToResourceList(ResourceLoader resourceLoader, Environment environment, String... paths) Convert the supplied paths to a list ofResourcehandles using the givenResourceLoaderandEnvironment.static Resource[]convertToResources(ResourceLoader resourceLoader, String... paths) Convert the supplied paths to an array ofResourcehandles using the givenResourceLoader.
- 
Constructor Details- 
TestContextResourceUtilspublic TestContextResourceUtils()
 
- 
- 
Method Details- 
convertToClasspathResourcePathsConvert the supplied paths to classpath resource paths.Delegates to convertToClasspathResourcePaths(Class, boolean, String...)withfalsesupplied for thepreservePlaceholdersflag.- Parameters:
- clazz- the class with which the paths are associated
- paths- the paths to be converted
- Returns:
- a new array of converted resource paths
- See Also:
 
- 
convertToClasspathResourcePathspublic static String[] convertToClasspathResourcePaths(Class<?> clazz, boolean preservePlaceholders, String... paths) Convert the supplied paths to classpath resource paths.For each of the supplied paths: - A plain path — for example, "context.xml"— will be treated as a classpath resource that is relative to the package in which the specified class is defined. Such a path will be prepended with theclasspath:prefix and the path to the package for the class.
- A path starting with a slash will be treated as an absolute path
 within the classpath, for example: "/org/example/schema.sql". Such a path will be prepended with theclasspath:prefix.
- A path which is already prefixed with a URL protocol (e.g.,
 classpath:,file:,http:, etc.) will not have its protocol modified.
 Each path will then be cleaned, unless the preservePlaceholdersflag istrueand the path contains one or more placeholders in the form${placeholder.name}.- Parameters:
- clazz- the class with which the paths are associated
- preservePlaceholders-- trueif placeholders should be preserved
- paths- the paths to be converted
- Returns:
- a new array of converted resource paths
- Since:
- 5.2
- See Also:
 
- A plain path — for example, 
- 
convertToResourcesConvert the supplied paths to an array ofResourcehandles using the givenResourceLoader.- Parameters:
- resourceLoader- the- ResourceLoaderto use to convert the paths
- paths- the paths to be converted
- Returns:
- a new array of resources
- See Also:
 
- 
convertToResourceListConvert the supplied paths to a list ofResourcehandles using the givenResourceLoader.- Parameters:
- resourceLoader- the- ResourceLoaderto use to convert the paths
- paths- the paths to be converted
- Returns:
- a new, mutable list of resources
- Since:
- 4.2
- See Also:
 
- 
convertToResourceListpublic static List<Resource> convertToResourceList(ResourceLoader resourceLoader, Environment environment, String... paths) Convert the supplied paths to a list ofResourcehandles using the givenResourceLoaderandEnvironment.- Parameters:
- resourceLoader- the- ResourceLoaderto use to convert the paths
- environment- the- Environmentto use to resolve property placeholders in the paths
- paths- the paths to be converted
- Returns:
- a new, mutable list of resources
- Since:
- 6.2
- See Also:
 
 
-