MRUNIT-182: TemporaryPath should support test data in subdirectories
diff --git a/src/main/java/org/apache/hadoop/mrunit/testutil/TemporaryPath.java b/src/main/java/org/apache/hadoop/mrunit/testutil/TemporaryPath.java
index 1b8ca5c..2f915d0 100644
--- a/src/main/java/org/apache/hadoop/mrunit/testutil/TemporaryPath.java
+++ b/src/main/java/org/apache/hadoop/mrunit/testutil/TemporaryPath.java
@@ -132,7 +132,7 @@
    * Copy a classpath resource to {@link File}.
    */
   public File copyResourceFile(String resourceName) throws IOException {
-    File dest = new File(tmp.getRoot(), resourceName);
+    File dest = new File(tmp.getRoot(), new File(resourceName).getName());
     copy(resourceName, dest);
     return dest;
   }
diff --git a/src/test/java/org/apache/hadoop/mrunit/testutil/TestTemporaryPath.java b/src/test/java/org/apache/hadoop/mrunit/testutil/TestTemporaryPath.java
index 5a5e2de..77bde65 100644
--- a/src/test/java/org/apache/hadoop/mrunit/testutil/TestTemporaryPath.java
+++ b/src/test/java/org/apache/hadoop/mrunit/testutil/TestTemporaryPath.java
@@ -72,6 +72,15 @@
   }
 
   @Test
+  public void testCopyResourceNested() throws IOException {
+    File dest = tmpDir.getFile("data.txt");
+    assertThat(dest.exists(), is(false));
+
+    tmpDir.copyResourceFile("testdir/data.txt");
+    assertThat(dest.exists(), is(true));
+  }
+  
+  @Test
   public void testGetDefaultConfiguration() {
     Configuration conf = tmpDir.getDefaultConfiguration();
     String fooDir = conf.get("foo.tmp");
diff --git a/src/test/resources/testdir/data.txt b/src/test/resources/testdir/data.txt
new file mode 100644
index 0000000..5d5f1e3
--- /dev/null
+++ b/src/test/resources/testdir/data.txt
@@ -0,0 +1,17 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */