| Copies the named resources from the
sample-data module to the
test-data directory in an other module. For example if
TestData.copy(this, "foo.txt") is
invoked inside a test suite in the
org.geotools.foo package, then this method
copies
org/geotools/test-data/foo.txt (from
sample-data module) to
org/geotools/foo/test-data/foo.txt (in the
foo module).
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
sample-data 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
test-data directory.
If the named file already exists in the caller
test-data 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
if and only if it has
been modified. Callers don't need to worry about cleanup, because the files are copied
in the
target/.../test-data directory, which is not versionned by SVN and is
cleaned by Maven on
mvn clean execution.
Parameters: caller - Calling class or object used to locate the destination test-data . Parameters: name - Path to file in org/geotools/test-data . The file to the org/geotools/caller-package/test-data resource copy, returned for convenience. throws: FileNotFoundException - if the file is not found. throws: IOException - if the resource can't be fetched for an other reason. |