01: /**
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */package com.tc.test;
04:
05: import java.io.File;
06: import java.io.FileNotFoundException;
07: import java.io.IOException;
08:
09: /**
10: * A helper that fetches data directories and files, for use in tests. These directories and files must exist.
11: */
12: public class DataDirectoryHelper extends BaseDirectoryHelper {
13:
14: public DataDirectoryHelper(Class theClass) throws IOException {
15: this (theClass, TestConfigObject.getInstance()
16: .dataDirectoryRoot());
17: }
18:
19: // For internal use and tests only.
20: DataDirectoryHelper(Class theClass, String directoryPath) {
21: super (theClass, directoryPath);
22: }
23:
24: protected File fetchDirectory() throws IOException {
25: ClassBasedDirectoryTree tree = new ClassBasedDirectoryTree(
26: getRoot());
27: File theDirectory = tree.getDirectory(getTargetClass());
28: if (!theDirectory.exists())
29: throw new FileNotFoundException("No data directory '"
30: + theDirectory.getAbsolutePath() + "' exists.");
31: return theDirectory;
32: }
33:
34: public File getFile(String path) throws IOException {
35: File theFile = super .getFile(path);
36: if (!theFile.exists())
37: throw new FileNotFoundException("No file '"
38: + theFile.getAbsolutePath() + "' exists.");
39: return theFile;
40: }
41: }
|