public class FileSystemResource extends Object implements DataResource
public static Object[][] dataProviderGetAllDocuments() throws IOException {
FileSystemResource resource = new FileSystemResource(fileName, USER.class);
Object[][] data = YamlDataProvider.getAllData(resource);
return data;
}
If test requires passing multiple arguments, multiple YamlResources can be defined to create such a data provider.
public static Object[][] dataProviderGetMultipleArguments() throws IOException {
List<FileSystemResource> yamlResources = new ArrayList<FileSystemResource>();
yamlResources.add(new FileSystemResource(fileName1, USER.class));
yamlResources.add(new FileSystemResource(fileName2, USER.class));
Object[][] data = YamlDataProvider.getAllDataMultipleArgs(yamlResources);
return data;
}
Test method signature example:
public void testExample(USER user1, USER user2)
| Constructor and Description |
|---|
FileSystemResource(String fileName)
Use this constructor when a data source file can be found as a resource and does NOT contain a user-defined object.
|
FileSystemResource(String fileName,
Class<?> cls)
Use this constructor when a data source file can be found as a resource and contains a user-defined object.
|
| Modifier and Type | Method and Description |
|---|---|
Class<?> |
getCls()
Fetch the user defined POJO class
|
InputStream |
getInputStream()
Load the input stream of the data file
|
String |
getType()
Fetch the data file extension
|
void |
setCls(Class<?> cls)
Set the user defined POJO class to map data
|
String |
toString() |
public FileSystemResource(String fileName, Class<?> cls)
fileName - cls - public FileSystemResource(String fileName)
fileName - public Class<?> getCls()
DataResourcegetCls in interface DataResourcepublic final void setCls(Class<?> cls)
DataResourcesetCls in interface DataResourcepublic InputStream getInputStream()
DataResourcegetInputStream in interface DataResourcepublic String getType()
DataResourcegetType in interface DataResourceCopyright © 2016 PayPal Open Source. All rights reserved.