|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.geotools.resources.TestData org.geotools.TestData
Provides access to the common directories provided in the module. This directory is shared by test suites in other modules.
This file has to live in the root package in order to
get access to the directory. If you don't
need this directory, then use the TestData
class provided in the directory.
Method Summary | |
static java.io.File |
copy(java.lang.Object caller,
java.lang.String name)
Copies the named resources from the module to the directory in an other module. |
static java.io.File |
file(java.lang.String name)
Access to getResource(name) as a non-null
File . |
static java.nio.channels.ReadableByteChannel |
openChannel(java.lang.String name)
Provides a channel for named test data. |
static java.io.LineNumberReader |
openReader(java.lang.String name)
Provides a BufferedReader for named test data. |
static java.io.InputStream |
openStream(java.lang.String name)
Provides a non-null InputStream for named test data.
|
static java.net.URL |
url(java.lang.String name)
Access to getResource(name) as a non-null
URL . |
Methods inherited from class org.geotools.resources.TestData |
deleteOnExit, file, getReader, getResource, openChannel, openReader, openStream, run, temp, unzipFile, url |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static java.net.URL url(java.lang.String name) throws java.io.FileNotFoundException
getResource(name)
as a non-null
URL
. At the difference of , this method throws an exception if
the resource is not found. This provides a more explicit explanation about the failure
reason than the infamous NullPointerException
.
name
- Path to file in .
java.io.FileNotFoundException
- if the resource is not found.public static java.io.File file(java.lang.String name) throws java.io.IOException
getResource(name)
as a non-null
File
. You can access the directory with:
TestData.file(null);
name
- Path to file in .
java.io.FileNotFoundException
- if the file is not found.
java.io.IOException
- if the resource can't be fetched for an other reason.public static java.io.InputStream openStream(java.lang.String name) throws java.io.IOException
InputStream
for named test data.
It is the caller responsability to close this stream after usage.
name
- Path to file in .
java.io.FileNotFoundException
- if the resource is not found.
java.io.IOException
- if an error occurs during an input operation.public static java.io.LineNumberReader openReader(java.lang.String name) throws java.io.IOException
BufferedReader
for named test data. The buffered reader is provided as
an LineNumberReader
instance, which is useful for displaying line numbers where
error occur. It is the caller responsability to close this reader after usage.
name
- Path to file in .
java.io.FileNotFoundException
- if the resource is not found.
java.io.IOException
- if an error occurs during an input operation.public static java.nio.channels.ReadableByteChannel openChannel(java.lang.String name) throws java.io.IOException
name
- Path to file in .
java.io.FileNotFoundException
- if the resource is not found.
java.io.IOException
- if an error occurs during an input operation.public static java.io.File copy(java.lang.Object caller, java.lang.String name) throws java.io.IOException
This method is useful when a test case needs to access a resource through a File
,
for example because it want to open it using java.io.RandomAccess
. Because the
resources provided in the module are available to other modules as
a JAR file, other modules can only access them through an URL
unless they copy
them in their own directory.
If the named file already exists in the caller directory, then this method does nothing. It make it safe to invoke this method many time in a test suite, since this method should not copy the file more than once for a given JVM execution. The file will be deleted on exit.
caller
- Calling class or object used to locate the destination .name
- Path to file in .
org/geotools/caller-package/test-data
resource copy, returned for convenience.
java.io.FileNotFoundException
- if the file is not found.
java.io.IOException
- if the resource can't be fetched for an other reason.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |