next up previous contents
Next: Other References Up: Test Data Organization Previous: Temporary Test Data (class   Contents

Test Data in a Zip File (class ZipFileRepo)

Test data may be stored in a Zip(TM) file in order to conserve disk space. Class junit.extensions.repo.ZipFileRepo provides access to files from a Zip file.

ZipFileRepo is constructed and used as follows:

import java.io.IOException;
...
protected void setUp() throws IOException {
    repo = new ZipFileRepo("/path/to/data.zip");
}
...
File file = repo.getFile("test.properties");

When an instance of ZipFileRepo is constructed, it uncompresses the specified Zip file to a temporary directory. Later on, when files are requested from that instance of ZipFileRepo, files from the temporary directory are returned. In the above example, it is assumed that file data.zip contains file test.properties.

As with ResourceFileRepo, ZipFileRepo deletes all temporary files on exit.