我正在使用 DBUnit,我遇到了字符串到字符串数组转换的问题。我通过@DatabaseSetup注释传递数据集文件位置。接下来这个位置被传递给从AbstractDataSetLoader(来源:http ://springtestdbunit.github.io/spring-test-dbunit/cobertura/com.github.springtestdbunit.dataset.AbstractDataSetLoader.html )扩展的加载器。在这个类中存在方法
公共 IDataSet loadDataSet(Class testClass, String location) 抛出异常 {
ResourceLoader resourceLoader = getResourceLoader(testClass);
String[] resourceLocations = getResourceLocations(testClass, location);
对于(字符串资源位置:资源位置){
资源资源 = resourceLoader.getResource(resourceLocation);
if (resource.exists()) {
返回创建数据集(资源);
}
}
返回空值;
}
调用 getResourceLocations 方法(该方法在同一个类中实现)
protected String[] getResourceLocations(Class testClass, String location) {
返回新字符串 [] { 位置 };
}
带有位置参数(这是我在 中指定的参数@DatabaseSetup)。我认为以这种方式声明的数组总是必须只包含一个元素,但在loadDataSet方法中我看到对从getResourceLocations. 问题是,getResourceLocations 可以返回包含多个元素的数组吗?