|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.geotools.resources.TestData
Provides access to test-data directories associated with junit tests.
We have chosen test-data to follow the javadoc "doc-files" convention of ensuring that data directories don't look anything like normal java packages.
Example:
class MyClass {
public void example(){
Image testImage =
new ImageIcon( TestData.getResource( this, "test.png" ) ).getImage();
Reader reader = TestData.getReader( this, "script.xml" );
}
}
Where:
By convention you should try and locate test-data near the junit test cases that uses it.
Constructor Summary | |
TestData()
|
Method Summary | |
static java.io.File |
file(java.lang.Class caller,
java.lang.String path)
Access to getResource(caller, path) as a File .
|
static java.io.File |
file(java.lang.Object caller,
java.lang.String path)
Access to getResource(caller, path) as a File .
|
static java.io.BufferedReader |
getReader(java.lang.Class caller,
java.lang.String name)
Provided a BufferedReader for named test data.
|
static java.io.BufferedReader |
getReader(java.lang.Object host,
java.lang.String name)
Provided a BufferedReader for named test data.
|
static java.net.URL |
getResource(java.lang.Class caller,
java.lang.String name)
Locate named test-data resource for caller. |
static java.net.URL |
getResource(java.lang.Object caller,
java.lang.String name)
Locate named test-data resource for caller. |
static java.io.File |
temp(java.lang.Object caller,
java.lang.String name)
Creates a temporary file with the given name. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TestData()
Method Detail |
public static final java.io.BufferedReader getReader(java.lang.Class caller, java.lang.String name) throws java.io.IOException
BufferedReader
for named test data.
It is the caller responsability to close this reader after usage.
caller
- The class of the object associated with named data.name
- of test data to load.
null
if the named test data are not found.
java.io.IOException
- if an error occurs during an input operation.public static final java.io.BufferedReader getReader(java.lang.Object host, java.lang.String name) throws java.io.IOException
BufferedReader
for named test data.
It is the caller responsability to close this reader after usage.
host
- Object associated with named dataname
- of test data to load
null
if the named test data are not found.
java.io.IOException
- if an error occurs during an input operation.public static final java.net.URL getResource(java.lang.Class caller, java.lang.String name)
caller
- Class used to locate test-data.name
- name of test-data.
public static final java.net.URL getResource(java.lang.Object caller, java.lang.String name)
caller
- Object used to locate test-dataname
- name of test-data
public static final java.io.File file(java.lang.Object caller, java.lang.String path) throws java.io.IOException
getResource(caller, path)
as a File
.
You can access the test-data directory with:
TestData.file( this, null )
caller
- Calling object used to locate test-datapath
- Path to file in testdata
java.io.IOException
- if the file is not found.public static final java.io.File file(java.lang.Class caller, java.lang.String path) throws java.io.IOException
getResource(caller, path)
as a File
.
You can access the test-data directory with:
TestData.file( MyClass.class, null )
caller
- Calling class used to locate test-datapath
- Path to file in testdata
java.io.IOException
- if the file is not found.public static final java.io.File temp(java.lang.Object caller, java.lang.String name) throws java.io.IOException
java.io.IOException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |