(no commit message)
[utils] / support / test / org / wamblee / test / FileSystemUtils.java
index da05687010a77e1d5ecae06c8b9a608c0f962ecf..7d1c2d7e8efb50088efde7d60a24e65bfa7792df 100644 (file)
@@ -39,6 +39,11 @@ public final class FileSystemUtils {
      * Test output directory relative to the sub project.
      */
     private static final String TEST_OUTPUT_DIR = "resources/testoutput";
+    
+    /**
+     * Test input directory relative to the sub project. 
+     */
+    private static final String TEST_INPUT_DIR = "resources/test";
 
     /*
      * Disabled.
@@ -112,6 +117,7 @@ public final class FileSystemUtils {
         URL location = source.getLocation();
         String protocol = location.getProtocol();
         if (!protocol.equals("file")) {
+            LOG.warn("protocol is not 'file': " + location);
             return new File(aRelativePath);
         }
 
@@ -120,6 +126,7 @@ public final class FileSystemUtils {
             path = URLDecoder.decode(location.getPath(), "UTF-8");
         } catch (UnsupportedEncodingException e) {
             // ignore it.. just don't decode
+            LOG.warn("Decoding path failed: '" + location.getPath() + "'", e );
         }
 
         return new File(new File(path).getParentFile(), aRelativePath);
@@ -157,6 +164,20 @@ public final class FileSystemUtils {
         String packagePath = packageName.replaceAll("\\.", "/");
         return new File(file, packagePath);
     }
+    
+    /**
+     * Gets the test input directory for a specific test class.
+     * 
+     * @param aTestClass
+     *            Test class.
+     * @return Test input directory.
+     */
+    public static File getTestInputDir(Class aTestClass) {
+        File file = getPath(TEST_INPUT_DIR, aTestClass);
+        String packageName = aTestClass.getPackage().getName();
+        String packagePath = packageName.replaceAll("\\.", "/");
+        return new File(file, packagePath);
+    }
 
     /**
      * Creates a directory hierarchy for the output directory of a test class if