类 TestContextResourceUtils
- java.lang.Object
- org.springframework.test.context.util.TestContextResourceUtils
public abstract class TestContextResourceUtils extends Object
Utility methods for working with resources within the Spring TestContext Framework. Mainly for internal use within the framework.- 从以下版本开始:
- 4.1
- 作者:
- Sam Brannen, Tadaya Tsuyukubo
- 另请参阅:
ResourceUtils
,Resource
,ClassPathResource
,FileSystemResource
,UrlResource
,ResourceLoader
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static String[]
convertToClasspathResourcePaths(Class<?> clazz, String... paths)
Convert the supplied paths to classpath resource paths.static List<Resource>
convertToResourceList(ResourceLoader resourceLoader, String... paths)
Convert the supplied paths to a list ofResource
handles using the givenResourceLoader
.static Resource[]
convertToResources(ResourceLoader resourceLoader, String... paths)
Convert the supplied paths to an array ofResource
handles using the givenResourceLoader
.
方法详细资料
convertToClasspathResourcePaths
public static String[] convertToClasspathResourcePaths(Class<?> clazz, 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. - A path starting with a slash will be treated as an absolute path within the classpath, for example:
"/org/example/schema.sql"
. - A path which is prefixed with a URL protocol (e.g.,
classpath:
,file:
,http:
, etc.) will becleaned
but otherwise unmodified.
- 参数:
clazz
- the class with which the paths are associatedpaths
- the paths to be converted- 返回:
- a new array of converted resource paths
- 另请参阅:
convertToResources(org.springframework.core.io.ResourceLoader, java.lang.String...)
- A plain path — for example,
convertToResources
public static Resource[] convertToResources(ResourceLoader resourceLoader, String... paths)
Convert the supplied paths to an array ofResource
handles using the givenResourceLoader
.- 参数:
resourceLoader
- theResourceLoader
to use to convert the pathspaths
- the paths to be converted- 返回:
- a new array of resources
- 另请参阅:
convertToResourceList(ResourceLoader, String...)
,convertToClasspathResourcePaths(java.lang.Class<?>, java.lang.String...)
convertToResourceList
public static List<Resource> convertToResourceList(ResourceLoader resourceLoader, String... paths)
Convert the supplied paths to a list ofResource
handles using the givenResourceLoader
.- 参数:
resourceLoader
- theResourceLoader
to use to convert the pathspaths
- the paths to be converted- 返回:
- a new list of resources
- 从以下版本开始:
- 4.2
- 另请参阅:
convertToResources(ResourceLoader, String...)
,convertToClasspathResourcePaths(java.lang.Class<?>, java.lang.String...)