Package com.android.testutils
Class TestResources
- java.lang.Object
-
- com.android.testutils.TestResources
-
public final class TestResources extends java.lang.ObjectUtil class to help get testing resources.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.io.FilegetDirectory(java.lang.Class<?> clazz, java.lang.String path)Returns a file that is a directory from resources.static java.io.FilegetDirectory(java.lang.String name)Variant ofgetDirectory(Class, String)that only works with absolute paths, so doesn't need a "context" class.static java.io.FilegetFile(java.lang.Class<?> clazz, java.lang.String name)Returns a file from class resources.static java.io.FilegetFile(java.lang.String name)Variant ofgetFile(Class, String)that only works with absolute paths, so doesn't need a "context" class.static voidgetFileInDirectory(java.lang.Class<?> clazz, java.lang.String resourceName, java.lang.String filePath)Given aresourceNamerelative toclazz, copies the resource to a new file atfilePathand registers that to be deleted when the JVM exits.
-
-
-
Method Detail
-
getFile
public static java.io.File getFile(java.lang.String name)
Variant ofgetFile(Class, String)that only works with absolute paths, so doesn't need a "context" class.- See Also:
getFile(Class, String)
-
getFile
public static java.io.File getFile(java.lang.Class<?> clazz, java.lang.String name)Returns a file from class resources. If original resource is not file, a temp file is created and returned with resource stream content; the temp file will be deleted when program exits.- Parameters:
clazz- Test class.name- Resource name.- Returns:
- File with resource content.
-
getFileInDirectory
public static void getFileInDirectory(java.lang.Class<?> clazz, java.lang.String resourceName, java.lang.String filePath)Given aresourceNamerelative toclazz, copies the resource to a new file atfilePathand registers that to be deleted when the JVM exits. If there is an existing file atfilePath, it does nothing.- Parameters:
clazz- Resource class.resourceName- Input name to get resource from class.filePath- Output file name in specific directory.
-
getDirectory
public static java.io.File getDirectory(java.lang.String name)
Variant ofgetDirectory(Class, String)that only works with absolute paths, so doesn't need a "context" class.- See Also:
getDirectory(Class, String)
-
getDirectory
public static java.io.File getDirectory(java.lang.Class<?> clazz, java.lang.String path)Returns a file that is a directory from resources. If original resources is in a jar, the specified directory and all files beneath are copied to system temp root directory. Those copied temp files will be deleted on program exits.- Parameters:
clazz- Class with resources.path- Directory path.- Returns:
- Directory of given path that contains resources.
-
-