You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mrunit.apache.org by br...@apache.org on 2013/03/30 16:33:41 UTC

git commit: MRUNIT-182: TemporaryPath should support test data in subdirectories

Updated Branches:
  refs/heads/trunk 30e2d1fde -> d70cedd1f


MRUNIT-182: TemporaryPath should support test data in subdirectories


Project: http://git-wip-us.apache.org/repos/asf/mrunit/repo
Commit: http://git-wip-us.apache.org/repos/asf/mrunit/commit/d70cedd1
Tree: http://git-wip-us.apache.org/repos/asf/mrunit/tree/d70cedd1
Diff: http://git-wip-us.apache.org/repos/asf/mrunit/diff/d70cedd1

Branch: refs/heads/trunk
Commit: d70cedd1fb09ba3e3cc23882f51bcd6fa07e5463
Parents: 30e2d1f
Author: Brock Noland <br...@apache.org>
Authored: Sat Mar 30 10:33:05 2013 -0500
Committer: Brock Noland <br...@apache.org>
Committed: Sat Mar 30 10:33:26 2013 -0500

----------------------------------------------------------------------
 .../hadoop/mrunit/testutil/TemporaryPath.java      |    2 +-
 .../hadoop/mrunit/testutil/TestTemporaryPath.java  |    9 ++++++++
 src/test/resources/testdir/data.txt                |   17 +++++++++++++++
 3 files changed, 27 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mrunit/blob/d70cedd1/src/main/java/org/apache/hadoop/mrunit/testutil/TemporaryPath.java
----------------------------------------------------------------------
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 @@ public final class TemporaryPath extends ExternalResource {
    * 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;
   }

http://git-wip-us.apache.org/repos/asf/mrunit/blob/d70cedd1/src/test/java/org/apache/hadoop/mrunit/testutil/TestTemporaryPath.java
----------------------------------------------------------------------
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 @@ public class TestTemporaryPath {
   }
 
   @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");

http://git-wip-us.apache.org/repos/asf/mrunit/blob/d70cedd1/src/test/resources/testdir/data.txt
----------------------------------------------------------------------
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.
+ */